|
load("jstests/libs/check_log.js"); // For 'checkLog'.
|
|
// Pause oplog application on a specified node.
|
function pauseOplogApplication(node) {
|
assert.commandWorked(
|
node.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "alwaysOn"}));
|
checkLog.contains(node, "rsSyncApplyStop fail point enabled");
|
}
|
|
// Resume oplog application on a specified node.
|
function resumeOplogApplication(node) {
|
assert.commandWorked(node.adminCommand({configureFailPoint: "rsSyncApplyStop", mode: "off"}));
|
}
|
|
var replTest = new ReplSetTest({name: "applyOpsUUID", nodes: 2});
|
|
replTest.startSet();
|
replTest.initiate();
|
replTest.awaitReplication();
|
|
// Pause application on secondary 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.
|
assert.commandWorked(pdb.createCollection(collName));
|
|
// Get the UUID for 'coll'.
|
let uuid = pdb.getCollectionInfos()[0].info.uuid;
|
|
jsTestLog("Dropping collection.");
|
assert.commandWorked(pdb.runCommand({drop: collName}));
|
assert.commandWorked(pdb.createCollection("otherColl"));
|
|
// Create collection with UUID via applyOps.
|
let ops = [{
|
"op": "c",
|
"ns": "test.$cmd",
|
"ui": uuid,
|
"o": {
|
"create": collName,
|
"idIndex": {"v": 2, "key": {"_id": 1}, "name": "_id_", "ns": "test.coll"}
|
}
|
}];
|
jsTestLog("Doing 'applyOps' command.");
|
assert.commandWorked(pdb.adminCommand({applyOps: ops}));
|
|
// Dump oplog of primary.
|
jsTestLog("Primary oplog.");
|
let oplog = primary.getDB("local")["oplog.rs"].find().toArray();
|
jsTestLog(tojson(oplog));
|
|
jsTestLog("Resuming oplog application.");
|
resumeOplogApplication(replTest.getSecondary());
|
|
// Check data consistency.
|
replTest.awaitReplication();
|
replTest.checkReplicatedDataHashes();
|