0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-31906 Test that applyOps can overwrite admin.system.version

This commit is contained in:
Xiangyu Yao 2017-11-13 17:09:45 -05:00
parent 594cf2ef09
commit 7327250b59

View File

@ -0,0 +1,39 @@
(function() {
"use strict";
var standalone = MongoRunner.runMongod();
var adminDB = standalone.getDB("admin");
// Get the uuid of the original admin.system.version.
var res = adminDB.runCommand({listCollections: 1, filter: {name: "system.version"}});
assert.commandWorked(res, "failed to list collections");
assert.eq(1, res.cursor.firstBatch.length);
var originalUUID = res.cursor.firstBatch[0].info.uuid;
var newUUID = UUID();
// Create new collection, insert new FCV document and then delete the
// original collection.
var createNewAdminSystemVersionCollection =
{op: "c", ns: "admin.$cmd", ui: newUUID, o: {create: "system.version"}};
var insertFCVDocument = {
op: "i",
ns: "admin.system.version",
o: {_id: "featureCompatibilityVersion", version: "3.6"}
};
var dropOriginalAdminSystemVersionCollection =
{op: "c", ns: "admin.$cmd", ui: originalUUID, o: {drop: "admin.tmp_system_version"}};
var cmd = {
applyOps: [
createNewAdminSystemVersionCollection,
insertFCVDocument,
dropOriginalAdminSystemVersionCollection
]
};
assert.commandWorked(adminDB.runCommand(cmd), "failed command " + tojson(cmd));
// Now admin.system.version is overwritten with the new entry.
res = adminDB.runCommand({listCollections: 1, filter: {name: "system.version"}});
assert.commandWorked(res, "failed to list collections");
assert.eq(1, res.cursor.firstBatch.length);
assert.eq(newUUID, res.cursor.firstBatch[0].info.uuid);
})();