Skip to content

Commit befab62

Browse files
CLDSRV-717: Tests backbeat route isolate buckets
Add a suffix to isolate buckets With versions if one test fails and bucket can't be cleaned, it will make other tests fails
1 parent 0cbe863 commit befab62

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

tests/multipleBackend/routes/routeBackbeat.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ const backbeatAuthCredentials = {
3737
accessKey: accessKeyId,
3838
secretKey: secretAccessKey,
3939
};
40-
const TEST_BUCKET = 'backbeatbucket';
41-
const TEST_ENCRYPTED_BUCKET = 'backbeatbucket-encrypted';
40+
const TEST_BUCKET_PREFIX = 'backbeatbucket';
41+
const TEST_ENCRYPTED_BUCKET_PREFIX = 'backbeatbucket-encrypted';
4242
const TEST_KEY = 'fookey';
43-
const NONVERSIONED_BUCKET = 'backbeatbucket-non-versioned';
44-
const VERSION_SUSPENDED_BUCKET = 'backbeatbucket-version-suspended';
45-
const BUCKET_FOR_NULL_VERSION = 'backbeatbucket-null-version';
43+
const NONVERSIONED_BUCKET_PREFIX = 'backbeatbucket-non-versioned';
44+
const VERSION_SUSPENDED_BUCKET_PREFIX = 'backbeatbucket-version-suspended';
45+
const BUCKET_FOR_NULL_VERSION_PREFIX = 'backbeatbucket-null-version';
4646

4747
const testArn = 'aws::iam:123456789012:user/bart';
4848
const testKey = 'testkey';
@@ -226,6 +226,12 @@ function getMetadataToPut(putDataResponse) {
226226
describe('backbeat routes', () => {
227227
let bucketUtil;
228228
let s3;
229+
const suffix = uuidv4();
230+
// These buckets are created once before tests
231+
const TEST_BUCKET = `${TEST_BUCKET_PREFIX}-${suffix}`;
232+
const TEST_ENCRYPTED_BUCKET = `${TEST_ENCRYPTED_BUCKET_PREFIX}-${suffix}`;
233+
const NONVERSIONED_BUCKET = `${NONVERSIONED_BUCKET_PREFIX}-${suffix}`;
234+
const VERSION_SUSPENDED_BUCKET = `${VERSION_SUSPENDED_BUCKET_PREFIX}-${suffix}`;
229235

230236
before(done => {
231237
bucketUtil = new BucketUtility(
@@ -288,7 +294,7 @@ describe('backbeat routes', () => {
288294
);
289295

290296
describe('null version', () => {
291-
const bucket = BUCKET_FOR_NULL_VERSION;
297+
let bucket;
292298
const keyName = 'key0';
293299
const storageClass = 'foo';
294300

@@ -306,14 +312,15 @@ describe('backbeat routes', () => {
306312
assert.strictEqual(StorageClass, 'STANDARD');
307313
}
308314

309-
beforeEach(() =>
310-
bucketUtil.emptyIfExists(BUCKET_FOR_NULL_VERSION)
311-
.then(() => s3.createBucket({ Bucket: BUCKET_FOR_NULL_VERSION }).promise())
312-
);
315+
beforeEach(() => {
316+
bucket = `${BUCKET_FOR_NULL_VERSION_PREFIX}-${uuidv4()}`;
317+
return bucketUtil.emptyIfExists(bucket)
318+
.then(() => s3.createBucket({ Bucket: bucket }).promise());
319+
});
313320

314321
afterEach(() =>
315-
bucketUtil.empty(BUCKET_FOR_NULL_VERSION)
316-
.then(() => s3.deleteBucket({ Bucket: BUCKET_FOR_NULL_VERSION }).promise())
322+
bucketUtil.empty(bucket)
323+
.then(() => s3.deleteBucket({ Bucket: bucket }).promise())
317324
);
318325

319326
it('should update metadata of a current null version', done => {

0 commit comments

Comments
 (0)