Skip to content

Commit da1658f

Browse files
committed
Update tests
Issue: S3UTILS-188
1 parent 2de385c commit da1658f

File tree

8 files changed

+2293
-2250
lines changed

8 files changed

+2293
-2250
lines changed

tests/functional/collectBucketMetricsAndUpdateBucketCapacityInfo.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
5454
},
5555
},
5656
CapacityInfo: {
57-
Capacity: 0,
58-
Available: 0,
59-
Used: 0,
57+
Capacity: 0n,
58+
Available: 0n,
59+
Used: 0n,
6060
},
6161
},
6262
};
6363
client.updateStorageConsumptionMetrics({}, {
6464
bucket: {
6565
[`${testBucketName}_${testBucketCreationDate}`]: {
66-
usedCapacity: { current: 10, nonCurrent: 10 },
67-
objectCount: { current: 10, nonCurrent: 10 },
66+
usedCapacity: { current: 10n, nonCurrent: 10n },
67+
objectCount: { current: 10n, nonCurrent: 10n },
6868
},
6969
},
7070
}, logger, done);
@@ -94,8 +94,8 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
9494
next();
9595
}),
9696
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
97-
assert.equal(err, null);
98-
assert.equal(bucketInfo.getCapabilities(), null);
97+
assert.equal(err && err.message, 'InternalError');
98+
assert.equal(bucketInfo, undefined);
9999
next();
100100
}),
101101
], done);
@@ -126,16 +126,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
126126
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
127127
assert.equal(err, null);
128128
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
129-
assert.strictEqual(Capacity, 0);
130-
assert.strictEqual(Available, 0);
131-
assert.strictEqual(Used, 0);
129+
assert.strictEqual(Capacity, 0n);
130+
assert.strictEqual(Available, 0n);
131+
assert.strictEqual(Used, 0n);
132132
next();
133133
}),
134134
], done);
135135
});
136136

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

140140
return async.series([
141141
next => client.createBucket(testBucketName, {
@@ -160,16 +160,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
160160
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
161161
assert.equal(err, null);
162162
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
163-
assert.strictEqual(Capacity, 30);
164-
assert.strictEqual(Available, 10);
165-
assert.strictEqual(Used, 20);
163+
assert.strictEqual(Capacity, 30n);
164+
assert.strictEqual(Available, 10n);
165+
assert.strictEqual(Used, 20n);
166166
next();
167167
}),
168168
], done);
169169
});
170170

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

174174
return async.series([
175175
next => client.createBucket(testBucketName, {
@@ -194,16 +194,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
194194
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
195195
assert.equal(err, null);
196196
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
197-
assert.strictEqual(Capacity, -1);
198-
assert.strictEqual(Available, -1);
199-
assert.strictEqual(Used, 20);
197+
assert.strictEqual(Capacity, -1n);
198+
assert.strictEqual(Available, -1n);
199+
assert.strictEqual(Used, 20n);
200200
next();
201201
}),
202202
], done);
203203
});
204204

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

208208
return async.series([
209209
next => client.createBucket(testBucketName, {
@@ -228,16 +228,16 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
228228
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
229229
assert.equal(err, null);
230230
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
231-
assert.strictEqual(Capacity, 10);
232-
assert.strictEqual(Available, -1);
233-
assert.strictEqual(Used, 20);
231+
assert.strictEqual(Capacity, 10n);
232+
assert.strictEqual(Available, -1n);
233+
assert.strictEqual(Used, 20n);
234234
next();
235235
}),
236236
], done);
237237
});
238238

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

242242
return async.series([
243243
next => client.updateStorageConsumptionMetrics({}, { bucket: {} }, logger, next),
@@ -263,9 +263,9 @@ describe('collectBucketMetricsAndUpdateBucketCapacityInfo', () => {
263263
next => client.getBucketAttributes(testBucketName, logger, (err, bucketInfo) => {
264264
assert.equal(err, null);
265265
const { Capacity, Available, Used } = bucketInfo.getCapabilities().VeeamSOSApi.CapacityInfo;
266-
assert.strictEqual(Capacity, 30);
267-
assert.strictEqual(Available, -1);
268-
assert.strictEqual(Used, -1);
266+
assert.strictEqual(Capacity, 30n);
267+
assert.strictEqual(Available, -1n);
268+
assert.strictEqual(Used, -1n);
269269
next();
270270
}),
271271
], done);

tests/functional/countItems.js

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const async = require('async');
33
const werelogs = require('werelogs');
44
const { BucketInfo, ObjectMD } = require('arsenal').models;
55
const { constants } = require('arsenal');
6-
const sinon = require('sinon');
76
const S3UtilsMongoClient = require('../../utils/S3UtilsMongoClient');
87
const CountMaster = require('../../CountItems/CountMaster');
98
const CountManager = require('../../CountItems/CountManager');
@@ -34,67 +33,67 @@ const expectedCountItems = {
3433
};
3534
const expectedDataMetrics = {
3635
[`account_${testAccountCanonicalId}`]: {
37-
objectCount: { current: 90, deleteMarker: 0, nonCurrent: 60 },
38-
usedCapacity: { current: 9000, nonCurrent: 6000 },
36+
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n },
37+
usedCapacity: { current: 9000n, nonCurrent: 6000n },
3938
locations: {
4039
'secondary-location-1': {
41-
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 },
42-
usedCapacity: { current: 3000, nonCurrent: 3000 },
40+
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n },
41+
usedCapacity: { current: 3000n, nonCurrent: 3000n },
4342
},
4443
'secondary-location-2': {
45-
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 },
46-
usedCapacity: { current: 3000, nonCurrent: 3000 },
44+
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n },
45+
usedCapacity: { current: 3000n, nonCurrent: 3000n },
4746
},
4847
'us-east-1': {
49-
objectCount: { current: 90, deleteMarker: 0, nonCurrent: 60 },
50-
usedCapacity: { current: 9000, nonCurrent: 6000 },
48+
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n },
49+
usedCapacity: { current: 9000n, nonCurrent: 6000n },
5150
},
5251
},
5352
},
5453
[`bucket_test-bucket-0_${testBucketCreationDate}`]: {
55-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 0 },
56-
usedCapacity: { current: 1000, nonCurrent: 0 },
54+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
55+
usedCapacity: { current: 1000n, nonCurrent: 0n },
5756
},
5857
[`bucket_test-bucket-1_${testBucketCreationDate}`]: {
59-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 0 },
60-
usedCapacity: { current: 1000, nonCurrent: 0 },
58+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
59+
usedCapacity: { current: 1000n, nonCurrent: 0n },
6160
},
6261
[`bucket_test-bucket-2_${testBucketCreationDate}`]: {
63-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 0 },
64-
usedCapacity: { current: 1000, nonCurrent: 0 },
62+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 0n },
63+
usedCapacity: { current: 1000n, nonCurrent: 0n },
6564
},
6665
[`bucket_test-bucket-3_${testBucketCreationDate}`]: {
67-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
68-
usedCapacity: { current: 1000, nonCurrent: 1000 },
66+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
67+
usedCapacity: { current: 1000n, nonCurrent: 1000n },
6968
},
7069
[`bucket_test-bucket-4_${testBucketCreationDate}`]: {
71-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
72-
usedCapacity: { current: 1000, nonCurrent: 1000 },
70+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
71+
usedCapacity: { current: 1000n, nonCurrent: 1000n },
7372
},
7473
[`bucket_test-bucket-5_${testBucketCreationDate}`]: {
75-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
76-
usedCapacity: { current: 1000, nonCurrent: 1000 },
74+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
75+
usedCapacity: { current: 1000n, nonCurrent: 1000n },
7776
},
7877
[`bucket_test-bucket-6_${testBucketCreationDate}`]: {
79-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
80-
usedCapacity: { current: 1000, nonCurrent: 1000 },
78+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
79+
usedCapacity: { current: 1000n, nonCurrent: 1000n },
8180
},
8281
[`bucket_test-bucket-7_${testBucketCreationDate}`]: {
83-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
84-
usedCapacity: { current: 1000, nonCurrent: 1000 },
82+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
83+
usedCapacity: { current: 1000n, nonCurrent: 1000n },
8584
},
8685
[`bucket_test-bucket-8_${testBucketCreationDate}`]: {
87-
objectCount: { current: 10, deleteMarker: 0, nonCurrent: 10 },
88-
usedCapacity: { current: 1000, nonCurrent: 1000 },
86+
objectCount: { current: 10n, deleteMarker: 0n, nonCurrent: 10n },
87+
usedCapacity: { current: 1000n, nonCurrent: 1000n },
8988
},
9089
'location_secondary-location-1': {
91-
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 }, usedCapacity: { current: 3000, nonCurrent: 3000 },
90+
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n }, usedCapacity: { current: 3000n, nonCurrent: 3000n },
9291
},
9392
'location_secondary-location-2': {
94-
objectCount: { current: 30, deleteMarker: 0, nonCurrent: 30 }, usedCapacity: { current: 3000, nonCurrent: 3000 },
93+
objectCount: { current: 30n, deleteMarker: 0n, nonCurrent: 30n }, usedCapacity: { current: 3000n, nonCurrent: 3000n },
9594
},
9695
'location_us-east-1': {
97-
objectCount: { current: 90, deleteMarker: 0, nonCurrent: 60 }, usedCapacity: { current: 9000, nonCurrent: 6000 },
96+
objectCount: { current: 90n, deleteMarker: 0n, nonCurrent: 60n }, usedCapacity: { current: 9000n, nonCurrent: 6000n },
9897
},
9998
};
10099

0 commit comments

Comments
 (0)