Skip to content

Commit 2a53c38

Browse files
committed
Update mongodb-memory-server createBucket regression tests
Expect BucketAlreadyExists on concurrent metastore races while keeping the pre-existing collection regression when createCollection is idempotent. Issue: ARSN-613
1 parent f2f61cf commit 2a53c38

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

tests/unit/storage/metadata/mongoclient/MongoClientInterface.spec.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ describe('MongoClientInterface, tests', () => {
644644
});
645645

646646
it('should create a bucket whose backing collection already exists', done => {
647-
const bucketName = 'test-bucket-collection-exists';
647+
const bucketName = `test-bucket-collection-exists-${Date.now()}`;
648648
async.waterfall(
649649
[
650650
next => {
@@ -666,13 +666,22 @@ describe('MongoClientInterface, tests', () => {
666666
);
667667
});
668668

669-
it('should succeed on concurrent createBucket calls for the same bucket', done => {
669+
it('should return BucketAlreadyExists on concurrent createBucket calls', done => {
670670
const bucketName = 'test-bucket-concurrent-create';
671+
const results = [];
671672
async.times(
672673
5,
673-
(n, next) => createBucket(client, bucketName, false, next),
674+
(n, next) =>
675+
createBucket(client, bucketName, false, err => {
676+
results.push(err);
677+
next();
678+
}),
674679
err => {
675680
assert.ifError(err);
681+
const successes = results.filter(e => !e).length;
682+
const alreadyExists = results.filter(e => e?.is?.BucketAlreadyExists).length;
683+
assert.strictEqual(successes, 1);
684+
assert.strictEqual(alreadyExists, 4);
676685
client.deleteBucket(bucketName, logger, done);
677686
},
678687
);

0 commit comments

Comments
 (0)