summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2021-02-07 14:06:20 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-07 19:50:58 +0000
commita642fd5193e5a18fb476eb684e1f2bf19bfed36e (patch)
treedcaf1b64d710d2b54100372e3da2b7ab13d9d0ad
parent4b88a9534a31fc78c5a3a388999e1f8469a1786f (diff)
downloadmongo-a642fd5193e5a18fb476eb684e1f2bf19bfed36e.tar.gz
SERVER-54217 ensure unique collection names in time-series tests (clustered indexes/out of order timestamps)
-rw-r--r--jstests/core/timeseries/timeseries_id_index.js10
-rw-r--r--jstests/core/timeseries/timeseries_out_of_order.js10
-rw-r--r--jstests/core/timeseries/timeseries_resume_after.js19
-rw-r--r--jstests/core/timeseries/timeseries_show_record_id.js10
4 files changed, 18 insertions, 31 deletions
diff --git a/jstests/core/timeseries/timeseries_id_index.js b/jstests/core/timeseries/timeseries_id_index.js
index 1123e8d8b91..0ccc9eb9124 100644
--- a/jstests/core/timeseries/timeseries_id_index.js
+++ b/jstests/core/timeseries/timeseries_id_index.js
@@ -20,17 +20,13 @@ if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
return;
}
-const testDB = db.getSiblingDB(jsTestName());
-assert.commandWorked(testDB.dropDatabase());
-
-const coll = testDB.getCollection("a");
+const coll = db.timeseries_id_index;
coll.drop();
const timeFieldName = "time";
-assert.commandWorked(
- testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
+assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
-const bucketsColl = testDB.getCollection("system.buckets." + coll.getName());
+const bucketsColl = db.getCollection("system.buckets." + coll.getName());
const res = bucketsColl.createIndex({"_id": 1});
assert.commandFailedWithCode(res, ErrorCodes.CannotCreateIndex);
diff --git a/jstests/core/timeseries/timeseries_out_of_order.js b/jstests/core/timeseries/timeseries_out_of_order.js
index ef89104b289..0e1a758cfad 100644
--- a/jstests/core/timeseries/timeseries_out_of_order.js
+++ b/jstests/core/timeseries/timeseries_out_of_order.js
@@ -22,7 +22,7 @@ if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
return;
}
-const testDB = db.getSiblingDB(jsTestName());
+const collNamePrefix = 'timeseries_out_of_order_';
const timeFieldName = 'time';
const times = [
@@ -34,13 +34,13 @@ let docs = [{_id: 0, [timeFieldName]: times[1]}, {_id: 1, [timeFieldName]: times
let collCount = 0;
const runTest = function(bucketsFn) {
- const coll = testDB.getCollection('t_' + collCount++);
- const bucketsColl = testDB.getCollection('system.buckets.' + coll.getName());
+ const coll = db.getCollection(collNamePrefix + collCount++);
+ const bucketsColl = db.getCollection('system.buckets.' + coll.getName());
coll.drop();
assert.commandWorked(
- testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
- assert.contains(bucketsColl.getName(), testDB.getCollectionNames());
+ db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
+ assert.contains(bucketsColl.getName(), db.getCollectionNames());
assert.commandWorked(coll.insert(docs, {ordered: false}));
assert.docEq(coll.find().sort({_id: 1}).toArray(), docs);
diff --git a/jstests/core/timeseries/timeseries_resume_after.js b/jstests/core/timeseries/timeseries_resume_after.js
index 323e4add78d..011d8414711 100644
--- a/jstests/core/timeseries/timeseries_resume_after.js
+++ b/jstests/core/timeseries/timeseries_resume_after.js
@@ -22,18 +22,14 @@ if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
return;
}
-const testDB = db.getSiblingDB(jsTestName());
-assert.commandWorked(testDB.dropDatabase());
-
const timeFieldName = "time";
-const coll = testDB.getCollection("a");
+const coll = db.timeseries_resume_after;
coll.drop();
-assert.commandWorked(
- testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
+assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
-const bucketsColl = testDB.getCollection("system.buckets." + coll.getName());
+const bucketsColl = db.getCollection("system.buckets." + coll.getName());
Random.setRandomSeed();
@@ -55,7 +51,7 @@ for (let i = 0; i < 100; i++) {
// Run the initial query and request to return a resume token. We're interested only in a single
// document, so 'batchSize' is set to 1.
-let res = assert.commandWorked(testDB.runCommand(
+let res = assert.commandWorked(db.runCommand(
{find: bucketsColl.getName(), hint: {$natural: 1}, batchSize: 1, $_requestResumeToken: true}));
// Make sure the query returned a resume token which will be used to resume the query from.
@@ -66,11 +62,10 @@ jsTestLog("Got resume token " + tojson(resumeToken));
assert.neq(null, resumeToken.$recordId);
// Kill the cursor before attempting to resume.
-assert.commandWorked(
- testDB.runCommand({killCursors: bucketsColl.getName(), cursors: [res.cursor.id]}));
+assert.commandWorked(db.runCommand({killCursors: bucketsColl.getName(), cursors: [res.cursor.id]}));
// Try to resume the query from the saved resume token.
-res = assert.commandWorked(testDB.runCommand({
+res = assert.commandWorked(db.runCommand({
find: bucketsColl.getName(),
hint: {$natural: 1},
batchSize: 1,
@@ -85,7 +80,7 @@ jsTestLog("Got resume token " + tojson(resumeToken));
assert.eq(null, resumeToken.$recordId);
// Try to resume from a null '$recordId'.
-res = assert.commandWorked(testDB.runCommand({
+res = assert.commandWorked(db.runCommand({
find: bucketsColl.getName(),
hint: {$natural: 1},
batchSize: 1,
diff --git a/jstests/core/timeseries/timeseries_show_record_id.js b/jstests/core/timeseries/timeseries_show_record_id.js
index 4ac62ad1ccc..81a84d8dd22 100644
--- a/jstests/core/timeseries/timeseries_show_record_id.js
+++ b/jstests/core/timeseries/timeseries_show_record_id.js
@@ -20,16 +20,12 @@ if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
return;
}
-const testDB = db.getSiblingDB(jsTestName());
-assert.commandWorked(testDB.dropDatabase());
-
const timeFieldName = "time";
-const coll = testDB.getCollection("a");
+const coll = db.timeseries_show_record_id;
coll.drop();
-assert.commandWorked(
- testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
+assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
Random.setRandomSeed();
@@ -62,6 +58,6 @@ const error = assert.throws(() => {
});
assert.commandFailedWithCode(error, ErrorCodes.InvalidPipelineOperator);
-const bucketsColl = testDB.getCollection("system.buckets." + coll.getName());
+const bucketsColl = db.getCollection("system.buckets." + coll.getName());
checkRecordId(bucketsColl.find().showRecordId().toArray());
})();