Skip to content

Commit 7805158

Browse files
added test for replication that should not happen
Issue : ZENKO-5057
1 parent 033fd88 commit 7805158

File tree

4 files changed

+43
-19
lines changed

4 files changed

+43
-19
lines changed

tests/ctst/features/crrReplicationS3utils.feature

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,24 @@ Feature: Replication
22
This feature tests replication using the script crrExistingObjects.js from S3utils,
33
that replicates objects created before the replication was enabled on source the bucket.
44

5+
@2.12.0
6+
@PreMerge
7+
@ReplicationTest
8+
Scenario Outline: Objects created before setting up replication should not be replicated automatically
9+
Given an existing bucket "source-bucket-0" "with" versioning, "without" ObjectLock "without" retention mode
10+
And an object "source-object-1" that "exists"
11+
And a replication configuration to "awsbackendmismatch" location
12+
Then the object replication should eventually "never happen"
13+
514
@2.12.0
615
@PreMerge
716
@ReplicationTest
817
Scenario Outline: Replicate objects created before creating the replication rule
9-
Given an existing bucket "source-bucket" "with" versioning, "without" ObjectLock "without" retention mode
18+
Given an existing bucket "source-bucket-1" "with" versioning, "without" ObjectLock "without" retention mode
1019
And an object "source-object-1" that "exists"
1120
And a replication configuration to "awsbackendmismatch" location
1221
When the job to replicate existing objects with status "NEW" is executed
13-
Then the object should eventually "be" replicated
22+
Then the object replication should eventually "succeed"
1423
And the replicated object should be the same as the source object
1524

1625
@2.12.0
@@ -22,8 +31,8 @@ Feature: Replication
2231
And a replication configuration to "awsbackendreplicationctstfail" location
2332
And a deleted destination bucket on that location
2433
And an object "source-object-2" that "exists"
25-
Then the object should eventually "fail to be" replicated
34+
Then the object replication should eventually "fail"
2635
When the destination bucket on the location is created again
2736
And the job to replicate existing objects with status "FAILED" is executed
28-
Then the object should eventually "be" replicated
37+
Then the object replication should eventually "succeed"
2938
And the replicated object should be the same as the source object

tests/ctst/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
"prometheus-query": "^3.4.0",
1919
"proper-lockfile": "^4.1.2",
2020
"qs": "^6.13.0",
21-
"scubaclient": "git+https://github.com/scality/scubaclient#^1.1.2",
22-
"uuid": "^11.1.0"
21+
"scubaclient": "git+https://github.com/scality/scubaclient#^1.1.2"
2322
},
2423
"devDependencies": {
2524
"@aws-sdk/client-iam": "^3.582.0",

tests/ctst/steps/replication.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ When('the job to replicate existing objects with status {string} is executed',
8989
await createAndRunPod(this, podManifest);
9090
});
9191

92-
Then('the object should eventually {string} replicated', { timeout: 360_000 },
93-
async function (this: Zenko, replicate: 'be' | 'fail to be') {
92+
Then('the object replication should eventually {string}', { timeout: 360_000 },
93+
async function (
94+
this: Zenko,
95+
expectedOutcome: 'succeed' | 'fail' | 'never happen'
96+
) {
9497
const objectName = this.getSaved<string>('objectName');
9598
const bucketSource = this.getSaved<string>('bucketName');
9699
const startTime = Date.now();
@@ -112,12 +115,22 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
112115
assert(parsed.ok);
113116
const replicationStatus = parsed.result?.ReplicationStatus;
114117

115-
if (replicate === 'be') {
118+
if ((expectedOutcome === 'succeed' || expectedOutcome === 'fail') &&
119+
(replicationStatus === 'PENDING' ||
120+
replicationStatus === 'PROCESSING' ||
121+
replicationStatus === undefined // If replication hasn't started, status is still undefined
122+
)) {
123+
continue;
124+
}
125+
126+
switch (expectedOutcome) {
127+
case 'succeed':
116128
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`);
117129
if (replicationStatus === 'COMPLETED') {
118130
return;
119131
}
120-
} else if (replicate === 'fail to be') {
132+
break;
133+
case 'fail':
121134
assert.notStrictEqual(
122135
replicationStatus,
123136
'COMPLETED',
@@ -126,12 +139,20 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
126139
if (replicationStatus === 'FAILED') {
127140
return;
128141
}
142+
break;
143+
case 'never happen':
144+
// When the replication is not expected to happen, replicationStatus is never set
145+
assert.strictEqual(
146+
replicationStatus, undefined,
147+
'expected object to have no ReplicationStatus (should remain undefined)'
148+
);
149+
break;
129150
}
130-
if (replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING') {
131-
continue;
132-
}
133151
}
134-
assert.fail(`Timeout: Object '${objectName}' is still pending/processing after timeout`);
152+
if (expectedOutcome === 'never happen') {
153+
return;
154+
}
155+
assert.fail(`Timeout: Object '${objectName}' is still in pending/processing state after timeout`);
135156
});
136157

137158
Then(

tests/ctst/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4664,11 +4664,6 @@ uuid@9.0.1, uuid@^9.0.1:
46644664
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
46654665
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
46664666

4667-
uuid@^11.1.0:
4668-
version "11.1.0"
4669-
resolved "https://registry.yarnpkg.com/uuid/-/uuid-11.1.0.tgz#9549028be1753bb934fc96e2bca09bb4105ae912"
4670-
integrity sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==
4671-
46724667
uuid@^3.3.2:
46734668
version "3.4.0"
46744669
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"

0 commit comments

Comments
 (0)