Skip to content

Commit 6dffcd4

Browse files
added test for replication that should not happen
1 parent 033fd88 commit 6dffcd4

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
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/steps/replication.ts

Lines changed: 26 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,19 @@ 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' || replicationStatus === 'PROCESSING')) {
120+
continue;
121+
}
122+
123+
switch (expectedOutcome) {
124+
case 'succeed':
116125
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`);
117126
if (replicationStatus === 'COMPLETED') {
118127
return;
119128
}
120-
} else if (replicate === 'fail to be') {
129+
break;
130+
case 'fail':
121131
assert.notStrictEqual(
122132
replicationStatus,
123133
'COMPLETED',
@@ -126,12 +136,20 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
126136
if (replicationStatus === 'FAILED') {
127137
return;
128138
}
139+
break;
140+
case 'never happen':
141+
// When the replication is not expected to happen, replicationStatus is never set
142+
assert.strictEqual(
143+
replicationStatus, undefined,
144+
'expected object to have no ReplicationStatus (should remain undefined)'
145+
);
146+
break;
129147
}
130-
if (replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING') {
131-
continue;
132-
}
133148
}
134-
assert.fail(`Timeout: Object '${objectName}' is still pending/processing after timeout`);
149+
if (expectedOutcome === 'never happen') {
150+
return;
151+
}
152+
assert.fail(`Timeout: Object '${objectName}' is still in pending/processing state after timeout`);
135153
});
136154

137155
Then(

0 commit comments

Comments
 (0)