From 05da813985eb44494e8b691e8c429d5f26fcd823 Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 14 Nov 2024 12:10:34 +0100 Subject: [PATCH] fixup! fixup! Add test for archive object replacement --- tests/ctst/steps/utils/utils.ts | 39 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tests/ctst/steps/utils/utils.ts b/tests/ctst/steps/utils/utils.ts index 0e7e32361..5463ef977 100644 --- a/tests/ctst/steps/utils/utils.ts +++ b/tests/ctst/steps/utils/utils.ts @@ -199,32 +199,34 @@ async function createBucketWithConfiguration( } } -async function putMpuObject(world: Zenko, parts: number = 2, objectName?: string, content?: string) { +async function putMpuObject(world: Zenko, parts: number = 2, objectName: string = `${Utils.randomString()}`, content?: string) { + const bucketName = world.getSaved('bucketName'); world.resetCommand(); - let key = objectName; - if (!key) { - key = `${Utils.randomString()}`; - } - world.addToSaved('objectName', key); - world.logger.debug('Adding mpu object', { objectName: key }); - world.addCommandParameter({ key }); - world.addCommandParameter({ bucket: world.getSaved('bucketName') }); + world.addToSaved('objectName', objectName); + world.logger.debug('Adding mpu object', { objectName: objectName }); + world.addCommandParameter({ key: objectName }); + world.addCommandParameter({ bucket: bucketName }); const userMetadata = world.getSaved('userMetadata'); if (userMetadata) { world.addCommandParameter({ metadata: JSON.stringify(userMetadata) }); } const initiateMPUResult = await S3.createMultipartUpload(world.getCommandParameters()); assert.ifError(initiateMPUResult.stderr || initiateMPUResult.err); - world.addCommandParameter({ - uploadId: extractPropertyFromResults(initiateMPUResult, 'UploadId') - }); + const uploadId = extractPropertyFromResults(initiateMPUResult, 'UploadId'); await uploadSetup(world, 'UploadPart', content); - world.deleteKeyFromCommand('metadata'); + const body = world.getSaved('tempFileName'); const uploadedParts = []; for (let i = 0; i < parts; i++) { + world.resetCommand(); + world.addCommandParameter({ key: objectName }); + world.addCommandParameter({ bucket: bucketName }); world.addCommandParameter({ partNumber: i+1 }); + world.addCommandParameter({ uploadId: uploadId }); + if (body) { + world.addCommandParameter({ body: body }); + } world.logger.info('upload part', { part: i, cliParams: world.getCommandParameters() }); @@ -239,11 +241,14 @@ async function putMpuObject(world: Zenko, parts: number = 2, objectName?: string await uploadTeardown(world, 'UploadPart'); - world.deleteKeyFromCommand('partNumber'); + world.resetCommand(); + world.addCommandParameter({ key: objectName }); + world.addCommandParameter({ bucket: bucketName }); + world.addCommandParameter({ uploadId: uploadId }); world.addCommandParameter({ multipartUpload: JSON.stringify({ Parts: uploadedParts }) }); const result = await S3.completeMultipartUpload(world.getCommandParameters()); const versionId = extractPropertyFromResults(result, 'VersionId'); - world.saveCreatedObject(key, versionId || ''); + world.saveCreatedObject(objectName, versionId || ''); world.setResult(result); return result; } @@ -254,8 +259,8 @@ async function copyObject(world: Zenko, srcObjectName?: string, dstObjectName?: world.resetCommand(); world.addCommandParameter({ copySource: `${bucket}/${srcObjectName || world.getSaved('objectName')}`}); - world.addCommandParameter({ bucket }); - world.addCommandParameter({ key }); + world.addCommandParameter({ bucket: bucket }); + world.addCommandParameter({ key: key }); const userMetadata = world.getSaved('userMetadata'); if (userMetadata) {