Skip to content

Commit

Permalink
S3TILS-163: adapt and add tests for inflights
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed May 17, 2024
1 parent f88ce6d commit 445d4cb
Show file tree
Hide file tree
Showing 3 changed files with 536 additions and 14 deletions.
232 changes: 232 additions & 0 deletions tests/unit/CountItems/CountManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ describe('CountItems::CountManager', () => {
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
Expand All @@ -222,6 +223,7 @@ describe('CountItems::CountManager', () => {
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
Expand Down Expand Up @@ -249,6 +251,7 @@ describe('CountItems::CountManager', () => {
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
Expand All @@ -274,6 +277,235 @@ describe('CountItems::CountManager', () => {
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
},
},
});
});

test('should update dataMetrics with inflights', () => {
const workers = createWorkers(1);
const m = new CountManager({
log: new DummyLogger(),
workers,
maxConcurrent: 1,
});
expect(m.dataMetrics).toEqual({
account: {},
bucket: {},
location: {},
});
m._consolidateData({
dataMetrics: {
account: {
account1: {
objectCount: {
current: 10,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 100,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
locations: {
location1: {
objectCount: {
current: 10,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 100,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
},
},
},
},
bucket: {
bucket1: {
objectCount: {
current: 10,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 100,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
},
},
location: {
location1: {
objectCount: {
current: 10,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 100,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
},
},
},
});
expect(m.dataMetrics).toEqual({
account: {
account1: {
objectCount: {
current: 11,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
locations: {
location1: {
objectCount: {
current: 11,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
},
},
},
},
bucket: {
bucket1: {
objectCount: {
current: 11,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
},
},
location: {
location1: {
objectCount: {
current: 11,
deleteMarker: 0,
nonCurrent: 10,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 1,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
usedCapacity: {
current: 200,
nonCurrent: 100,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 100,
Expand Down
60 changes: 60 additions & 0 deletions tests/unit/CountItems/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe('CountItems::utils::consolidateDataMetrics', () => {
usedCapacity: {
current: 0,
nonCurrent: 0,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
Expand All @@ -29,6 +30,7 @@ describe('CountItems::utils::consolidateDataMetrics', () => {
usedCapacity: {
current: 10,
nonCurrent: 10,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
Expand All @@ -53,6 +55,7 @@ describe('CountItems::utils::consolidateDataMetrics', () => {
usedCapacity: {
current: 20,
nonCurrent: 20,
_inflightsPreScan: 0,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
Expand All @@ -73,6 +76,56 @@ describe('CountItems::utils::consolidateDataMetrics', () => {
},
};

const exampleWithInflights = {
usedCapacity: {
current: 20,
nonCurrent: 20,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
objectCount: {
current: 20,
nonCurrent: 20,
deleteMarker: 20,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
};

const expectedResponseWithInflights = {
usedCapacity: {
current: 40,
nonCurrent: 40,
_inflightsPreScan: 1000,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
objectCount: {
current: 40,
nonCurrent: 40,
deleteMarker: 40,
_currentCold: 0,
_nonCurrentCold: 0,
_currentRestored: 0,
_currentRestoring: 0,
_nonCurrentRestored: 0,
_nonCurrentRestoring: 0,
},
};

test('should return zero-value if target and source are both undefined', () => {
const res = consolidateDataMetrics(undefined, undefined);
expect(res).toEqual(zeroValueRes);
Expand Down Expand Up @@ -114,4 +167,11 @@ describe('CountItems::utils::consolidateDataMetrics', () => {
const res = consolidateDataMetrics(target, source);
expect(res).toEqual(zeroValueRes);
});

test('should consolidate inflight delta metrics', () => {
const source = exampleWithInflights;
const target = example1;
const res = consolidateDataMetrics(target, source);
expect(res).toEqual(expectedResponseWithInflights);
});
});
Loading

0 comments on commit 445d4cb

Please sign in to comment.