summaryrefslogtreecommitdiff
path: root/jstests/replsets
diff options
context:
space:
mode:
authorAllison Chang <allison.chang@10gen.com>2017-06-07 10:29:32 -0400
committerAllison Chang <allison.chang@10gen.com>2017-06-19 12:39:54 -0400
commit3737a7bad0d92bc8ee1383d3d00bd4ca0b0e24f5 (patch)
treec6cf48bb8b1ba6bae3ddf9946b614ce5d58dd8ce /jstests/replsets
parentdac2c7dde31c68fb81364ba3cc8c076235a62ced (diff)
downloadmongo-3737a7bad0d92bc8ee1383d3d00bd4ca0b0e24f5.tar.gz
SERVER-29467 Update comments and logging in rs_rollback files for greater readability
Diffstat (limited to 'jstests/replsets')
-rw-r--r--jstests/replsets/rollback_cmd_unrollbackable.js36
-rw-r--r--jstests/replsets/rollback_collMod_fatal.js34
-rw-r--r--jstests/replsets/rollback_dropdb.js34
3 files changed, 55 insertions, 49 deletions
diff --git a/jstests/replsets/rollback_cmd_unrollbackable.js b/jstests/replsets/rollback_cmd_unrollbackable.js
index 4d8acdb312a..051d4595d05 100644
--- a/jstests/replsets/rollback_cmd_unrollbackable.js
+++ b/jstests/replsets/rollback_cmd_unrollbackable.js
@@ -1,13 +1,15 @@
-// test that a rollback of a non-rollbackable command causes a message to be logged
-//
-// If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
-// not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
-// scenario, none of the members will have any data, and upon restart will each look for a member to
-// inital sync from, so no primary will be elected. This test induces such a scenario, so cannot be
-// run on ephemeral storage engines.
-// @tags: [requires_persistence]
+/**
+ * Test that a rollback of a non-rollbackable command causes a message to be logged
+ *
+ * If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
+ * not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
+ * scenario, none of the members will have any data, and upon restart will each look for a member to
+ * initial sync from, so no primary will be elected. This test induces such a scenario, so cannot be
+ * run on ephemeral storage engines.
+ * @tags: [requires_persistence]
+*/
-// set up a set and grab things for later
+// Sets up a replica set and grabs things for later.
var name = "rollback_cmd_unrollbackable";
var replTest = new ReplSetTest({name: name, nodes: 3});
var nodes = replTest.nodeList();
@@ -25,7 +27,7 @@ var b_conn = conns[1];
var AID = replTest.getNodeId(a_conn);
var BID = replTest.getNodeId(b_conn);
-// get master and do an initial write
+// Gets master and do an initial write.
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
var master = replTest.getPrimary();
assert(master === conns[0], "conns[0] assumed to be master");
@@ -33,17 +35,17 @@ assert(a_conn.host === master.host, "a_conn assumed to be master");
var options = {writeConcern: {w: 2, wtimeout: 60000}, upsert: true};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
-// shut down master
+// Shuts down the master.
replTest.stop(AID);
-// insert a fake oplog entry with a non-rollbackworthy command
+// Inserts a fake oplog entry with a non-rollbackworthy command.
master = replTest.getPrimary();
assert(b_conn.host === master.host, "b_conn assumed to be master");
options = {
writeConcern: {w: 1, wtimeout: 60000},
upsert: true
};
-// another insert to set minvalid ahead
+// Inserts another oplog entry to set minValid ahead.
assert.writeOK(b_conn.getDB(name).foo.insert({x: 123}));
var oplog_entry = b_conn.getDB("local").oplog.rs.find().sort({$natural: -1})[0];
oplog_entry["ts"] = Timestamp(oplog_entry["ts"].t, oplog_entry["ts"].i + 1);
@@ -53,23 +55,23 @@ oplog_entry["o"] = {
};
assert.writeOK(b_conn.getDB("local").oplog.rs.insert(oplog_entry));
-// shut down B and bring back the original master
+// Shuts down B and brings back the original master.
replTest.stop(BID);
replTest.restart(AID);
master = replTest.getPrimary();
assert(a_conn.host === master.host, "a_conn assumed to be master");
-// do a write so that B will have to roll back
+// Does a write so that B will have to roll back.
options = {
writeConcern: {w: 1, wtimeout: 60000},
upsert: true
};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 2}, options));
-// restart B, which should attempt to rollback but then fassert.
+// Restarts B, which should attempt to rollback but then fassert.
clearRawMongoProgramOutput();
replTest.restart(BID);
-var msg = RegExp("can't rollback this command yet: ");
+var msg = RegExp("Can't roll back this command yet: ");
assert.soon(function() {
return rawMongoProgramOutput().match(msg);
}, "Did not see a log entry about skipping the nonrollbackable command during rollback");
diff --git a/jstests/replsets/rollback_collMod_fatal.js b/jstests/replsets/rollback_collMod_fatal.js
index c4409ced190..ed9251e8c92 100644
--- a/jstests/replsets/rollback_collMod_fatal.js
+++ b/jstests/replsets/rollback_collMod_fatal.js
@@ -1,13 +1,15 @@
-// test that a rollback of collMod altering TTL will cause the node to go into a FATAL state
-//
-// If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
-// not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
-// scenario, none of the members will have any data, and upon restart will each look for a member to
-// inital sync from, so no primary will be elected. This test induces such a scenario, so cannot be
-// run on ephemeral storage engines.
-// @tags: [requires_persistence]
+/**
+ * Test that a rollback of collMod altering TTL will cause the node to go into a FATAL state
+ *
+ * If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
+ * not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
+ * scenario, none of the members will have any data, and upon restart will each look for a member to
+ * initial sync from, so no primary will be elected. This test induces such a scenario, so cannot be
+ * run on ephemeral storage engines.
+ * @tags: [requires_persistence]
+ */
-// set up a set and grab things for later
+// Sets up a replica set and grabs things for later.
var name = "rollback_collMod_fatal";
var replTest = new ReplSetTest({name: name, nodes: 3});
var nodes = replTest.nodeList();
@@ -27,7 +29,7 @@ var BID = replTest.getNodeId(b_conn);
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
-// get master and do an initial write
+// Gets master and does an initial write.
var master = replTest.getPrimary();
assert(master === conns[0], "conns[0] assumed to be master");
assert(a_conn.host === master.host, "a_conn assumed to be master");
@@ -35,33 +37,33 @@ var options = {writeConcern: {w: 2, wtimeout: 60000}, upsert: true};
a_conn.getDB(name).foo.ensureIndex({x: 1}, {expireAfterSeconds: 3600});
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
-// shut down master
+// Shuts down the master.
replTest.stop(AID);
-// do a collMod altering TTL which should cause FATAL when rolled back
+// Does a collMod altering TTL which should cause FATAL when rolled back.
master = replTest.getPrimary();
assert(b_conn.host === master.host, "b_conn assumed to be master");
assert.commandWorked(b_conn.getDB(name).runCommand(
{collMod: "foo", index: {keyPattern: {x: 1}, expireAfterSeconds: 10}}));
-// shut down B and bring back the original master
+// Shuts down B and brings back the original master.
replTest.stop(BID);
replTest.restart(AID);
master = replTest.getPrimary();
assert(a_conn.host === master.host, "a_conn assumed to be master");
-// do a write so that B will have to roll back
+// Does a write so that B will have to roll back.
options = {
writeConcern: {w: 1, wtimeout: 60000},
upsert: true
};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 2}, options));
-// restart B, which should attempt rollback but then fassert
+// Restarts B, which should attempt rollback but then fassert.
clearRawMongoProgramOutput();
replTest.restart(BID);
assert.soon(function() {
- return rawMongoProgramOutput().match("cannot rollback a collMod command");
+ return rawMongoProgramOutput().match("Cannot roll back a collMod command");
}, "B failed to fassert");
replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});
diff --git a/jstests/replsets/rollback_dropdb.js b/jstests/replsets/rollback_dropdb.js
index f3ee7607437..3d61970bb77 100644
--- a/jstests/replsets/rollback_dropdb.js
+++ b/jstests/replsets/rollback_dropdb.js
@@ -1,13 +1,15 @@
-// test that a rollback of dropdatabase will cause the node to go into a FATAL state
-//
-// If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
-// not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
-// scenario, none of the members will have any data, and upon restart will each look for a member to
-// inital sync from, so no primary will be elected. This test induces such a scenario, so cannot be
-// run on ephemeral storage engines.
-// @tags: [requires_persistence]
+/**
+ * Test that a rollback of 'dropDatabase' will cause the node to go into a FATAL state
+ *
+ * If all data-bearing nodes in a replica set are using an ephemeral storage engine, the set will
+ * not be able to survive a scenario where all data-bearing nodes are down simultaneously. In such a
+ * scenario, none of the members will have any data, and upon restart will each look for a member to
+ * initial sync from, so no primary will be elected. This test induces such a scenario, so cannot be
+ * run on ephemeral storage engines.
+ * @tags: [requires_persistence]
+ */
-// set up a set and grab things for later
+// Sets up a replica set and grabs things for later.
var name = "rollback_dropdb";
var replTest = new ReplSetTest({name: name, nodes: 3});
var nodes = replTest.nodeList();
@@ -27,41 +29,41 @@ var BID = replTest.getNodeId(b_conn);
replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY);
-// get master and do an initial write
+// Gets master and does an initial write.
var master = replTest.getPrimary();
assert(master === conns[0], "conns[0] assumed to be master");
assert(a_conn.host === master.host, "a_conn assumed to be master");
var options = {writeConcern: {w: 2, wtimeout: 60000}, upsert: true};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
-// shut down master
+// Shuts down the master.
replTest.stop(AID);
-// drop database which should cause FATAL when rolled back
+// Drops the database which should cause FATAL when rolled back.
master = replTest.getPrimary();
assert(b_conn.host === master.host, "b_conn assumed to be master");
b_conn.getDB(name).dropDatabase();
assert.eq(0, b_conn.getDB(name).foo.find().itcount(), "dropping database failed");
-// shut down B and bring back the original master
+// Shuts down B and brings back the original master.
replTest.stop(BID);
replTest.restart(AID);
master = replTest.getPrimary();
assert(a_conn.host === master.host, "a_conn assumed to be master");
-// do a write so that B will have to roll back
+// Does a write so that B will have to roll back.
options = {
writeConcern: {w: 1, wtimeout: 60000},
upsert: true
};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 2}, options));
-// restart B, which should attempt rollback but then fassert
+// Restarts B, which should attempt rollback but then fassert.
clearRawMongoProgramOutput();
replTest.restart(BID);
assert.soon(function() {
return rawMongoProgramOutput().match(
- "rollback : can't rollback drop database full resync will be required");
+ "Can't roll back drop database. Full resync will be required");
}, "B failed to fassert");
replTest.stop(BID, undefined, {allowedExitCode: MongoRunner.EXIT_ABRUPT});