Skip to content

Commit 3e923f5

Browse files
committed
add crr tests
Issue: ZENKO-5069
1 parent 14f8b46 commit 3e923f5

File tree

3 files changed

+524
-2
lines changed

3 files changed

+524
-2
lines changed

tests/zenko_tests/node_tests/backbeat/ReplicationUtility.js

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,12 @@ class ReplicationUtility {
521521
}, cb);
522522
}
523523

524+
deleteBucketReplication(bucketName, cb) {
525+
this.s3.deleteBucketReplication({
526+
Bucket: bucketName,
527+
}, cb);
528+
}
529+
524530
getHeadObject(bucketName, key, cb) {
525531
this.s3.headObject({
526532
Bucket: bucketName,
@@ -752,6 +758,40 @@ class ReplicationUtility {
752758
});
753759
}
754760

761+
compareObjectsCRR(srcBucket, destClient, destBucket, key, userMetadataField, cb) {
762+
return async.series([
763+
next => this.waitUntilReplicated(srcBucket, key, undefined, next),
764+
next => this.getObject(srcBucket, key, next),
765+
next => destClient.getObject(destBucket, key, next),
766+
], (err, data) => {
767+
if (err) {
768+
return cb(err);
769+
}
770+
const srcData = data[1];
771+
const destData = data[2];
772+
assert.strictEqual(srcData.ReplicationStatus, 'COMPLETED');
773+
assert.strictEqual(destData.ReplicationStatus, 'REPLICA');
774+
assert.strictEqual(
775+
srcData.ContentLength,
776+
destData.ContentLength,
777+
);
778+
this._compareObjectBody(srcData.Body, destData.Body);
779+
const srcUserMD = srcData.Metadata;
780+
assert.strictEqual(
781+
srcData.VersionId,
782+
destData.VersionId,
783+
);
784+
if (userMetadataField) {
785+
const destUserMD = destData.Metadata;
786+
assert.strictEqual(
787+
srcUserMD[userMetadataField],
788+
destUserMD[userMetadataField],
789+
);
790+
}
791+
return cb();
792+
});
793+
}
794+
755795
compareObjectsOneToMany(
756796
srcBucket,
757797
awsDestBucket,
@@ -968,6 +1008,23 @@ class ReplicationUtility {
9681008
});
9691009
}
9701010

1011+
compareACLsCRR(srcBucket, destClient, destBucket, key, cb) {
1012+
return async.series([
1013+
next => this.waitUntilReplicated(srcBucket, key, undefined, next),
1014+
next => this.getObjectACL(srcBucket, key, next),
1015+
next => destClient.getObjectACL(destBucket, key, next),
1016+
], (err, data) => {
1017+
if (err) {
1018+
return cb(err);
1019+
}
1020+
assert.strictEqual(
1021+
data[1].Grants[0].Permission,
1022+
data[2].Grants[0].Permission,
1023+
);
1024+
return cb();
1025+
});
1026+
}
1027+
9711028
compareObjectTagsAWS(
9721029
srcBucket,
9731030
destBucket,
@@ -1004,6 +1061,43 @@ class ReplicationUtility {
10041061
});
10051062
}
10061063

1064+
compareObjectTagCRR(
1065+
srcBucket,
1066+
destClient,
1067+
destBucket,
1068+
key,
1069+
cb,
1070+
) {
1071+
return async.series([
1072+
next => this.waitUntilReplicated(
1073+
srcBucket,
1074+
key,
1075+
undefined,
1076+
next,
1077+
),
1078+
next => this.getObjectTagging(
1079+
srcBucket,
1080+
key,
1081+
undefined,
1082+
next,
1083+
),
1084+
next => destClient.getObjectTagging(
1085+
destBucket,
1086+
key,
1087+
null,
1088+
next,
1089+
),
1090+
], (err, data) => {
1091+
if (err) {
1092+
return cb(err);
1093+
}
1094+
const srcData = data[1];
1095+
const destData = data[2];
1096+
assert.deepStrictEqual(srcData.TagSet, destData.TagSet);
1097+
return cb();
1098+
});
1099+
}
1100+
10071101
compareObjectTagsAzure(
10081102
srcBucket,
10091103
destContainer,
@@ -1095,6 +1189,19 @@ class ReplicationUtility {
10951189
return cb();
10961190
});
10971191
}
1192+
1193+
assertVersionCount(bucketName, expectedCount, cb) {
1194+
this.s3.listObjectVersions({
1195+
Bucket: bucketName,
1196+
}, (err, data) => {
1197+
if (err) {
1198+
return cb(err);
1199+
}
1200+
const totalCount = data.Versions.length + data.DeleteMarkers.length;
1201+
assert.strictEqual(totalCount, expectedCount);
1202+
return cb();
1203+
});
1204+
}
10981205
}
10991206

11001207
module.exports = ReplicationUtility;

0 commit comments

Comments
 (0)