summaryrefslogtreecommitdiff
path: root/jstests/replsets/rollback_index.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/rollback_index.js')
-rw-r--r--jstests/replsets/rollback_index.js40
1 files changed, 27 insertions, 13 deletions
diff --git a/jstests/replsets/rollback_index.js b/jstests/replsets/rollback_index.js
index 1a3197f9ed0..6fb3044b740 100644
--- a/jstests/replsets/rollback_index.js
+++ b/jstests/replsets/rollback_index.js
@@ -25,12 +25,14 @@ var name = "rollback_index";
var replTest = new ReplSetTest({name: name, nodes: 3});
var nodes = replTest.nodeList();
var conns = replTest.startSet();
-replTest.initiate({"_id": name,
- "members": [
- { "_id": 0, "host": nodes[0], priority: 3 },
- { "_id": 1, "host": nodes[1] },
- { "_id": 2, "host": nodes[2], arbiterOnly: true}]
- });
+replTest.initiate({
+ "_id": name,
+ "members": [
+ {"_id": 0, "host": nodes[0], priority: 3},
+ {"_id": 1, "host": nodes[1]},
+ {"_id": 2, "host": nodes[2], arbiterOnly: true}
+ ]
+});
var a_conn = conns[0];
var b_conn = conns[1];
var AID = replTest.getNodeId(a_conn);
@@ -42,7 +44,10 @@ replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000);
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};
+var options = {
+ writeConcern: {w: 2, wtimeout: 60000},
+ upsert: true
+};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
// shut down master
@@ -52,7 +57,10 @@ replTest.stop(AID);
// cause errors when applying operations from the primary.
master = replTest.getPrimary();
assert(b_conn.host === master.host, "b_conn assumed to be master");
-options = {writeConcern: {w: 1, wtimeout: 60000}, upsert: true};
+options = {
+ writeConcern: {w: 1, wtimeout: 60000},
+ upsert: true
+};
// another insert to set minvalid ahead
assert.writeOK(b_conn.getDB(name).foo.insert({x: 123}));
assert.commandWorked(b_conn.getDB(name).foo.ensureIndex({x: 1}, {unique: true}));
@@ -66,7 +74,9 @@ assert(a_conn.host === master.host, "a_conn assumed to be master");
// Insert a document with the same value for 'x' that should be
// propagated successfully to B if the unique index was dropped successfully.
-options = {writeConcern: {w: 1, wtimeout: 60000}};
+options = {
+ writeConcern: {w: 1, wtimeout: 60000}
+};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
assert.eq(2, a_conn.getDB(name).foo.count(), 'invalid number of documents on A');
@@ -78,14 +88,18 @@ replTest.awaitReplication();
replTest.awaitSecondaryNodes();
// Perform a write that should succeed if there's no unique index on B.
-options = {writeConcern: {w: 'majority', wtimeout: 60000}};
+options = {
+ writeConcern: {w: 'majority', wtimeout: 60000}
+};
assert.writeOK(a_conn.getDB(name).foo.insert({x: 1}, options));
// Check collections and indexes.
-assert.eq(3, b_conn.getDB(name).foo.count(),
+assert.eq(3,
+ b_conn.getDB(name).foo.count(),
'Collection on B does not have the same number of documents as A');
-assert.eq(a_conn.getDB(name).foo.getIndexes().length, b_conn.getDB(name).foo.getIndexes().length,
+assert.eq(a_conn.getDB(name).foo.getIndexes().length,
+ b_conn.getDB(name).foo.getIndexes().length,
'Unique index not dropped during rollback: ' +
- tojson(b_conn.getDB(name).foo.getIndexes()));
+ tojson(b_conn.getDB(name).foo.getIndexes()));
replTest.stopSet();