Skip to content

Commit d354dcc

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

File tree

4 files changed

+45
-32
lines changed

4 files changed

+45
-32
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 "never happen" within 30 seconds
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 "succeed" within 300 seconds
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 "fail" within 500 seconds
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 "succeed" within 300 seconds
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: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,16 @@ 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 {string} within {int} seconds', { timeout: 600_000 },
93+
async function (
94+
this: Zenko,
95+
expectedOutcome: 'succeed' | 'fail' | 'never happen',
96+
replicationTimeout: number
97+
) {
9498
const objectName = this.getSaved<string>('objectName');
9599
const bucketSource = this.getSaved<string>('bucketName');
96100
const startTime = Date.now();
97-
const replicationTimeoutMs = 300_000;
98-
while (Date.now() - startTime < replicationTimeoutMs) {
101+
while (Date.now() - startTime < replicationTimeout * 1000) {
99102
await new Promise(resolve => setTimeout(resolve, 3000));
100103

101104
const response = await headObject(this, objectName, bucketSource);
@@ -112,26 +115,33 @@ 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') {
116-
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`);
117-
if (replicationStatus === 'COMPLETED') {
118-
return;
119-
}
120-
} else if (replicate === 'fail to be') {
121-
assert.notStrictEqual(
122-
replicationStatus,
123-
'COMPLETED',
124-
`expected replication to fail for object ${objectName}`
125-
);
126-
if (replicationStatus === 'FAILED') {
127-
return;
128-
}
129-
}
130-
if (replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING') {
118+
switch (replicationStatus) {
119+
case 'PENDING':
120+
case 'PROCESSING':
121+
assert.notStrictEqual(expectedOutcome, 'never happen',
122+
`replication status is ${replicationStatus}, but expected to never happen`);
131123
continue;
124+
case 'COMPLETED':
125+
assert.strictEqual(expectedOutcome, 'succeed',
126+
`replication is completed, but expected outcome was '${expectedOutcome}'`);
127+
return;
128+
case 'FAILED':
129+
assert.strictEqual(expectedOutcome, 'fail',
130+
`replication is failed, but expected outcome was '${expectedOutcome}'`);
131+
return;
132+
case undefined:
133+
// For 'succeed'/'fail', the object may not have been switched to pending status yet
134+
// For 'never happen', the status should remain undefined
135+
continue;
136+
default:
137+
throw new Error(`Unexpected replication status: ${replicationStatus}`);
132138
}
133139
}
134-
assert.fail(`Timeout: Object '${objectName}' is still pending/processing after timeout`);
140+
if (expectedOutcome === 'never happen') {
141+
// Success: status remained undefined throughout the timeout period
142+
return;
143+
}
144+
assert.fail(`Timeout: Object '${objectName}' is still in pending/processing state after timeout`);
135145
});
136146

137147
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)