Skip to content

Commit ef87fa5

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

File tree

4 files changed

+45
-16
lines changed

4 files changed

+45
-16
lines changed

.github/scripts/end2end/run-e2e-ctst.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,4 @@ kubectl run $POD_NAME \
203203
}
204204
]
205205
}
206-
}' -- ./run "$COMMAND" $WORLD_PARAMETERS --parallel $PARALLEL_RUNS --retry $RETRIES --retry-tag-filter @Flaky --format junit:$JUNIT_REPORT_PATH "$@"
206+
}' -- ./run "$COMMAND" $WORLD_PARAMETERS --parallel $PARALLEL_RUNS --retry $RETRIES --retry-tag-filter @Flaky --format junit:$JUNIT_REPORT_PATH "$@" --tags '@ReplicationTest'

.github/workflows/end2end.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,9 @@ jobs:
398398
- name: Install ctst test dependencies
399399
working-directory: tests/ctst
400400
run: yarn install
401-
- name: Lint ctst tests
402-
working-directory: tests/ctst
403-
run: yarn lint
401+
# - name: Lint ctst tests
402+
# working-directory: tests/ctst
403+
# run: yarn lint
404404
- name: Set up Docker Buildx
405405
uses: docker/setup-buildx-action@v3
406406
- name: Login to Registry

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: 28 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();
@@ -110,13 +113,25 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
110113
}>(response.stdout || '{}');
111114
assert(parsed.ok);
112115
const replicationStatus = parsed.result?.ReplicationStatus;
116+
console.log(`testing 0 ${expectedOutcome} - Response stdout:`, response.stdout);
117+
console.log(`testing 1 ${expectedOutcome} - Full response:`, JSON.stringify(response, null, 2));
118+
console.log(`testing 2 ${expectedOutcome} - Parsed result:`, JSON.stringify(parsed, null, 2));
119+
console.log(`testing 3 ${expectedOutcome} - Parsed result:`, JSON.stringify(parsed.result, null, 2));
120+
console.log(`testing 4 ${expectedOutcome} - Replication status: ${replicationStatus}`);
113121

114-
if (replicate === 'be') {
122+
if ((expectedOutcome === 'succeed' || expectedOutcome === 'fail') &&
123+
(replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING')) {
124+
continue;
125+
}
126+
127+
switch (expectedOutcome) {
128+
case 'succeed':
115129
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`);
116130
if (replicationStatus === 'COMPLETED') {
117131
return;
118132
}
119-
} else if (replicate === 'fail to be') {
133+
break;
134+
case 'fail':
120135
assert.notStrictEqual(
121136
replicationStatus,
122137
'COMPLETED',
@@ -125,12 +140,17 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
125140
if (replicationStatus === 'FAILED') {
126141
return;
127142
}
143+
break;
144+
case 'never happen':
145+
// When the replication is not expected to happen, replicationStatus is never set
146+
assert.strictEqual(replicationStatus, undefined, 'expected object to have no ReplicationStatus (should remain undefined)');
147+
break;
128148
}
129-
if (replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING') {
130-
continue;
131-
}
132149
}
133-
assert.fail(`Timeout: Object '${objectName}' is still pending/processing after timeout`);
150+
if (expectedOutcome === 'never happen') {
151+
return;
152+
}
153+
assert.fail(`Timeout: Object '${objectName}' is still in pending/processing state after timeout`);
134154
});
135155

136156
Then(

0 commit comments

Comments
 (0)