Skip to content

Commit 984f086

Browse files
committed
Improve code from review
Issue: S3UTILS-188
1 parent 84a25e2 commit 984f086

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

CountItems/utils/utils.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ function consolidateDataMetrics(target, source) {
8282
return resTarget;
8383
}
8484

85-
8685
function serializeBigInts(obj) {
8786
if (typeof obj !== 'object' || obj === null) {
8887
return typeof obj === 'bigint' ? { __bigint: obj.toString() } : obj;

tests/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ module.exports = {
2424
_lifecycleConfiguration: null,
2525
_uid: '',
2626
_isNFS: null,
27+
_capabilities: {
28+
VeeamSOSApi: undefined,
29+
},
2730
ingestion: null,
2831
},
2932
testAccountCanonicalId: 'd1d40abd2bd8250962f7f5774af1bbbeaec9b77a0853749d41ec46f142e66fe4',

tests/functional/collectBucketMetricsAndUpdateBucketCapacityInfo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
9494
next();
9595
}),
9696
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
97-
assert.equal(err && err.message, 'InternalError');
98-
assert.equal(bucketInfo, undefined);
97+
assert.equal(err, null);
98+
assert.strictEqual(bucketInfo.getCapabilities().VeeamSOSApi, undefined);
9999
next();
100100
}),
101101
], done);

tests/functional/utils/S3UtilsMongoClient.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ describe('S3UtilsMongoClient::getObjectMDStats', () => {
16131613
});
16141614
});
16151615

1616-
describe.skip('S3UtilsMongoClient::updateBucketCapacityInfo', () => {
1616+
describe('S3UtilsMongoClient::updateBucketCapacityInfo', () => {
16171617
let client;
16181618
let repl;
16191619

@@ -1676,7 +1676,7 @@ describe.skip('S3UtilsMongoClient::updateBucketCapacityInfo', () => {
16761676
});
16771677
});
16781678

1679-
describe.skip('S3UtilsMongoClient::getBucketInfos', () => {
1679+
describe('S3UtilsMongoClient::getBucketInfos', () => {
16801680
let client;
16811681
let repl;
16821682

@@ -1731,9 +1731,15 @@ describe.skip('S3UtilsMongoClient::getBucketInfos', () => {
17311731
it('Should get correct bucket infos', done => client.getBucketInfos(logger, (err, data) => {
17321732
assert.equal(err, null);
17331733
assert.strictEqual(data.bucketCount, 3);
1734-
assert.strictEqual(JSON.stringify(data.bucketInfos.find(bucket => bucket._name === buckets[0]._name)), JSON.stringify(buckets[0]));
1735-
assert.strictEqual(JSON.stringify(data.bucketInfos.find(bucket => bucket._name === buckets[1]._name)), JSON.stringify(buckets[1]));
1736-
assert.strictEqual(JSON.stringify(data.bucketInfos.find(bucket => bucket._name === buckets[2]._name)), JSON.stringify(buckets[2]));
1734+
assert.strictEqual(
1735+
data.bucketInfos.find(bucket => bucket._name === buckets[0]._name).serialize(),
1736+
BucketInfo.fromObj(buckets[0]).serialize());
1737+
assert.strictEqual(
1738+
data.bucketInfos.find(bucket => bucket._name === buckets[1]._name).serialize(),
1739+
BucketInfo.fromObj(buckets[1]).serialize());
1740+
assert.strictEqual(
1741+
data.bucketInfos.find(bucket => bucket._name === buckets[2]._name).serialize(),
1742+
BucketInfo.fromObj(buckets[2]).serialize());
17371743
done();
17381744
}));
17391745

@@ -1758,9 +1764,9 @@ describe.skip('S3UtilsMongoClient::getBucketInfos', () => {
17581764

17591765
// Perform the assertions
17601766
assert.strictEqual(data.bucketCount, 2);
1761-
assert.strictEqual(JSON.stringify(data.bucketInfos.find(bucket => bucket._name === buckets[0]._name)), undefined);
1762-
assert.strictEqual(JSON.stringify(data.bucketInfos.find(bucket => bucket._name === buckets[1]._name)), JSON.stringify(buckets[1]));
1763-
assert.strictEqual(JSON.stringify(data.bucketInfos.find(bucket => bucket._name === buckets[2]._name)), JSON.stringify(buckets[2]));
1767+
assert.strictEqual(data.bucketInfos.find(bucket => bucket._name === buckets[0]._name), undefined);
1768+
assert.strictEqual(!!data.bucketInfos.find(bucket => bucket._name === buckets[1]._name), true);
1769+
assert.strictEqual(!!data.bucketInfos.find(bucket => bucket._name === buckets[2]._name), true);
17641770
});
17651771
});
17661772
});

utils/S3UtilsMongoClient.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const INFOSTORE_TMP = `${INFOSTORE}_tmp`;
1414
const __COUNT_ITEMS = 'countitems';
1515

1616
const BigIntMax = (...args) => args.reduce((max, current) => {
17-
const maxAsBigInt = typeof max === 'bigint' ? max : BigInt(max);
18-
const currentAsBigInt = typeof current === 'bigint' ? current : BigInt(current);
17+
const maxAsBigInt = BigInt(max);
18+
const currentAsBigInt = BigInt(current);
1919
return maxAsBigInt > currentAsBigInt ? max : current;
2020
});
2121

@@ -114,7 +114,7 @@ class S3UtilsMongoClient extends MongoClientInterface {
114114
const id = entry._id;
115115
if (id.startsWith('bucket_')) {
116116
const inflightDocument = inflightsMap[id];
117-
const inflight = inflightDocument ? BigIntMax(0, inflightDocument - entry.usedCapacity._inflightsPreScan) : 0n;
117+
const inflight = inflightDocument ? BigIntMax(0n, inflightDocument - entry.usedCapacity._inflightsPreScan) : 0n;
118118
if (inflight) {
119119
// Inflights remaining after the scan are part of the "current" bytes,
120120
// and stored in _inflightsDelta

0 commit comments

Comments
 (0)