summaryrefslogtreecommitdiff
path: root/jstests/concurrency
diff options
context:
space:
mode:
authorNikita Lapkov <nikita.lapkov@mongodb.com>2021-09-08 13:53:21 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-20 15:12:19 +0000
commit8e08ad9655b7bac2a6705c1aaf2f7feaa997fd69 (patch)
tree7020e5f8808c639a5da62253da1095f2e867cfeb /jstests/concurrency
parentdc7f0f2f730fdb114657242190fac7a9cfc33fb2 (diff)
downloadmongo-8e08ad9655b7bac2a6705c1aaf2f7feaa997fd69.tar.gz
SERVER-59126 Delete buckets collection metadata from config servers on time-series collection drop
Diffstat (limited to 'jstests/concurrency')
-rw-r--r--jstests/concurrency/fsm_workloads/drop_sharded_timeseries_collection.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/jstests/concurrency/fsm_workloads/drop_sharded_timeseries_collection.js b/jstests/concurrency/fsm_workloads/drop_sharded_timeseries_collection.js
new file mode 100644
index 00000000000..7a411309b74
--- /dev/null
+++ b/jstests/concurrency/fsm_workloads/drop_sharded_timeseries_collection.js
@@ -0,0 +1,93 @@
+/**
+ * Repeatedly creates and drops a sharded time-series collection.
+ *
+ * @tags: [
+ * requires_sharding,
+ * ]
+ */
+'use strict';
+
+const dbPrefix = 'fsm_db_for_sharded_timeseries_collection_';
+const dbCount = 2;
+const collPrefix = 'sharded_timeseries_collection_';
+const collCount = 2;
+const timeField = 'time';
+const metaField = 'hostId';
+
+load("jstests/core/timeseries/libs/timeseries.js"); // For 'TimeseriesTest' helpers.
+
+function getRandomDb(db) {
+ return db.getSiblingDB(dbPrefix + Random.randInt(dbCount));
+}
+
+function getRandomTimeseriesView(db) {
+ return getRandomDb(db)[collPrefix + Random.randInt(collCount)];
+}
+
+var $config = (function() {
+ const setup = function(db, collName, cluster) {
+ // Check that necessary feature flags are enabled on each of the mongods.
+ let isEnabled = true;
+ cluster.executeOnMongodNodes(function(db) {
+ if (!TimeseriesTest.timeseriesCollectionsEnabled(db) ||
+ !TimeseriesTest.shardedtimeseriesCollectionsEnabled(db)) {
+ isEnabled = false;
+ }
+ });
+ this.isShardedTimeseriesEnabled = isEnabled;
+
+ if (!this.isShardedTimeseriesEnabled) {
+ jsTestLog(
+ "Feature flags for sharded time-series collections are not enabled. This test will do nothing.");
+ return;
+ }
+
+ // Enable sharding for the test databases.
+ for (var i = 0; i < dbCount; i++) {
+ const dbName = dbPrefix + i;
+ db.adminCommand({enablesharding: dbName});
+ }
+ };
+
+ const states = {
+ init: function(db, collName) {},
+ create: function(db, collName) {
+ if (!this.isShardedTimeseriesEnabled) {
+ return;
+ }
+
+ const coll = getRandomTimeseriesView(db);
+ jsTestLog("Executing create state on: " + coll.getFullName());
+ assertAlways.commandWorked(db.adminCommand({
+ shardCollection: coll.getFullName(),
+ key: {[metaField]: 1, [timeField]: 1},
+ timeseries: {timeField: timeField, metaField: metaField}
+ }));
+ },
+ dropView: function(db, collName) {
+ if (!this.isShardedTimeseriesEnabled) {
+ return;
+ }
+
+ const coll = getRandomTimeseriesView(db);
+ jsTestLog("Executing dropView state on: " + coll.getFullName());
+ assertAlways.commandWorked(coll.getDB().runCommand({drop: coll.getName()}));
+ },
+ };
+
+ const transitions = {
+ init: {create: 0.33, dropView: 0.33},
+ create: {create: 0.33, dropView: 0.33},
+ dropView: {create: 0.33, dropView: 0.33},
+ };
+
+ return {
+ threadCount: 12,
+ iterations: 64,
+ startState: 'init',
+ data: {},
+ states: states,
+ setup: setup,
+ transitions: transitions
+ };
+})();