-
Notifications
You must be signed in to change notification settings - Fork 89
zenko 5050 : Test replication of objects with replicationStatus=failed #2249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: bug/ZENKO-5030
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
import { When, Then } from '@cucumber/cucumber'; | ||
import { Given, When, Then } from '@cucumber/cucumber'; | ||
import Zenko from '../world/Zenko'; | ||
import { createAndRunPod, getMongoDBConfig, getZenkoVersion } from 'steps/utils/kubernetes'; | ||
import assert from 'assert'; | ||
import { GetObjectCommand } from '@aws-sdk/client-s3'; | ||
import { | ||
GetObjectCommand, | ||
DeleteBucketCommand, | ||
CreateBucketCommand, | ||
PutBucketVersioningCommand | ||
} from '@aws-sdk/client-s3'; | ||
import { v4 as uuidv4 } from 'uuid'; | ||
import { getObject, headObject, getReplicationLocationConfig } from 'steps/utils/utils'; | ||
import { safeJsonParse } from 'common/utils'; | ||
import { replicationLockTags } from 'common/hooks'; | ||
|
||
When('I run the job to replicate existing objects with status {string}', | ||
When('the job to replicate existing objects with status {string} is executed', | ||
{ timeout: 600000 }, | ||
async function ( | ||
this: Zenko, | ||
|
@@ -83,12 +89,12 @@ When('I run the job to replicate existing objects with status {string}', | |
await createAndRunPod(this, podManifest); | ||
}); | ||
|
||
Then('the object should eventually be replicated', | ||
async function (this: Zenko) { | ||
Then('the object should eventually {string} replicated', { timeout: 360_000 }, | ||
async function (this: Zenko, replicate: 'be' | 'fail to be') { | ||
const objectName = this.getSaved<string>('objectName'); | ||
const bucketSource = this.getSaved<string>('bucketName'); | ||
const startTime = Date.now(); | ||
const replicationTimeoutMs = 90_000; | ||
const replicationTimeoutMs = 300_000; | ||
while (Date.now() - startTime < replicationTimeoutMs) { | ||
await new Promise(resolve => setTimeout(resolve, 3000)); | ||
|
||
|
@@ -105,15 +111,27 @@ Then('the object should eventually be replicated', | |
}>(response.stdout || '{}'); | ||
assert(parsed.ok); | ||
const replicationStatus = parsed.result?.ReplicationStatus; | ||
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`); | ||
if (replicationStatus === 'COMPLETED') { | ||
return; | ||
|
||
if (replicate === 'be') { | ||
assert.notStrictEqual(replicationStatus, 'FAILED', `replication failed for object ${objectName}`); | ||
if (replicationStatus === 'COMPLETED') { | ||
return; | ||
} | ||
} else if (replicate === 'fail to be') { | ||
assert.notStrictEqual( | ||
replicationStatus, | ||
'COMPLETED', | ||
`expected replication to fail for object ${objectName}` | ||
); | ||
if (replicationStatus === 'FAILED') { | ||
return; | ||
} | ||
} | ||
if (replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING') { | ||
continue; | ||
} | ||
} | ||
assert.fail(`Timeout: Object '${objectName}' was not replicated successfully until timeout`); | ||
assert.fail(`Timeout: Object '${objectName}' is still pending/processing after timeout`); | ||
}); | ||
|
||
Then( | ||
|
@@ -173,3 +191,41 @@ Then( | |
'REPLICA' | ||
); | ||
}); | ||
|
||
Given('a deleted destination bucket on that location', async function (this: Zenko) { | ||
const replicationLocation = this.getSaved<string>('replicationLocation'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this approach will not "scale" well if multiple tests are using that location : since we will not be able to run multiple tests targeting it in parallel... (and which is why you created a new, dedicated location) I don't really see an easy alternative option (except introducing "faults" in the system, either via code changes or network tinkering), and probably acceptable at the moment; but I think we should explicitly "document" this limitation and try to prepare for the case where this is reused to avoid introducing flakiness then
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. investigating all 3 remarks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I added a tag which enforce non parallel run of tests using this tag. This tag is then read in the "delete bucket" step. If the tag is absent, the test returns an error. |
||
const scenarioTags = this.getSaved<string[]>('scenarioTags') || []; | ||
const lockTag = `@Lock${replicationLocation}`; | ||
const hasTestLock = scenarioTags.includes(lockTag); | ||
assert.strictEqual( | ||
hasTestLock, true, | ||
'This step can only be run when the tag @Lock$replicationLocation is configured' | ||
); | ||
assert.strictEqual( | ||
true, replicationLockTags.includes(lockTag), | ||
`The tag ${lockTag} must be added to the replicationLockTags array in common/hooks.ts` | ||
); | ||
|
||
const { destinationBucket, awsS3Client } = | ||
await getReplicationLocationConfig(this, replicationLocation); | ||
const command = new DeleteBucketCommand({ | ||
Bucket: destinationBucket, | ||
}); | ||
await awsS3Client.send(command); | ||
}); | ||
|
||
When('the destination bucket on the location is created again', async function (this: Zenko) { | ||
const { destinationBucket, awsS3Client } = | ||
await getReplicationLocationConfig(this, this.getSaved<string>('replicationLocation')); | ||
const command = new CreateBucketCommand({ | ||
Bucket: destinationBucket, | ||
}); | ||
await awsS3Client.send(command); | ||
const versioningCommand = new PutBucketVersioningCommand({ | ||
Bucket: destinationBucket, | ||
VersioningConfiguration: { | ||
Status: 'Enabled', | ||
}, | ||
}); | ||
await awsS3Client.send(versioningCommand); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: alternatively, we could make this a bit more generic by specifying the replication status in the test?
where string can be COMPLETED or FAILED (or PENDING, but this could create flakoness)
It avoids the "mapping", not sure if it is more useful or it makes the tests more easier to read...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will reconsider this one with the next pr which adds another test, because this new test will introduce a third new status variable