Skip to content

Commit 61490ab

Browse files
added test for replication that should not happen
1 parent aa1135e commit 61490ab

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 we run the job to replicate existing objects with status "NEW"
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
@@ -21,8 +30,8 @@ Feature: Replication
2130
And a replication configuration to "awsbackendreplicationctstfail" location
2231
And a deleted destination bucket on that location
2332
And an object "source-object-2" that "exists"
24-
Then the object should eventually "fail to be" replicated
33+
Then the object replication should eventually "fail"
2534
When the destination bucket on the location is created again
2635
And we run the job to replicate existing objects with status "FAILED"
27-
Then the object should eventually "be" replicated
36+
Then the object replication should eventually "succeed"
2837
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
@@ -88,8 +88,11 @@ When('we run the job to replicate existing objects with status {string}',
8888
await createAndRunPod(this, podManifest);
8989
});
9090

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

114-
if (replicate === 'be') {
117+
if ((expectedOutcome === 'succeed' || expectedOutcome === 'fail') &&
118+
(replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING')) {
119+
continue;
120+
}
121+
122+
switch (expectedOutcome) {
123+
case 'succeed':
115124
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`);
116125
if (replicationStatus === 'COMPLETED') {
117126
return;
118127
}
119-
} else if (replicate === 'fail to be') {
128+
break;
129+
case 'fail':
120130
assert.notStrictEqual(
121131
replicationStatus,
122132
'COMPLETED',
@@ -125,12 +135,20 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
125135
if (replicationStatus === 'FAILED') {
126136
return;
127137
}
138+
break;
139+
case 'never happen':
140+
// When the replication is not expected to happen, replicationStatus is never set
141+
assert.strictEqual(
142+
replicationStatus, undefined,
143+
'expected object to have no ReplicationStatus (should remain undefined)'
144+
);
145+
break;
128146
}
129-
if (replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING') {
130-
continue;
131-
}
132147
}
133-
assert.fail(`Timeout: Object '${objectName}' is still pending/processing after timeout`);
148+
if (expectedOutcome === 'never happen') {
149+
return;
150+
}
151+
assert.fail(`Timeout: Object '${objectName}' is still in pending/processing state after timeout`);
134152
});
135153

136154
Then(

0 commit comments

Comments
 (0)