From e981f68b35c273faec7b82961460e96998d29bfc Mon Sep 17 00:00:00 2001 From: Reo Kimura Date: Mon, 27 Sep 2021 19:45:41 +0000 Subject: SERVER-59666 Disallow renaming system.buckets collections --- .../core/timeseries/timeseries_bucket_rename.js | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 jstests/core/timeseries/timeseries_bucket_rename.js (limited to 'jstests/core') 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); +})(); -- cgit v1.2.1