UNPKG

@aws-cdk-testing/cli-integ

Version:

Integration tests for the AWS CDK CLI

52 lines (43 loc) 1.69 kB
import { ListObjectsV2Command } from '@aws-sdk/client-s3'; import { integTest, withoutBootstrap, randomString } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime integTest( 'Garbage Collection deletes unused s3 objects', withoutBootstrap(async (fixture) => { const toolkitStackName = fixture.bootstrapStackName; const bootstrapBucketName = `aws-cdk-garbage-collect-integ-test-bckt-${randomString()}`; fixture.rememberToDeleteBucket(bootstrapBucketName); // just in case await fixture.cdkBootstrapModern({ toolkitStackName, bootstrapBucketName, }); await fixture.cdkDeploy('lambda', { options: [ '--context', `bootstrapBucket=${bootstrapBucketName}`, '--context', `@aws-cdk/core:bootstrapQualifier=${fixture.qualifier}`, '--toolkit-stack-name', toolkitStackName, '--force', ], }); fixture.log('Setup complete!'); await fixture.cdkDestroy('lambda', { options: [ '--context', `bootstrapBucket=${bootstrapBucketName}`, '--context', `@aws-cdk/core:bootstrapQualifier=${fixture.qualifier}`, '--toolkit-stack-name', toolkitStackName, '--force', ], }); await fixture.cdkGarbageCollect({ rollbackBufferDays: 0, type: 's3', bootstrapStackName: toolkitStackName, }); fixture.log('Garbage collection complete!'); // assert that the bootstrap bucket is empty await fixture.aws.s3.send(new ListObjectsV2Command({ Bucket: bootstrapBucketName })) .then((result) => { expect(result.Contents).toBeUndefined(); }); }), );