|
load("jstests/libs/check_log.js"); // For 'checkLog'.
|
function pauseOplogApplication(node) {
|
assert.commandWorked(node.adminCommand(
|
{configureFailPoint: "rsSyncApplyStop", mode: "alwaysOn"}));
|
checkLog.contains(node, "rsSyncApplyStop fail point enabled");
|
}
|
|
function resumeOplogApplication(node) {
|
assert.commandWorked(
|
node.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "off"}));
|
}
|
|
function listAllCollections(adb){
|
let res = assert.commandWorked(adb.runCommand("listCollections", {includePendingDrops: true}));
|
return tojson(res.cursor.firstBatch);
|
}
|
|
let replTest = new ReplSetTest({name: "applyOpsTest", nodes: 2});
|
|
replTest.startSet();
|
replTest.initiate();
|
replTest.awaitReplication();
|
|
// Pause oplog application so collection drop doesn't commit.
|
pauseOplogApplication(replTest.getSecondary());
|
|
// Get connections and collection.
|
let primary = replTest.getPrimary();
|
let pdb = primary.getDB("test");
|
let collName = "coll";
|
|
// Create collection.
|
pdb[collName].insert({x:1});
|
|
let uuid = pdb.getCollectionInfos()[0].info.uuid;
|
|
// Drop collection.
|
jsTestLog("Doing collection drop.");
|
assert.commandWorked(pdb.runCommand({drop: collName, writeConcern: {w: 1}}));
|
|
// Print collections after drop.
|
jsTestLog(listAllCollections(pdb));
|
|
let renameOp = [{
|
"op": "c",
|
"ns": "test.$cmd",
|
"ui": uuid,
|
"o": {"renameCollection": "", "to": "test.not_drop_pending"}
|
}];
|
|
jsTestLog("Doing 'applyOps' command.");
|
assert.commandWorked(pdb.adminCommand({applyOps: renameOp}));
|
|
// Print collections after renameCollection.
|
jsTestLog(listAllCollections(pdb));
|