summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Chan <jason.chan@mongodb.com>2021-06-08 19:31:53 +0000
committerJason Chan <jason.chan@mongodb.com>2021-06-28 14:21:19 +0000
commitbf7c6c8d96ae29fcadaff3615fce5f85a5551624 (patch)
tree7effd118a68198be138034f69bec3e16464f65fb
parent6281048759c0e52ad0dac35bcd121effd9f127c3 (diff)
downloadmongo-bf7c6c8d96ae29fcadaff3615fce5f85a5551624.tar.gz
SERVER-57539 Move timeseries_create_drop.js to noPassthrough
(cherry picked from commit 8d28b15f140e4d255e7aae1d5d0209a3117e08fd)
-rw-r--r--jstests/core/timeseries/timeseries_create_drop.js104
-rw-r--r--jstests/noPassthrough/timeseries_create_drop.js112
2 files changed, 112 insertions, 104 deletions
diff --git a/jstests/core/timeseries/timeseries_create_drop.js b/jstests/core/timeseries/timeseries_create_drop.js
deleted file mode 100644
index 50f78c446fd..00000000000
--- a/jstests/core/timeseries/timeseries_create_drop.js
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Tests creating and dropping timeseries bucket collections and view definitions. Tests that we can
- * recover in both create and drop if a partial create occured where we have a bucket collection but
- * no view definition.
- * @tags: [
- * assumes_no_implicit_collection_creation_after_drop,
- * does_not_support_stepdowns,
- * does_not_support_transactions,
- * requires_fcv_49,
- * ]
- */
-(function() {
-"use strict";
-
-load("jstests/core/timeseries/libs/timeseries.js");
-
-if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
- jsTestLog("Skipping test because the time-series collection feature flag is disabled");
- return;
-}
-
-const coll = db.timeseries_create_drop;
-const viewName = coll.getName();
-const viewNs = coll.getFullName();
-
-// Disable test if fail point is missing (running in multiversion suite)
-const failpoint = 'failTimeseriesViewCreation';
-if (db.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn", data: {ns: viewNs}}).ok ===
- 0) {
- jsTestLog("Skipping test because the " + failpoint + " fail point is missing");
- return;
-}
-assert.commandWorked(db.adminCommand({configureFailPoint: failpoint, mode: "off"}));
-
-const bucketsColl = db.getCollection('system.buckets.' + coll.getName());
-const bucketsCollName = bucketsColl.getName();
-const timeFieldName = 'time';
-const expireAfterSecondsNum = 60;
-
-coll.drop();
-
-// Create should create both bucket collection and view
-assert.commandWorked(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
-assert.contains(viewName, db.getCollectionNames());
-assert.contains(bucketsCollName, db.getCollectionNames());
-
-// Drop should drop both bucket collection and view
-assert(coll.drop());
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.eq(db.getCollectionNames().findIndex(c => c == bucketsCollName), -1);
-
-// Enable failpoint to allow bucket collection to be created but fail creation of view definition
-assert.commandWorked(
- db.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn", data: {ns: viewNs}}));
-assert.commandFailed(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.contains(bucketsCollName, db.getCollectionNames());
-
-// Dropping a partially created timeseries where only the bucket collection exists is allowed and
-// should clean up the bucket collection
-assert(coll.drop());
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.eq(db.getCollectionNames().findIndex(c => c == bucketsCollName), -1);
-
-// Trying to create again yields the same result as fail point is still enabled
-assert.commandFailed(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.contains(bucketsCollName, db.getCollectionNames());
-
-// Turn off fail point and test creating view definition with existing bucket collection
-assert.commandWorked(db.adminCommand({configureFailPoint: failpoint, mode: "off"}));
-
-// Different timeField should fail
-assert.commandFailed(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName + "2"}, expireAfterSeconds: expireAfterSecondsNum}));
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.contains(bucketsCollName, db.getCollectionNames());
-
-// Different expireAfterSeconds should fail
-assert.commandFailed(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum + 1}));
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.contains(bucketsCollName, db.getCollectionNames());
-
-// Omitting expireAfterSeconds should fail
-assert.commandFailed(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
-assert.eq(db.getCollectionNames().findIndex(c => c == viewName), -1);
-assert.contains(bucketsCollName, db.getCollectionNames());
-
-// Same parameters should succeed
-assert.commandWorked(db.createCollection(
- coll.getName(),
- {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
-assert.contains(viewName, db.getCollectionNames());
-assert.contains(bucketsCollName, db.getCollectionNames());
-})();
diff --git a/jstests/noPassthrough/timeseries_create_drop.js b/jstests/noPassthrough/timeseries_create_drop.js
new file mode 100644
index 00000000000..ea7d5321e45
--- /dev/null
+++ b/jstests/noPassthrough/timeseries_create_drop.js
@@ -0,0 +1,112 @@
+/**
+ * Tests creating and dropping timeseries bucket collections and view definitions. Tests that we can
+ * recover in both create and drop if a partial create occured where we have a bucket collection but
+ * no view definition.
+ * @tags: [
+ * assumes_no_implicit_collection_creation_after_drop,
+ * does_not_support_stepdowns,
+ * does_not_support_transactions,
+ * requires_fcv_49,
+ * ]
+ */
+(function() {
+"use strict";
+
+load("jstests/core/timeseries/libs/timeseries.js");
+
+const rst = new ReplSetTest({nodes: 2});
+rst.startSet();
+rst.initiateWithHighElectionTimeout();
+const primary = rst.getPrimary();
+const primaryDb = primary.getDB('test');
+if (!TimeseriesTest.timeseriesCollectionsEnabled(primaryDb.getMongo())) {
+ jsTestLog("Skipping test because the time-series collection feature flag is disabled");
+ return;
+}
+
+const coll = primaryDb.timeseries_create_drop;
+const viewName = coll.getName();
+const viewNs = coll.getFullName();
+
+// Disable test if fail point is missing (running in multiversion suite)
+const failpoint = 'failTimeseriesViewCreation';
+if (primaryDb.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn", data: {ns: viewNs}})
+ .ok === 0) {
+ jsTestLog("Skipping test because the " + failpoint + " fail point is missing");
+ return;
+}
+assert.commandWorked(primaryDb.adminCommand({configureFailPoint: failpoint, mode: "off"}));
+
+const bucketsColl = primaryDb.getCollection('system.buckets.' + coll.getName());
+const bucketsCollName = bucketsColl.getName();
+const timeFieldName = 'time';
+const expireAfterSecondsNum = 60;
+
+coll.drop();
+
+// Create should create both bucket collection and view
+assert.commandWorked(primaryDb.createCollection(
+ coll.getName(),
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
+assert.contains(viewName, primaryDb.getCollectionNames());
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+// Drop should drop both bucket collection and view
+assert(coll.drop());
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == bucketsCollName), -1);
+
+// Enable failpoint to allow bucket collection to be created but fail creation of view definition
+assert.commandWorked(
+ primaryDb.adminCommand({configureFailPoint: failpoint, mode: "alwaysOn", data: {ns: viewNs}}));
+assert.commandFailed(primaryDb.createCollection(
+ coll.getName(),
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+// Dropping a partially created timeseries where only the bucket collection exists is allowed and
+// should clean up the bucket collection
+assert(coll.drop());
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == bucketsCollName), -1);
+
+// Trying to create again yields the same result as fail point is still enabled
+assert.commandFailed(primaryDb.createCollection(
+ coll.getName(),
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+// Turn off fail point and test creating view definition with existing bucket collection
+assert.commandWorked(primaryDb.adminCommand({configureFailPoint: failpoint, mode: "off"}));
+
+// Different timeField should fail
+assert.commandFailed(primaryDb.createCollection(
+ coll.getName(),
+ {timeseries: {timeField: timeFieldName + "2"}, expireAfterSeconds: expireAfterSecondsNum}));
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+// Different expireAfterSeconds should fail
+assert.commandFailed(primaryDb.createCollection(
+ coll.getName(),
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum + 1}));
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+// Omitting expireAfterSeconds should fail
+assert.commandFailed(
+ primaryDb.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
+assert.eq(primaryDb.getCollectionNames().findIndex(c => c == viewName), -1);
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+// Same parameters should succeed
+assert.commandWorked(primaryDb.createCollection(
+ coll.getName(),
+ {timeseries: {timeField: timeFieldName}, expireAfterSeconds: expireAfterSecondsNum}));
+assert.contains(viewName, primaryDb.getCollectionNames());
+assert.contains(bucketsCollName, primaryDb.getCollectionNames());
+
+rst.stopSet();
+})();