Skip to content

Commit 68c859a

Browse files
committed
listParts related tests migration
Issue: CLDSRV-724
1 parent e58839d commit 68c859a

File tree

2 files changed

+49
-36
lines changed

2 files changed

+49
-36
lines changed

tests/functional/aws-node-sdk/test/multipleBackend/listParts/azureListParts.js

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
const assert = require('assert');
2+
const { CreateBucketCommand,
3+
CreateMultipartUploadCommand,
4+
UploadPartCommand,
5+
AbortMultipartUploadCommand,
6+
ListPartsCommand } = require('@aws-sdk/client-s3');
27

38
const withV4 = require('../../support/withV4');
49
const BucketUtility = require('../../../lib/utility/bucket-util');
@@ -21,37 +26,37 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on Azure data backend',
2126
this.currentTest.key = `somekey-${genUniqID()}`;
2227
bucketUtil = new BucketUtility('default', sigCfg);
2328
s3 = bucketUtil.s3;
24-
return s3.createBucket({ Bucket: azureContainerName }).promise()
25-
.then(() => s3.createMultipartUpload({
29+
return s3.send(new CreateBucketCommand({ Bucket: azureContainerName }))
30+
.then(() => s3.send(new CreateMultipartUploadCommand({
2631
Bucket: azureContainerName, Key: this.currentTest.key,
2732
Metadata: { 'scal-location-constraint': azureLocation },
28-
}).promise())
33+
}))
2934
.then(res => {
3035
this.currentTest.uploadId = res.UploadId;
31-
return s3.uploadPart({ Bucket: azureContainerName,
36+
return s3.send(new UploadPartCommand({ Bucket: azureContainerName,
3237
Key: this.currentTest.key, PartNumber: 1,
3338
UploadId: this.currentTest.uploadId, Body: bodyFirstPart,
34-
}).promise();
39+
}));
3540
}).then(res => {
3641
this.currentTest.firstEtag = res.ETag;
37-
}).then(() => s3.uploadPart({ Bucket: azureContainerName,
42+
}).then(() => s3.send(new UploadPartCommand({ Bucket: azureContainerName,
3843
Key: this.currentTest.key, PartNumber: 2,
3944
UploadId: this.currentTest.uploadId, Body: bodySecondPart,
40-
}).promise()).then(res => {
45+
}))).then(res => {
4146
this.currentTest.secondEtag = res.ETag;
4247
})
4348
.catch(err => {
4449
process.stdout.write(`Error in beforeEach: ${err}\n`);
4550
throw err;
46-
});
51+
}));
4752
});
4853

4954
afterEach(function afterEachFn() {
5055
process.stdout.write('Emptying bucket');
51-
return s3.abortMultipartUpload({
56+
return s3.send(new AbortMultipartUploadCommand({
5257
Bucket: azureContainerName, Key: this.currentTest.key,
5358
UploadId: this.currentTest.uploadId,
54-
}).promise()
59+
}))
5560
.then(() => bucketUtil.empty(azureContainerName))
5661
.then(() => {
5762
process.stdout.write('Deleting bucket');
@@ -64,12 +69,10 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on Azure data backend',
6469
});
6570

6671
it('should list both parts', function itFn(done) {
67-
s3.listParts({
72+
s3.send(new ListPartsCommand({
6873
Bucket: azureContainerName,
6974
Key: this.test.key,
70-
UploadId: this.test.uploadId },
71-
(err, data) => {
72-
assert.equal(err, null, `Err listing parts: ${err}`);
75+
UploadId: this.test.uploadId })).then(data => {
7376
assert.strictEqual(data.Parts.length, 2);
7477
assert.strictEqual(data.Parts[0].PartNumber, 1);
7578
assert.strictEqual(data.Parts[0].Size, firstPartSize);
@@ -78,21 +81,25 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on Azure data backend',
7881
assert.strictEqual(data.Parts[1].Size, secondPartSize);
7982
assert.strictEqual(data.Parts[1].ETag, this.test.secondEtag);
8083
done();
84+
}).catch(err => {
85+
assert.equal(err, null, `Err listing parts: ${err}`);
86+
done(err);
8187
});
8288
});
8389

8490
it('should only list the second part', function itFn(done) {
85-
s3.listParts({
91+
s3.send(new ListPartsCommand({
8692
Bucket: azureContainerName,
8793
Key: this.test.key,
8894
PartNumberMarker: 1,
89-
UploadId: this.test.uploadId },
90-
(err, data) => {
91-
assert.equal(err, null, `Err listing parts: ${err}`);
95+
UploadId: this.test.uploadId })).then(data => {
9296
assert.strictEqual(data.Parts[0].PartNumber, 2);
9397
assert.strictEqual(data.Parts[0].Size, secondPartSize);
9498
assert.strictEqual(data.Parts[0].ETag, this.test.secondEtag);
9599
done();
100+
}).catch(err => {
101+
assert.equal(err, null, `Err listing parts: ${err}`);
102+
done(err);
96103
});
97104
});
98105
});

tests/functional/aws-node-sdk/test/multipleBackend/listParts/listPartsGcp.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const assert = require('assert');
2-
2+
const { CreateBucketCommand,
3+
CreateMultipartUploadCommand,
4+
UploadPartCommand,
5+
AbortMultipartUploadCommand,
6+
ListPartsCommand } = require('@aws-sdk/client-s3');
37
const withV4 = require('../../support/withV4');
48
const BucketUtility = require('../../../lib/utility/bucket-util');
59
const { describeSkipIfNotMultipleOrCeph, gcpLocation, genUniqID }
@@ -20,23 +24,23 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
2024
this.currentTest.key = `somekey-${genUniqID()}`;
2125
bucketUtil = new BucketUtility('default', sigCfg);
2226
s3 = bucketUtil.s3;
23-
return s3.createBucket({ Bucket: bucket }).promise()
24-
.then(() => s3.createMultipartUpload({
27+
return s3.send(new CreateBucketCommand({ Bucket: bucket }))
28+
.then(() => s3.send(new CreateMultipartUploadCommand({
2529
Bucket: bucket, Key: this.currentTest.key,
2630
Metadata: { 'scal-location-constraint': gcpLocation },
27-
}).promise())
31+
})))
2832
.then(res => {
2933
this.currentTest.uploadId = res.UploadId;
30-
return s3.uploadPart({ Bucket: bucket,
34+
return s3.send(new UploadPartCommand({ Bucket: bucket,
3135
Key: this.currentTest.key, PartNumber: 1,
3236
UploadId: this.currentTest.uploadId, Body: bodyFirstPart,
33-
}).promise();
37+
}));
3438
}).then(res => {
3539
this.currentTest.firstEtag = res.ETag;
36-
}).then(() => s3.uploadPart({ Bucket: bucket,
40+
}).then(() => s3.send(new UploadPartCommand({ Bucket: bucket,
3741
Key: this.currentTest.key, PartNumber: 2,
3842
UploadId: this.currentTest.uploadId, Body: bodySecondPart,
39-
}).promise())
43+
})))
4044
.then(res => {
4145
this.currentTest.secondEtag = res.ETag;
4246
})
@@ -48,10 +52,10 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
4852

4953
afterEach(function afterEachFn() {
5054
process.stdout.write('Emptying bucket');
51-
return s3.abortMultipartUpload({
55+
return s3.send(new AbortMultipartUploadCommand({
5256
Bucket: bucket, Key: this.currentTest.key,
5357
UploadId: this.currentTest.uploadId,
54-
}).promise()
58+
}))
5559
.then(() => bucketUtil.empty(bucket))
5660
.then(() => {
5761
process.stdout.write('Deleting bucket');
@@ -64,12 +68,10 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
6468
});
6569

6670
it('should list both parts', function itFn(done) {
67-
s3.listParts({
71+
s3.send(new ListPartsCommand({
6872
Bucket: bucket,
6973
Key: this.test.key,
70-
UploadId: this.test.uploadId },
71-
(err, data) => {
72-
assert.equal(err, null, `Err listing parts: ${err}`);
74+
UploadId: this.test.uploadId })).then(data => {
7375
assert.strictEqual(data.Parts.length, 2);
7476
assert.strictEqual(data.Parts[0].PartNumber, 1);
7577
assert.strictEqual(data.Parts[0].Size, firstPartSize);
@@ -78,21 +80,25 @@ describeSkipIfNotMultipleOrCeph('List parts of MPU on GCP data backend', () => {
7880
assert.strictEqual(data.Parts[1].Size, secondPartSize);
7981
assert.strictEqual(data.Parts[1].ETag, this.test.secondEtag);
8082
done();
83+
}).catch(err => {
84+
assert.equal(err, null, `Err listing parts: ${err}`);
85+
done(err);
8186
});
8287
});
8388

8489
it('should only list the second part', function itFn(done) {
85-
s3.listParts({
90+
s3.send(new ListPartsCommand({
8691
Bucket: bucket,
8792
Key: this.test.key,
8893
PartNumberMarker: 1,
89-
UploadId: this.test.uploadId },
90-
(err, data) => {
91-
assert.equal(err, null, `Err listing parts: ${err}`);
94+
UploadId: this.test.uploadId })).then(data => {
9295
assert.strictEqual(data.Parts[0].PartNumber, 2);
9396
assert.strictEqual(data.Parts[0].Size, secondPartSize);
9497
assert.strictEqual(data.Parts[0].ETag, this.test.secondEtag);
9598
done();
99+
}).catch(err => {
100+
assert.equal(err, null, `Err listing parts: ${err}`);
101+
done(err);
96102
});
97103
});
98104
});

0 commit comments

Comments
 (0)