diff options
32 files changed, 143 insertions, 133 deletions
diff --git a/jstests/replsets/auth2.js b/jstests/replsets/auth2.js index 8dab1918d23..dfdaa6b53fb 100644 --- a/jstests/replsets/auth2.js +++ b/jstests/replsets/auth2.js @@ -31,8 +31,8 @@ var hostnames = rs.nodeList(); rs.initiate({ "_id" : name, "members" : [ {"_id" : 0, "host" : hostnames[0], "priority" : 2}, - {"_id" : 1, "host" : hostnames[1]}, - {"_id" : 2, "host" : hostnames[2]} + {"_id" : 1, "host" : hostnames[1], priority: 0}, + {"_id" : 2, "host" : hostnames[2], priority: 0} ]}); var master = rs.getMaster(); diff --git a/jstests/replsets/buildindexes.js b/jstests/replsets/buildindexes.js index 76de7974f39..5ec65765e27 100644 --- a/jstests/replsets/buildindexes.js +++ b/jstests/replsets/buildindexes.js @@ -1,4 +1,6 @@ -doTest = function( signal ) { +// Check that buildIndexes config option is working + +(function() { var name = "buildIndexes"; var host = getHostName(); @@ -22,65 +24,43 @@ doTest = function( signal ) { } replTest.awaitReplication(); - print("creating an index on x"); master.x.ensureIndex({y : 1}); - printjson(master.x.stats()); - for (var i=0; i<100; i++) { + for (i = 0; i < 100; i++) { master.x.insert({x:1,y:"abc",c:1}); } replTest.awaitReplication(); - printjson(slave[0].runCommand({count: "x"})); - var ns = master.x+""; - print("namespace: "+ns); + assert.commandWorked(slave[0].runCommand({count: "x"})); - // can't query system.indexes from slave, so we'll look at coll.stats() - printjson(slave[0].adminCommand({replSetGetStatus:1})); - printjson(slave[0].getSisterDB("local").system.replset.findOne()); - printjson(master.stats()); - printjson(slave[0].stats()); - printjson(slave[1].stats()); - printjson(master.x.stats()); - printjson(slave[0].x.stats()); - printjson(slave[1].x.stats()); - print("sleeping"); - sleep(20000); var indexes = slave[0].stats().indexes; assert.eq(indexes, 2, 'number of indexes'); indexes = slave[1].stats().indexes; assert.eq(indexes, 1); - indexes = slave[0].x.stats().indexSizes; - printjson(indexes); var count = 0; - for (var i in indexes) { + for (i in indexes) { count++; if (i == "_id_") { continue; } - print(i); - print(i.match(/y_/)); assert(i.match(/y_/)); } assert.eq(count, 2); indexes = slave[1].x.stats().indexSizes; - printjson(indexes); count = 0; - for (var i in indexes) { + for (i in indexes) { count++; } assert.eq(count, 1); - replTest.stopSet(15); -} - -doTest(15); + replTest.stopSet(); +}()); diff --git a/jstests/replsets/chaining_removal.js b/jstests/replsets/chaining_removal.js index c3c23c59d38..2175c8d72cd 100644 --- a/jstests/replsets/chaining_removal.js +++ b/jstests/replsets/chaining_removal.js @@ -12,10 +12,10 @@ replTest.initiate({_id: name, members: [ {_id: 0, host: nodes[0].host, priority: 3}, - {_id: 1, host: nodes[1].host}, - {_id: 2, host: nodes[2].host}, - {_id: 3, host: nodes[3].host}, - {_id: 4, host: nodes[4].host}, + {_id: 1, host: nodes[1].host, priority: 0}, + {_id: 2, host: nodes[2].host, priority: 0}, + {_id: 3, host: nodes[3].host, priority: 0}, + {_id: 4, host: nodes[4].host, priority: 0}, ], }); var primary = replTest.getPrimary(); diff --git a/jstests/replsets/drain.js b/jstests/replsets/drain.js index 37d56e0628b..591f3df628a 100644 --- a/jstests/replsets/drain.js +++ b/jstests/replsets/drain.js @@ -15,7 +15,7 @@ replSet.startSet(); replSet.initiate({"_id" : "testSet", "members" : [ - {"_id" : 0, "host" : nodes[0], "priority" : 3}, + {"_id" : 0, "host" : nodes[0]}, {"_id" : 1, "host" : nodes[1]}, {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); diff --git a/jstests/replsets/election_not_blocked.js b/jstests/replsets/election_not_blocked.js index 851096ebb49..87eb6634135 100644 --- a/jstests/replsets/election_not_blocked.js +++ b/jstests/replsets/election_not_blocked.js @@ -20,6 +20,7 @@ {_id: 1, host: host+":"+port[1]}, {_id: 2, host: host+":"+port[2], hidden: true, priority: 0}, ]}); + replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); // do a write diff --git a/jstests/replsets/initial_sync3.js b/jstests/replsets/initial_sync3.js index 0355ad1db3e..200e0a30213 100644 --- a/jstests/replsets/initial_sync3.js +++ b/jstests/replsets/initial_sync3.js @@ -16,7 +16,7 @@ replTest.initiate({ _id : name, members : [ {_id:0, host : host+":"+port[0], priority: 10}, - {_id:1, host : host+":"+port[1]}, + {_id:1, host : host+":"+port[1], priority: 0}, {_id:2, host : host+":"+port[2], priority : 0, buildIndexes : false}, ]}); diff --git a/jstests/replsets/maxSyncSourceLagSecs.js b/jstests/replsets/maxSyncSourceLagSecs.js index cfbf575025f..8d4702510e1 100644 --- a/jstests/replsets/maxSyncSourceLagSecs.js +++ b/jstests/replsets/maxSyncSourceLagSecs.js @@ -11,8 +11,8 @@ replTest.initiate({"_id": name, "members": [ { "_id": 0, "host": nodes[0], priority: 3 }, - { "_id": 1, "host": nodes[1] }, - { "_id": 2, "host": nodes[2] }], + { "_id": 1, "host": nodes[1], priority: 0 }, + { "_id": 2, "host": nodes[2], priority: 0 }], }); var master = replTest.getMaster(); diff --git a/jstests/replsets/no_chaining.js b/jstests/replsets/no_chaining.js index 4934f1975b6..6a30527a56f 100644 --- a/jstests/replsets/no_chaining.js +++ b/jstests/replsets/no_chaining.js @@ -10,9 +10,9 @@ replTest.initiate( { "_id" : "testSet", "members" : [ - {"_id" : 0, "host" : hostnames[0], "priority" : 2}, - {"_id" : 1, "host" : hostnames[1]}, - {"_id" : 2, "host" : hostnames[2]} + {"_id" : 0, "host" : hostnames[0], priority: 2}, + {"_id" : 1, "host" : hostnames[1], priority: 0}, + {"_id" : 2, "host" : hostnames[2], priority: 0} ], "settings" : { "chainingAllowed" : false diff --git a/jstests/replsets/pipelineout.js b/jstests/replsets/pipelineout.js index a9ec98e5351..5e0c1d7f45c 100644 --- a/jstests/replsets/pipelineout.js +++ b/jstests/replsets/pipelineout.js @@ -6,7 +6,7 @@ var nodes = replTest.nodeList(); replTest.startSet(); replTest.initiate({"_id" : name, "members" : [ - {"_id" : 0, "host" : nodes[0], "priority" : 5}, + {"_id" : 0, "host" : nodes[0]}, {"_id" : 1, "host" : nodes[1]} ]}); diff --git a/jstests/replsets/replsetarb2.js b/jstests/replsets/replsetarb2.js index 23cb483fed0..75c53008c54 100644 --- a/jstests/replsets/replsetarb2.js +++ b/jstests/replsets/replsetarb2.js @@ -9,14 +9,13 @@ var conns = replTest.startSet(); var r = replTest.initiate({"_id" : "unicomplex", "members" : [ - {"_id" : 0, "host" : nodes[0], "priority" : 2}, + {"_id" : 0, "host" : nodes[0]}, {"_id" : 1, "host" : nodes[1], "arbiterOnly" : true, "votes": 1}, {"_id" : 2, "host" : nodes[2]} ]}); // Make sure we have a master var master = replTest.getMaster(); - assert.eq(master, conns[0], "wrong node became master"); // Make sure we have an arbiter assert.soon(function() { @@ -41,7 +40,7 @@ var new_master = replTest.getMaster(); var newMasterId = replTest.getNodeId(new_master); - assert.eq(newMasterId, 2, "Secondary wasn't promoted to new primary"); + assert.neq(newMasterId, mId, "Secondary wasn't promoted to new primary"); replTest.stopSet(15); }()); diff --git a/jstests/replsets/resync_with_write_load.js b/jstests/replsets/resync_with_write_load.js index 9fe82b62fb7..a0a76792a0a 100644 --- a/jstests/replsets/resync_with_write_load.js +++ b/jstests/replsets/resync_with_write_load.js @@ -17,7 +17,7 @@ var config = { "_id": testName, {"_id": 2, "host": nodes[2]}] }; var r = replTest.initiate(config); - +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); // Make sure we have a master var master = replTest.getMaster(); var a_conn = conns[0]; @@ -28,6 +28,7 @@ var A = a_conn.getDB("test"); var B = b_conn.getDB("test"); var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); + assert(master == conns[0], "conns[0] assumed to be master"); assert(a_conn.host == master.host); diff --git a/jstests/replsets/rollback.js b/jstests/replsets/rollback.js index 743f7138223..aa8f7fa54e1 100644 --- a/jstests/replsets/rollback.js +++ b/jstests/replsets/rollback.js @@ -30,11 +30,10 @@ load("jstests/replsets/rslib.js"); assert.eq(3, x[2].q); assert.eq(7, x[3].q); assert.eq(8, x[4].q); - } + }; var replTest = new ReplSetTest({ name: 'unicomplex', nodes: 3, oplogSize: 1 }); var nodes = replTest.nodeList(); - //jsTest.log(tojson(nodes)); var conns = replTest.startSet(); var r = replTest.initiate({ "_id": "unicomplex", @@ -46,6 +45,7 @@ load("jstests/replsets/rslib.js"); replTest.bridge(); // Make sure we have a master + replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); var a_conn = conns[0]; var A = a_conn.getDB("admin"); @@ -71,7 +71,8 @@ load("jstests/replsets/rslib.js"); for (var i = 0; i < 1000; i++) { bulk.find({}).update({ $inc: { x: 1 }}); } - // unlikely secondary isn't keeping up, but let's avoid possible intermittent issues with that. + // unlikely secondary isn't keeping up, but let's avoid possible intermittent + // issues with that. bulk.execute({ w: 2 }); var op = a.getSisterDB("local").oplog.rs.find().sort({ $natural: 1 }).limit(1)[0]; diff --git a/jstests/replsets/rollback2.js b/jstests/replsets/rollback2.js index 9fb10f730c0..8897455515c 100644 --- a/jstests/replsets/rollback2.js +++ b/jstests/replsets/rollback2.js @@ -41,6 +41,7 @@ load("jstests/replsets/rslib.js"); replTest.bridge(); // Make sure we have a master and that that master is node A + replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); var a_conn = conns[0]; a_conn.setSlaveOk(); diff --git a/jstests/replsets/rollback3.js b/jstests/replsets/rollback3.js index 959dad91955..762f7589b41 100755 --- a/jstests/replsets/rollback3.js +++ b/jstests/replsets/rollback3.js @@ -46,6 +46,7 @@ load("jstests/replsets/rslib.js"); replTest.bridge(); // Make sure we have a master and that that master is node A + replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); var a_conn = conns[0]; a_conn.setSlaveOk(); diff --git a/jstests/replsets/rollback5.js b/jstests/replsets/rollback5.js index 79b5b274435..30b3d6b3420 100644 --- a/jstests/replsets/rollback5.js +++ b/jstests/replsets/rollback5.js @@ -14,6 +14,7 @@ var r = replTest.initiate({ "_id": "rollback5", }); // Make sure we have a master +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); var a_conn = conns[0]; var b_conn = conns[1]; diff --git a/jstests/replsets/rollback_auth.js b/jstests/replsets/rollback_auth.js index ac89a83bcbb..936337457b1 100644 --- a/jstests/replsets/rollback_auth.js +++ b/jstests/replsets/rollback_auth.js @@ -32,6 +32,7 @@ ]}); // Make sure we have a master + replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); var a_conn = conns[0]; var b_conn = conns[1]; diff --git a/jstests/replsets/rollback_cmd_unrollbackable.js b/jstests/replsets/rollback_cmd_unrollbackable.js index 0d4b4b0eb26..e83972c32f1 100644 --- a/jstests/replsets/rollback_cmd_unrollbackable.js +++ b/jstests/replsets/rollback_cmd_unrollbackable.js @@ -17,6 +17,7 @@ var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); // get master and do an initial write +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); assert(a_conn.host === master.host, "a_conn assumed to be master"); diff --git a/jstests/replsets/rollback_collMod_PowerOf2Sizes.js b/jstests/replsets/rollback_collMod_PowerOf2Sizes.js index 16fb68f53e8..148ebddec1f 100644 --- a/jstests/replsets/rollback_collMod_PowerOf2Sizes.js +++ b/jstests/replsets/rollback_collMod_PowerOf2Sizes.js @@ -19,19 +19,18 @@ var nodes = replTest.nodeList(); var conns = replTest.startSet(); replTest.initiate({"_id": name, "members": [ - { "_id": 0, "host": nodes[0], priority: 3 }, + { "_id": 0, "host": nodes[0] }, { "_id": 1, "host": nodes[1] }, { "_id": 2, "host": nodes[2], arbiterOnly: true}] }); -var a_conn = conns[0]; -var b_conn = conns[1]; +// get master and do an initial write +var master = replTest.getMaster(); +var a_conn = master; +var slaves = replTest.liveNodes.slaves; +var b_conn = slaves[0]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); -// get master and do an initial write -var master = replTest.getMaster(); -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)); diff --git a/jstests/replsets/rollback_collMod_fatal.js b/jstests/replsets/rollback_collMod_fatal.js index 311cb21eb8d..4235c39fc73 100644 --- a/jstests/replsets/rollback_collMod_fatal.js +++ b/jstests/replsets/rollback_collMod_fatal.js @@ -16,6 +16,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/rollback_different_h.js b/jstests/replsets/rollback_different_h.js index 4d216f671fa..9c0d3cdae77 100644 --- a/jstests/replsets/rollback_different_h.js +++ b/jstests/replsets/rollback_different_h.js @@ -27,6 +27,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/rollback_dropdb.js b/jstests/replsets/rollback_dropdb.js index 24505dbfd36..81cbb139730 100644 --- a/jstests/replsets/rollback_dropdb.js +++ b/jstests/replsets/rollback_dropdb.js @@ -16,6 +16,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/rollback_empty_ns.js b/jstests/replsets/rollback_empty_ns.js index 5e47e9257f5..2d7ed1e0e07 100644 --- a/jstests/replsets/rollback_empty_ns.js +++ b/jstests/replsets/rollback_empty_ns.js @@ -27,6 +27,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/rollback_empty_o.js b/jstests/replsets/rollback_empty_o.js index d95ebb6d5ef..0ec66a4b9c3 100644 --- a/jstests/replsets/rollback_empty_o.js +++ b/jstests/replsets/rollback_empty_o.js @@ -27,6 +27,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/rollback_empty_o2.js b/jstests/replsets/rollback_empty_o2.js index a1a1c78858e..51d68e5481c 100644 --- a/jstests/replsets/rollback_empty_o2.js +++ b/jstests/replsets/rollback_empty_o2.js @@ -27,6 +27,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/rollback_fake_cmd.js b/jstests/replsets/rollback_fake_cmd.js index 96c27ee68e5..c93cbb6f4db 100644 --- a/jstests/replsets/rollback_fake_cmd.js +++ b/jstests/replsets/rollback_fake_cmd.js @@ -27,6 +27,8 @@ var b_conn = conns[1]; var AID = replTest.getNodeId(a_conn); var BID = replTest.getNodeId(b_conn); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + // get master and do an initial write var master = replTest.getMaster(); assert(master === conns[0], "conns[0] assumed to be master"); diff --git a/jstests/replsets/slavedelay3.js b/jstests/replsets/slavedelay3.js index e89fe965f46..ad52f8d459e 100644 --- a/jstests/replsets/slavedelay3.js +++ b/jstests/replsets/slavedelay3.js @@ -8,6 +8,7 @@ var config = replTest.getReplSetConfig(); config.members[0].priority = 2; config.members[1].priority = 0; config.members[1].slaveDelay = 5; +config.members[2].priority = 0; replTest.initiate(config); replTest.awaitReplication(); @@ -35,4 +36,4 @@ master.foo.insert({x:1}); // make sure the record still appears in the remote slave assert.soon( function() { return slave[1].foo.findOne() != null; } ); -replTest.stopSet();
\ No newline at end of file +replTest.stopSet(); diff --git a/jstests/replsets/stepdown_kill_other_ops.js b/jstests/replsets/stepdown_kill_other_ops.js index 41778c0c4d0..3c91bc93d48 100644 --- a/jstests/replsets/stepdown_kill_other_ops.js +++ b/jstests/replsets/stepdown_kill_other_ops.js @@ -12,6 +12,8 @@ {"_id" : 1, "host" : nodes[1]}, {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); + replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + var primary = replSet.getPrimary(); assert.eq(primary.host, nodes[0], "primary assumed to be node 0"); assert.writeOK(primary.getDB(name).foo.insert({x: 1}, {w: 2, wtimeout:10000})); diff --git a/jstests/replsets/stepdown_killop.js b/jstests/replsets/stepdown_killop.js index fd7975478d4..8e958fdb1e9 100644 --- a/jstests/replsets/stepdown_killop.js +++ b/jstests/replsets/stepdown_killop.js @@ -24,6 +24,9 @@ replSet.bridge(); replSet.partition(1,0); replSet.partition(1,2); + + replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + var primary = replSet.getPrimary(); assert.eq(primary.host, nodes[0], "primary assumed to be node 0"); diff --git a/jstests/replsets/stepdown_long_wait_time.js b/jstests/replsets/stepdown_long_wait_time.js index 27493d55173..6ca307cc8b9 100644 --- a/jstests/replsets/stepdown_long_wait_time.js +++ b/jstests/replsets/stepdown_long_wait_time.js @@ -23,6 +23,8 @@ replSet.bridge(); replSet.partition(1,0); replSet.partition(1,2); + + replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); var primary = replSet.getPrimary(); assert.eq(primary.host, nodes[0], "primary assumed to be node 0"); diff --git a/jstests/replsets/sync_passive.js b/jstests/replsets/sync_passive.js index f4ee4e2243c..2f3431ed7a7 100644 --- a/jstests/replsets/sync_passive.js +++ b/jstests/replsets/sync_passive.js @@ -29,6 +29,7 @@ config.members[0].priority = 2; config.members[2].priority = 0; replTest.initiate(config); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); var master = replTest.getMaster().getDB("test"); var server0 = master; diff --git a/jstests/slow1/replsets_priority1.js b/jstests/slow1/replsets_priority1.js index e6587de99ce..db28539ebe4 100644 --- a/jstests/slow1/replsets_priority1.js +++ b/jstests/slow1/replsets_priority1.js @@ -1,6 +1,6 @@ // come up with random priorities and make sure that the right member gets -// elected. then kill that member and make sure then next one gets elected.
-
+// elected. then kill that member and make sure the next one gets elected. + print("\n\n\nreplsets_priority1.js BEGIN\n"); load("jstests/replsets/rslib.js"); @@ -29,65 +29,65 @@ var everyoneOkSoon = function() { } return ok; }, tojson(status)); -};
-
-var checkPrimaryIs = function (node) {
-
- print("nreplsets_priority1.js checkPrimaryIs(" + node + ")");
-
- var status;
-
- assert.soon(function () {
- var ok = true;
-
- try {
- status = master.adminCommand({ replSetGetStatus: 1 });
- }
- catch (e) {
- print(e);
- print("nreplsets_priority1.js checkPrimaryIs reconnecting");
- reconnect(master);
- status = master.adminCommand({ replSetGetStatus: 1 });
- }
-
- var str = "goal: " + node.host + "==1 states: ";
- if (!status || !status.members) {
- return false;
- }
- status.members.forEach(function (m) {
- str += m.name + ": " + m.state + " ";
-
- if (m.name == node.host) {
- ok &= m.state == 1;
- }
- else {
- ok &= m.state != 1 || (m.state == 1 && m.health == 0);
- }
- });
- print();
- print(str);
- print();
-
- occasionally(function () {
- print("\nstatus:");
- printjson(status);
- print();
- }, 15);
-
- return ok;
- }, node.host + '==1', 60000, 1000);
-
- everyoneOkSoon();
}; -everyoneOkSoon();
-
+var checkPrimaryIs = function (node) { + + print("nreplsets_priority1.js checkPrimaryIs(" + node + ")"); + + var status; + + assert.soon(function () { + var ok = true; + + try { + status = master.adminCommand({ replSetGetStatus: 1 }); + } + catch (e) { + print(e); + print("nreplsets_priority1.js checkPrimaryIs reconnecting"); + reconnect(master); + status = master.adminCommand({ replSetGetStatus: 1 }); + } + + var str = "goal: " + node.host + "==1 states: "; + if (!status || !status.members) { + return false; + } + status.members.forEach(function (m) { + str += m.name + ": " + m.state + " "; + + if (m.name == node.host) { + ok &= m.state == 1; + } + else { + ok &= m.state != 1 || (m.state == 1 && m.health == 0); + } + }); + print(); + print(str); + print(); + + occasionally(function () { + print("\nstatus:"); + printjson(status); + print(); + }, 15); + + return ok; + }, node.host + '==1', 60000, 1000); + + everyoneOkSoon(); +}; + +everyoneOkSoon(); + print("\n\nreplsets_priority1.js initial sync"); // intial sync master.getDB("foo").bar.insert({x:1}); -rs.awaitReplication();
-
+rs.awaitReplication(); + print("\n\nreplsets_priority1.js starting loop"); var n = 5; @@ -102,8 +102,8 @@ for (i=0; i<n; i++) { var version = config.version; config.version++; - for (var j=0; j<config.members.length; j++) {
- var priority = Math.random() * 100;
+ for (var j=0; j<config.members.length; j++) { + var priority = Math.random() * 100; print("random priority : " + priority); config.members[j].priority = priority; @@ -119,8 +119,8 @@ for (i=0; i<n; i++) { if (!second || config.members[j].priority > second.priority) { second = config.members[j]; } - }
-
+ } + print("\n\nreplsets_priority1.js max is " + max.host + " with priority " + max.priority + ", reconfiguring..."); var count = 0; @@ -138,20 +138,20 @@ for (i=0; i<n; i++) { version = master.getDB("local").system.replset.findOne().version; } - catch (e) {
+ catch (e) { print("nreplsets_priority1.js Caught exception: " + e); } count++; - }
-
+ } + print("\nreplsets_priority1.js wait for 2 slaves"); assert.soon(function() { rs.getMaster(); return rs.liveNodes.slaves.length == 2; - }, "2 slaves");
-
+ }, "2 slaves"); + print("\nreplsets_priority1.js wait for new config version " + config.version); assert.soon(function() { @@ -161,20 +161,20 @@ for (i=0; i<n; i++) { rs.liveNodes.slaves[1].setSlaveOk(); versions[1] = rs.liveNodes.slaves[1].getDB("local").system.replset.findOne().version; return versions[0] == config.version && versions[1] == config.version; - });
-
- print("replsets_priority1.js awaitReplication");
+ }); + + print("replsets_priority1.js awaitReplication"); // the reconfiguration needs to be replicated! the hb sends it out // separately from the repl - rs.awaitReplication();
-
+ rs.awaitReplication(); + print("reconfigured. Checking statuses."); - checkPrimaryIs(max);
-
- print("rs.stop");
-
+ checkPrimaryIs(max); + + print("rs.stop"); + rs.stop(max._id); var master = rs.getMaster(); @@ -182,8 +182,8 @@ for (i=0; i<n; i++) { print("\nkilled max primary. Checking statuses."); print("second is "+second.host+" with priority "+second.priority); - checkPrimaryIs(second);
-
+ checkPrimaryIs(second); + print("restart max " + max._id); rs.restart(max._id); diff --git a/jstests/slow2/rollback4.js b/jstests/slow2/rollback4.js index 3cb9d9bec00..db1cefe0eab 100644 --- a/jstests/slow2/rollback4.js +++ b/jstests/slow2/rollback4.js @@ -14,6 +14,7 @@ var r = replTest.initiate({ "_id": "unicomplex", { "_id": 2, "host": nodes[2], arbiterOnly: true}] }, 'replSetInitiate', 600000); +replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); // Make sure we have a master var master = replTest.getMaster(); var b_conn = conns[1]; |