summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorReo Kimura <reo.kimura@mongodb.com>2021-09-27 19:45:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-27 20:07:09 +0000
commite981f68b35c273faec7b82961460e96998d29bfc (patch)
treec7be372b5ee5b9f2c4b2293767e1aed9c6628f3d /jstests/core
parentc203f95e7bec67d75123116f59bdb9776ab68207 (diff)
downloadmongo-e981f68b35c273faec7b82961460e96998d29bfc.tar.gz
SERVER-59666 Disallow renaming system.buckets collections
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/timeseries/timeseries_bucket_rename.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/jstests/core/timeseries/timeseries_bucket_rename.js b/jstests/core/timeseries/timeseries_bucket_rename.js
new file mode 100644
index 00000000000..41dd8ec61df
--- /dev/null
+++ b/jstests/core/timeseries/timeseries_bucket_rename.js
@@ -0,0 +1,29 @@
+/**
+ * Tests that a system.buckets collection cannot be renamed.
+ *
+ * @tags: [
+ * assumes_no_implicit_collection_creation_after_drop,
+ * does_not_support_stepdowns,
+ * does_not_support_transactions,
+ * requires_getmore,
+ * ]
+ */
+(function() {
+'use strict';
+
+const coll = db.timeseries_bucket_rename;
+const bucketsColl = db.getCollection('system.buckets.' + coll.getName());
+
+const timeFieldName = 'time';
+
+coll.drop();
+assert.commandWorked(db.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));
+assert.contains(bucketsColl.getName(), db.getCollectionNames());
+
+assert.commandFailedWithCode(db.adminCommand({
+ renameCollection: bucketsColl.getFullName(),
+ to: db.getName() + ".otherColl",
+ dropTarget: false
+}),
+ ErrorCodes.IllegalOperation);
+})();