Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
williamlardier committed Jan 24, 2025
1 parent 2de385c commit da1658f
Show file tree
Hide file tree
Showing 8 changed files with 2,293 additions and 2,250 deletions.
54 changes: 27 additions & 27 deletions tests/functional/collectBucketMetricsAndUpdateBucketCapacityInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
},
},
CapacityInfo: {
Capacity: 0,
Available: 0,
Used: 0,
Capacity: 0n,
Available: 0n,
Used: 0n,
},
},
};
client.updateStorageConsumptionMetrics({}, {
bucket: {
[`${testBucketName}_${testBucketCreationDate}`]: {
usedCapacity: { current: 10, nonCurrent: 10 },
objectCount: { current: 10, nonCurrent: 10 },
usedCapacity: { current: 10n, nonCurrent: 10n },
objectCount: { current: 10n, nonCurrent: 10n },
},
},
}, logger, done);
Expand Down Expand Up @@ -94,8 +94,8 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
next();
}),
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
assert.equal(err, null);
assert.equal(bucketInfo.getCapabilities(), null);
assert.equal(err && err.message, 'InternalError');
assert.equal(bucketInfo, undefined);
next();
}),
], done);
Expand Down Expand Up @@ -126,16 +126,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
assert.equal(err, null);
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
assert.strictEqual(Capacity, 0);
assert.strictEqual(Available, 0);
assert.strictEqual(Used, 0);
assert.strictEqual(Capacity, 0n);
assert.strictEqual(Available, 0n);
assert.strictEqual(Used, 0n);
next();
}),
], done);
});

test('should successfully collect bucketMetrics and update bucket CapacityInfo', done => {
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 30;
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 30n;

return async.series([
next => client.createBucket(testBucketName, {
Expand All @@ -160,16 +160,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
assert.equal(err, null);
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
assert.strictEqual(Capacity, 30);
assert.strictEqual(Available, 10);
assert.strictEqual(Used, 20);
assert.strictEqual(Capacity, 30n);
assert.strictEqual(Available, 10n);
assert.strictEqual(Used, 20n);
next();
}),
], done);
});

test('should update bucket Capacity and Available -1 if Capacity value is not valid', done => {
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 'not-a-number';
test('should update bucket Capacity and Available -1 if Capacity value is not set', done => {
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = -1;

return async.series([
next => client.createBucket(testBucketName, {
Expand All @@ -194,16 +194,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
assert.equal(err, null);
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
assert.strictEqual(Capacity, -1);
assert.strictEqual(Available, -1);
assert.strictEqual(Used, 20);
assert.strictEqual(Capacity, -1n);
assert.strictEqual(Available, -1n);
assert.strictEqual(Used, 20n);
next();
}),
], done);
});

test('should update bucket Available -1 if Capacity value is smaller than Used', done => {
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 10;
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 10n;

return async.series([
next => client.createBucket(testBucketName, {
Expand All @@ -228,16 +228,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
assert.equal(err, null);
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
assert.strictEqual(Capacity, 10);
assert.strictEqual(Available, -1);
assert.strictEqual(Used, 20);
assert.strictEqual(Capacity, 10n);
assert.strictEqual(Available, -1n);
assert.strictEqual(Used, 20n);
next();
}),
], done);
});

test('should update bucket Used and Available -1 if bucket metrics are not retrievable', done => {
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 30;
testBucketCapacities.VeeamSOSApi.CapacityInfo.Capacity = 30n;

return async.series([
next => client.updateStorageConsumptionMetrics({}, { bucket: {} }, logger, next),
Expand All @@ -263,9 +263,9 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
assert.equal(err, null);
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
assert.strictEqual(Capacity, 30);
assert.strictEqual(Available, -1);
assert.strictEqual(Used, -1);
assert.strictEqual(Capacity, 30n);
assert.strictEqual(Available, -1n);
assert.strictEqual(Used, -1n);
next();
}),
], done);
Expand Down
59 changes: 29 additions & 30 deletions tests/functional/countItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const async = require('async');
const werelogs = require('werelogs');
const { BucketInfo, ObjectMD } = require('arsenal').models;
const { constants } = require('arsenal');
const sinon = require('sinon');
const S3UtilsMongoClient = require('../../utils/S3UtilsMongoClient');
const CountMaster = require('../../CountItems/CountMaster');
const CountManager = require('../../CountItems/CountManager');
Expand Down Expand Up @@ -34,67 +33,67 @@ const expectedCountItems = {
};
const expectedDataMetrics = {
[`account_${testAccountCanonicalId}`]: {
objectCount: { current: 90, deleteMarker: 0, nonCurrent: 60 },
usedCapacity: { current: 9000, nonCurrent: 6000 },
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n },
usedCapacity: { current: 9000n, nonCurrent: 6000n },
locations: {
'secondary-location-1': {
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 },
usedCapacity: { current: 3000, nonCurrent: 3000 },
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n },
usedCapacity: { current: 3000n, nonCurrent: 3000n },
},
'secondary-location-2': {
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 },
usedCapacity: { current: 3000, nonCurrent: 3000 },
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n },
usedCapacity: { current: 3000n, nonCurrent: 3000n },
},
'us-east-1': {
objectCount: { current: 90, deleteMarker: 0, nonCurrent: 60 },
usedCapacity: { current: 9000, nonCurrent: 6000 },
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n },
usedCapacity: { current: 9000n, nonCurrent: 6000n },
},
},
},
[`bucket_test-bucket-0_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 0 },
usedCapacity: { current: 1000, nonCurrent: 0 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
usedCapacity: { current: 1000n, nonCurrent: 0n },
},
[`bucket_test-bucket-1_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 0 },
usedCapacity: { current: 1000, nonCurrent: 0 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
usedCapacity: { current: 1000n, nonCurrent: 0n },
},
[`bucket_test-bucket-2_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 0 },
usedCapacity: { current: 1000, nonCurrent: 0 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
usedCapacity: { current: 1000n, nonCurrent: 0n },
},
[`bucket_test-bucket-3_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
usedCapacity: { current: 1000, nonCurrent: 1000 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
usedCapacity: { current: 1000n, nonCurrent: 1000n },
},
[`bucket_test-bucket-4_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
usedCapacity: { current: 1000, nonCurrent: 1000 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
usedCapacity: { current: 1000n, nonCurrent: 1000n },
},
[`bucket_test-bucket-5_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
usedCapacity: { current: 1000, nonCurrent: 1000 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
usedCapacity: { current: 1000n, nonCurrent: 1000n },
},
[`bucket_test-bucket-6_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
usedCapacity: { current: 1000, nonCurrent: 1000 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
usedCapacity: { current: 1000n, nonCurrent: 1000n },
},
[`bucket_test-bucket-7_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
usedCapacity: { current: 1000, nonCurrent: 1000 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
usedCapacity: { current: 1000n, nonCurrent: 1000n },
},
[`bucket_test-bucket-8_${testBucketCreationDate}`]: {
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
usedCapacity: { current: 1000, nonCurrent: 1000 },
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
usedCapacity: { current: 1000n, nonCurrent: 1000n },
},
'location_secondary-location-1': {
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 }, usedCapacity: { current: 3000, nonCurrent: 3000 },
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n }, usedCapacity: { current: 3000n, nonCurrent: 3000n },
},
'location_secondary-location-2': {
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 }, usedCapacity: { current: 3000, nonCurrent: 3000 },
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n }, usedCapacity: { current: 3000n, nonCurrent: 3000n },
},
'location_us-east-1': {
objectCount: { current: 90, deleteMarker: 0, nonCurrent: 60 }, usedCapacity: { current: 9000, nonCurrent: 6000 },
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n }, usedCapacity: { current: 9000n, nonCurrent: 6000n },
},
};

Expand Down
Loading

0 comments on commit da1658f

Please sign in to comment.