diff options
author | Benety Goh <benety@mongodb.com> | 2021-02-13 07:51:36 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-02-13 13:24:01 +0000 |
commit | 4dd10ec20b608ec364db1ba4815bbf45d73e8da4 (patch) | |
tree | 28ec6528a7a50c530d0ce0e4f5d345c5bbd25ec4 /jstests/core | |
parent | 64293926f7e54c01635d3ffc1416629abe23f17b (diff) | |
download | mongo-4dd10ec20b608ec364db1ba4815bbf45d73e8da4.tar.gz |
SERVER-54469 ensure unique collection names in time-series tests (collMod expireAfterSeconds)
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/timeseries/timeseries_expire_collmod.js | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/jstests/core/timeseries/timeseries_expire_collmod.js b/jstests/core/timeseries/timeseries_expire_collmod.js index 86ad72f8c08..0147c5159bd 100644 --- a/jstests/core/timeseries/timeseries_expire_collmod.js +++ b/jstests/core/timeseries/timeseries_expire_collmod.js @@ -18,72 +18,71 @@ if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) { return; } -const testDB = db.getSiblingDB("timeseries_expire_collmod"); -assert.commandWorked(testDB.dropDatabase()); - -const coll = testDB.getCollection('t'); +const coll = db.timeseries_expire_collmod; coll.drop(); const timeFieldName = 'time'; const expireAfterSeconds = NumberLong(5); -assert.commandWorked(testDB.createCollection( +assert.commandWorked(db.createCollection( coll.getName(), {timeseries: {timeField: timeFieldName, expireAfterSeconds: expireAfterSeconds}})); -const bucketsColl = testDB.getCollection('system.buckets.' + coll.getName()); +const bucketsColl = db.getCollection('system.buckets.' + coll.getName()); // Cannot use the 'clusteredIndex' option on collections that aren't time-series bucket collections. -assert.commandWorked(testDB.createCollection("other")); +const collNotClustered = db.getCollection(coll.getName() + '_not_clustered'); +collNotClustered.drop(); +assert.commandWorked(db.createCollection(collNotClustered.getName())); assert.commandFailedWithCode( - testDB.runCommand({collMod: "other", clusteredIndex: {expireAfterSeconds: 10}}), + db.runCommand({collMod: collNotClustered.getName(), clusteredIndex: {expireAfterSeconds: 10}}), ErrorCodes.InvalidOptions); // Check for invalid input. assert.commandFailedWithCode( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: "10"}}), + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: "10"}}), ErrorCodes.InvalidOptions); assert.commandFailedWithCode( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: {}}}), + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: {}}}), ErrorCodes.TypeMismatch); assert.commandFailedWithCode( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: -10}}), + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: -10}}), ErrorCodes.InvalidOptions); -assert.commandFailedWithCode( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {}}), 40414); +assert.commandFailedWithCode(db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {}}), + 40414); let res = assert.commandWorked( - testDB.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); + db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); assert.eq(expireAfterSeconds, res.cursor.firstBatch[0].options.clusteredIndex.expireAfterSeconds); // Change expireAfterSeconds to 10. assert.commandWorked( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: 10}})); + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: 10}})); res = assert.commandWorked( - testDB.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); + db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); assert.eq(10, res.cursor.firstBatch[0].options.clusteredIndex.expireAfterSeconds); // Change expireAfterSeconds to 0. assert.commandWorked( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: 0}})); + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: 0}})); res = assert.commandWorked( - testDB.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); + db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); assert.eq(0, res.cursor.firstBatch[0].options.clusteredIndex.expireAfterSeconds); // Disable expireAfterSeconds. -assert.commandWorked(testDB.runCommand( - {collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: "off"}})); +assert.commandWorked( + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: "off"}})); res = assert.commandWorked( - testDB.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); + db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); assert(!res.cursor.firstBatch[0].options.clusteredIndex.hasOwnProperty("expireAfterSeconds")); // Enable expireAfterSeconds again. assert.commandWorked( - testDB.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: 100}})); + db.runCommand({collMod: bucketsColl.getName(), clusteredIndex: {expireAfterSeconds: 100}})); res = assert.commandWorked( - testDB.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); + db.runCommand({listCollections: 1, filter: {name: bucketsColl.getName()}})); assert.eq(100, res.cursor.firstBatch[0].options.clusteredIndex.expireAfterSeconds); })(); |