From 20cd3a392e15c7b124f634c4c38a4d480f92d1ef Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Thu, 10 Dec 2015 10:21:51 -0500 Subject: SERVER-21050 Introduce ReplSetTest.State enumeration everywhere Makes all JS tests access the replica set member state from the class itself instead of the object instance. Also removes some unused code. --- jstests/replsets/apply_batch_only_goes_forward.js | 4 +- jstests/replsets/auth2.js | 6 +- jstests/replsets/auth_no_pri.js | 5 +- jstests/replsets/chaining_removal.js | 2 +- jstests/replsets/config_server_checks.js | 13 ++-- jstests/replsets/drain.js | 2 +- jstests/replsets/election_not_blocked.js | 4 +- jstests/replsets/initial_sync1.js | 7 ++- jstests/replsets/maintenance.js | 2 +- jstests/replsets/oplog_term.js | 4 +- jstests/replsets/oplog_truncated_on_recovery.js | 2 +- .../priority_takeover_cascading_priorities.js | 2 +- .../priority_takeover_one_node_higher_priority.js | 6 +- .../priority_takeover_two_nodes_equal_priority.js | 71 +++++++++++----------- jstests/replsets/replsetadd_profile.js | 2 +- jstests/replsets/replsetprio1.js | 6 +- jstests/replsets/replsetrestart1.js | 2 + jstests/replsets/resync_with_write_load.js | 2 +- jstests/replsets/rollback.js | 2 +- jstests/replsets/rollback2.js | 2 +- jstests/replsets/rollback3.js | 2 +- jstests/replsets/rollback5.js | 2 +- jstests/replsets/rollback_auth.js | 2 +- jstests/replsets/rollback_cmd_unrollbackable.js | 2 +- jstests/replsets/rollback_collMod_PowerOf2Sizes.js | 2 +- jstests/replsets/rollback_collMod_fatal.js | 2 +- jstests/replsets/rollback_different_h.js | 2 +- jstests/replsets/rollback_dropdb.js | 2 +- jstests/replsets/rollback_empty_ns.js | 2 +- jstests/replsets/rollback_empty_o.js | 2 +- jstests/replsets/rollback_empty_o2.js | 2 +- jstests/replsets/rollback_fake_cmd.js | 2 +- jstests/replsets/rollback_index.js | 2 +- jstests/replsets/stepdown.js | 2 +- jstests/replsets/stepdown_kill_other_ops.js | 4 +- jstests/replsets/stepdown_killop.js | 4 +- jstests/replsets/stepdown_long_wait_time.js | 6 +- jstests/replsets/sync_passive.js | 2 +- jstests/replsets/tags.js | 2 +- jstests/replsets/test_command.js | 10 +-- jstests/replsets/two_nodes_priority_take_over.js | 4 +- 41 files changed, 107 insertions(+), 99 deletions(-) (limited to 'jstests/replsets') diff --git a/jstests/replsets/apply_batch_only_goes_forward.js b/jstests/replsets/apply_batch_only_goes_forward.js index 8abbb693fe0..e380c981566 100644 --- a/jstests/replsets/apply_batch_only_goes_forward.js +++ b/jstests/replsets/apply_batch_only_goes_forward.js @@ -39,7 +39,7 @@ // Write op assert.writeOK(mTest.foo.save({}, {writeConcern: {w: 3}})); - replTest.waitForState(slave, replTest.SECONDARY, 30000); + replTest.waitForState(slave, ReplSetTest.State.SECONDARY, 30000); assert.writeOK(mTest.foo.save({}, {writeConcern: {w: 3}})); // Set minvalid to something far in the future for the current primary, to simulate recovery. @@ -63,7 +63,7 @@ jsTest.log("restart primary"); replTest.restart(master); printjson(sLocal.adminCommand("isMaster")); - replTest.waitForState(master, replTest.RECOVERING, 90000); + replTest.waitForState(master, ReplSetTest.State.RECOVERING, 90000); // Slave is now master... so do a write to get a minvalid entry on the secondary. assert.writeOK(replTest.getPrimary().getDB("test").foo.save({}, {writeConcern: {w: 3}})); diff --git a/jstests/replsets/auth2.js b/jstests/replsets/auth2.js index 62179c1c7af..b7776d94572 100644 --- a/jstests/replsets/auth2.js +++ b/jstests/replsets/auth2.js @@ -5,18 +5,18 @@ var testInvalidAuthStates = function() { print("check that 0 is in recovering"); - rs.waitForState(rs.nodes[0], rs.RECOVERING); + rs.waitForState(rs.nodes[0], ReplSetTest.State.RECOVERING); print("shut down 1, 0 still in recovering."); rs.stop(1); sleep(5); - rs.waitForState(rs.nodes[0], rs.RECOVERING); + rs.waitForState(rs.nodes[0], ReplSetTest.State.RECOVERING); print("shut down 2, 0 becomes a secondary."); rs.stop(2); - rs.waitForState(rs.nodes[0], rs.SECONDARY); + rs.waitForState(rs.nodes[0], ReplSetTest.State.SECONDARY); rs.restart(1, {"keyFile" : key1}); rs.restart(2, {"keyFile" : key1}); diff --git a/jstests/replsets/auth_no_pri.js b/jstests/replsets/auth_no_pri.js index 59eefa52f52..cce4e8020d6 100644 --- a/jstests/replsets/auth_no_pri.js +++ b/jstests/replsets/auth_no_pri.js @@ -1,5 +1,7 @@ // Test that you can still authenticate a replset connection to a RS with no primary (SERVER-6665). (function () { +'use strict'; + var NODE_COUNT = 3; var rs = new ReplSetTest({"nodes" : NODE_COUNT, keyFile : "jstests/libs/key1"}); var nodes = rs.startSet(); @@ -17,7 +19,7 @@ assert.writeOK(conn.getDB('admin').foo.insert({a:1}, { writeConcern: { w: NODE_C // Make sure there is no primary rs.stop(0); rs.stop(1); -rs.waitForState(nodes[2], rs.SECONDARY); +rs.waitForState(nodes[2], ReplSetTest.State.SECONDARY); // Make sure you can still authenticate a replset connection with no primary var conn2 = new Mongo(rs.getURL()); @@ -26,4 +28,5 @@ assert(conn2.getDB('admin').auth({user:'admin', pwd:'pwd', mechanism:"SCRAM-SHA- assert.eq(1, conn2.getDB('admin').foo.findOne().a); rs.stopSet(); + }()); diff --git a/jstests/replsets/chaining_removal.js b/jstests/replsets/chaining_removal.js index e23c8994ddb..79fc89c8ecd 100644 --- a/jstests/replsets/chaining_removal.js +++ b/jstests/replsets/chaining_removal.js @@ -18,7 +18,7 @@ {_id: 4, host: nodes[4].host, priority: 0}, ], }); - replTest.waitForState(nodes[0], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var primary = replTest.getPrimary(); replTest.awaitReplication(); diff --git a/jstests/replsets/config_server_checks.js b/jstests/replsets/config_server_checks.js index 41579aceb89..2c6128d75e8 100644 --- a/jstests/replsets/config_server_checks.js +++ b/jstests/replsets/config_server_checks.js @@ -33,7 +33,7 @@ try { } catch (e) { // expected since we close all connections after going into REMOVED } -expectState(rst, rst.REMOVED); +expectState(rst, ReplSetTest.State.REMOVED); rst.stopSet(); })(); @@ -52,7 +52,7 @@ conf.configsvr = true; assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: conf})); rst.getPrimary(); -expectState(rst, rst.PRIMARY); +expectState(rst, ReplSetTest.State.PRIMARY); rst.stopSet(); })(); @@ -72,7 +72,7 @@ conf.configsvr = true; assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: conf})); rst.getPrimary(); -expectState(rst, rst.PRIMARY); +expectState(rst, ReplSetTest.State.PRIMARY); var conf = rst.getPrimary().getDB('local').system.replset.findOne(); assert(conf.configsvr, tojson(conf)); @@ -94,7 +94,7 @@ rst.startSet(); assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: 1})); rst.getPrimary(); -expectState(rst, rst.PRIMARY); +expectState(rst, ReplSetTest.State.PRIMARY); rst.stopSet(); })(); @@ -112,7 +112,7 @@ var conf = rst.getReplSetConfig(); assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: conf})); rst.getPrimary(); -expectState(rst, rst.PRIMARY); +expectState(rst, ReplSetTest.State.PRIMARY); assert.throws(function() { rst.restart(0, {configsvr: ""}); }); @@ -136,7 +136,7 @@ conf.configsvr = true; assert.commandWorked(rst.nodes[0].adminCommand({replSetInitiate: conf})); rst.getPrimary(); -expectState(rst, rst.PRIMARY); +expectState(rst, ReplSetTest.State.PRIMARY); var node = rst.nodes[0]; var options = node.savedOptions; @@ -150,5 +150,4 @@ assert.eq(null, conn, "Mongod should have failed to start, but didn't"); rst.stopSet(); })(); - })(); diff --git a/jstests/replsets/drain.js b/jstests/replsets/drain.js index 1f3e3428015..30d4cb61e19 100644 --- a/jstests/replsets/drain.js +++ b/jstests/replsets/drain.js @@ -58,7 +58,7 @@ primary.getDB("admin").shutdownServer({force:true}); var electionTimeout = (isPV0 ? 60 : 20 ) * 1000; // Timeout in milliseconds - replSet.waitForState(secondary, replSet.PRIMARY, electionTimeout); + replSet.waitForState(secondary, ReplSetTest.State.PRIMARY, electionTimeout); // Ensure new primary is not yet writable jsTestLog('New primary should not be writable yet'); diff --git a/jstests/replsets/election_not_blocked.js b/jstests/replsets/election_not_blocked.js index c3523200b0b..ec916f72cf7 100644 --- a/jstests/replsets/election_not_blocked.js +++ b/jstests/replsets/election_not_blocked.js @@ -23,7 +23,7 @@ // In PV1, a voter writes the last vote to disk before granting the vote, // so it cannot vote while fsync locked in PV1. Use PV0 explicitly here. protocolVersion: 0}); - replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); // do a write @@ -37,7 +37,7 @@ // take down master replTest.stop(0); - replTest.waitForState(slave, replTest.PRIMARY, 90*1000); + replTest.waitForState(slave, ReplSetTest.State.PRIMARY, 90*1000); locked.getDB("admin").fsyncUnlock(); replTest.stopSet(); diff --git a/jstests/replsets/initial_sync1.js b/jstests/replsets/initial_sync1.js index 8b673117fd1..4047180d783 100644 --- a/jstests/replsets/initial_sync1.js +++ b/jstests/replsets/initial_sync1.js @@ -82,7 +82,8 @@ wait(function() { (config3 && config3.version == config.version); }); -replTest.waitForState(slave2, [replTest.SECONDARY, replTest.RECOVERING], 60 * 1000); +replTest.waitForState( + slave2, [ReplSetTest.State.SECONDARY, ReplSetTest.State.RECOVERING], 60 * 1000); print("7. Kill the secondary in the middle of syncing"); replTest.stop(slave1); @@ -90,12 +91,12 @@ replTest.stop(slave1); print("8. Eventually the new node should become a secondary"); print("if initial sync has started, this will cause it to fail and sleep for 5 minutes"); -replTest.waitForState(slave2, replTest.SECONDARY, 60 * 1000); +replTest.waitForState(slave2, ReplSetTest.State.SECONDARY, 60 * 1000); print("9. Bring the secondary back up"); replTest.start(slave1, {}, true); reconnect(slave1); -replTest.waitForState(slave1, [replTest.PRIMARY, replTest.SECONDARY], 60 * 1000); +replTest.waitForState(slave1, [ReplSetTest.State.PRIMARY, ReplSetTest.State.SECONDARY], 60 * 1000); print("10. Insert some stuff"); master = replTest.getPrimary(); diff --git a/jstests/replsets/maintenance.js b/jstests/replsets/maintenance.js index 5ecc15456dc..40e7d878ae9 100644 --- a/jstests/replsets/maintenance.js +++ b/jstests/replsets/maintenance.js @@ -5,7 +5,7 @@ var conns = replTest.startSet({ verbose: 1 }); var config = replTest.getReplSetConfig(); config.members[0].priority = 2; replTest.initiate(config); -replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60000); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60000); // Make sure we have a master var master = replTest.getPrimary(); diff --git a/jstests/replsets/oplog_term.js b/jstests/replsets/oplog_term.js index 8cacd0b4e7a..6aa6ca612ae 100644 --- a/jstests/replsets/oplog_term.js +++ b/jstests/replsets/oplog_term.js @@ -8,7 +8,7 @@ var replSet = new ReplSetTest({name: name, nodes: 1, protocolVersion: 0}); replSet.startSet(); replSet.initiate(); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 5 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, 5 * 1000); // Protocol version 0 - 'term' field should be absent from oplog entry. var primary = replSet.getPrimary(); @@ -30,7 +30,7 @@ config.protocolVersion = 1; config.version++; assert.commandWorked(primary.adminCommand({replSetReconfig: config})); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 5 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, 5 * 1000); primary = replSet.getPrimary(); collection = primary.getDB('test').getCollection(name); diff --git a/jstests/replsets/oplog_truncated_on_recovery.js b/jstests/replsets/oplog_truncated_on_recovery.js index c9e2fcaeae2..b9fee8aefba 100644 --- a/jstests/replsets/oplog_truncated_on_recovery.js +++ b/jstests/replsets/oplog_truncated_on_recovery.js @@ -103,7 +103,7 @@ log(assert.commandWorked(localDB.adminCommand("replSetGetStatus"))); log("restart primary"); replTest.restart(master); - replTest.waitForState(master, replTest.RECOVERING, 90000); + replTest.waitForState(master, ReplSetTest.State.RECOVERING, 90000); assert.soon(function() { var mv; diff --git a/jstests/replsets/priority_takeover_cascading_priorities.js b/jstests/replsets/priority_takeover_cascading_priorities.js index b42d8dda317..b17cf0de073 100644 --- a/jstests/replsets/priority_takeover_cascading_priorities.js +++ b/jstests/replsets/priority_takeover_cascading_priorities.js @@ -24,7 +24,7 @@ assert.commandWorked( replSet.nodes[i].adminCommand({ replSetTest: 1, - waitForMemberState: replSet.PRIMARY, + waitForMemberState: ReplSetTest.State.PRIMARY, timeoutMillis: 60 * 1000, }), 'node ' + i + ' ' + replSet.nodes[i].host + ' failed to become primary' diff --git a/jstests/replsets/priority_takeover_one_node_higher_priority.js b/jstests/replsets/priority_takeover_one_node_higher_priority.js index 8c140623867..4fc0dadf60d 100644 --- a/jstests/replsets/priority_takeover_one_node_higher_priority.js +++ b/jstests/replsets/priority_takeover_one_node_higher_priority.js @@ -16,7 +16,7 @@ replSet.startSet(); replSet.initiate(); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var primary = replSet.getPrimary(); // Primary should step down long enough for election to occur on secondary. @@ -30,8 +30,8 @@ 'replSetStepDown did not disconnect client'); // Step down primary and wait for node 1 to be promoted to primary. - replSet.waitForState(replSet.nodes[1], replSet.PRIMARY, 60 * 1000); + replSet.waitForState(replSet.nodes[1], ReplSetTest.State.PRIMARY, 60 * 1000); // Eventually node 0 will stand for election again because it has a higher priorty. - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, stepDownGuardMillis + 60 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, stepDownGuardMillis + 60 * 1000); })(); diff --git a/jstests/replsets/priority_takeover_two_nodes_equal_priority.js b/jstests/replsets/priority_takeover_two_nodes_equal_priority.js index bb0674dabe3..44e177a25f8 100644 --- a/jstests/replsets/priority_takeover_two_nodes_equal_priority.js +++ b/jstests/replsets/priority_takeover_two_nodes_equal_priority.js @@ -3,43 +3,46 @@ // Start replica set. Ensure that highest priority node becomes primary eventually. // Shut down the primary and confirm that the next highest priority node becomes primary. // Repeat until 2 nodes are left standing. +load('jstests/replsets/rslib.js'); + (function () { - 'use strict'; - load('jstests/replsets/rslib.js'); +'use strict'; + +var name = 'priority_takeover_two_nodes_equal_priority'; +var replSet = new ReplSetTest({name: name, nodes: [ + {rsConfig: {priority: 3}}, + {rsConfig: {priority: 3}}, + {}, +]}); +replSet.startSet(); +replSet.initiate(); + +var primary = replSet.getPrimary(); +var primaryIndex = -1; +replSet.nodes.find(function(node, index, array) { + if (primary.host == node.host) { + primaryIndex = index; + return true; + } + return false; +}); +assert.neq(-1, primaryIndex, + 'expected one of the nodes with priority 3 to become primary'); - var name = 'priority_takeover_two_nodes_equal_priority'; - var replSet = new ReplSetTest({name: name, nodes: [ - {rsConfig: {priority: 3}}, - {rsConfig: {priority: 3}}, - {}, - ]}); - replSet.startSet(); - replSet.initiate(); +replSet.stop(primaryIndex); +var newPrimaryIndex = primaryIndex === 0 ? 1 : 0; - var primary = replSet.getPrimary(); - var primaryIndex = -1; - replSet.nodes.find(function(node, index, array) { - if (primary.host == node.host) { - primaryIndex = index; - return true; - } - return false; - }); - assert.neq(-1, primaryIndex, - 'expected one of the nodes with priority 3 to become primary'); +// Refresh connections to nodes. +replSet.status(); - replSet.stop(primaryIndex); - var newPrimaryIndex = primaryIndex === 0 ? 1 : 0; +assert.commandWorked( + replSet.nodes[newPrimaryIndex].adminCommand({ + replSetTest: 1, + waitForMemberState: ReplSetTest.State.PRIMARY, + timeoutMillis: 60 * 1000, + }), + 'node ' + newPrimaryIndex + ' ' + replSet.nodes[newPrimaryIndex].host + + ' failed to become primary' +); - // Refresh connections to nodes. - replSet.status(); - assert.commandWorked( - replSet.nodes[newPrimaryIndex].adminCommand({ - replSetTest: 1, - waitForMemberState: replSet.PRIMARY, - timeoutMillis: 60 * 1000, - }), - 'node ' + newPrimaryIndex + ' ' + replSet.nodes[newPrimaryIndex].host + - ' failed to become primary' - ); })(); diff --git a/jstests/replsets/replsetadd_profile.js b/jstests/replsets/replsetadd_profile.js index cc36f4c1a57..810b6f5f144 100644 --- a/jstests/replsets/replsetadd_profile.js +++ b/jstests/replsets/replsetadd_profile.js @@ -20,7 +20,7 @@ masterCollection.save({a: 1}); var newNode = replTest.add(); replTest.reInitiate(); -replTest.waitForState(replTest.nodes[1], replTest.SECONDARY, 60 * 1000); +replTest.waitForState(replTest.nodes[1], ReplSetTest.State.SECONDARY, 60 * 1000); // Allow documents to propagate to new replica set member. replTest.awaitReplication(); diff --git a/jstests/replsets/replsetprio1.js b/jstests/replsets/replsetprio1.js index c0d6cb48a01..37da3c6474d 100644 --- a/jstests/replsets/replsetprio1.js +++ b/jstests/replsets/replsetprio1.js @@ -13,13 +13,13 @@ {"_id" : 2, "host" : nodenames[2], "priority" : 3}]}); // 2 should be master (give this a while to happen, as 0 will be elected, then demoted) - replTest.waitForState(nodes[2], replTest.PRIMARY, 120000); + replTest.waitForState(nodes[2], ReplSetTest.State.PRIMARY, 120000); // kill 2, 1 should take over replTest.stop(2); // 1 should eventually be master - replTest.waitForState(nodes[1], replTest.PRIMARY, 60000); + replTest.waitForState(nodes[1], ReplSetTest.State.PRIMARY, 60000); // do some writes on 1 var master = replTest.getPrimary(); @@ -33,7 +33,7 @@ // bring 2 back up, 2 should wait until caught up and then become master replTest.restart(2); - replTest.waitForState(nodes[2], replTest.PRIMARY, 60000); + replTest.waitForState(nodes[2], ReplSetTest.State.PRIMARY, 60000); // make sure nothing was rolled back master = replTest.getPrimary(); diff --git a/jstests/replsets/replsetrestart1.js b/jstests/replsets/replsetrestart1.js index 9ff3773a24f..9324b95406b 100644 --- a/jstests/replsets/replsetrestart1.js +++ b/jstests/replsets/replsetrestart1.js @@ -9,6 +9,8 @@ // @tags: [requires_persistence] (function() { + 'use strict'; + var compare_configs = function(c1, c2) { assert.eq(c1.version, c2.version, 'version same'); assert.eq(c1._id, c2._id, '_id same'); diff --git a/jstests/replsets/resync_with_write_load.js b/jstests/replsets/resync_with_write_load.js index f96c9a8e152..b79ab6df616 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // Make sure we have a master var master = replTest.getPrimary(); var a_conn = conns[0]; diff --git a/jstests/replsets/rollback.js b/jstests/replsets/rollback.js index e66357b1fc5..a7ae6c133ed 100644 --- a/jstests/replsets/rollback.js +++ b/jstests/replsets/rollback.js @@ -44,7 +44,7 @@ load("jstests/replsets/rslib.js"); }); // Make sure we have a master - replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); var a_conn = conns[0]; var A = a_conn.getDB("admin"); diff --git a/jstests/replsets/rollback2.js b/jstests/replsets/rollback2.js index 000346b17d3..f557802556b 100644 --- a/jstests/replsets/rollback2.js +++ b/jstests/replsets/rollback2.js @@ -40,7 +40,7 @@ load("jstests/replsets/rslib.js"); ]}); // Make sure we have a master and that that master is node A - replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); var a_conn = conns[0]; a_conn.setSlaveOk(); diff --git a/jstests/replsets/rollback3.js b/jstests/replsets/rollback3.js index b5bfcd655c5..04675164756 100755 --- a/jstests/replsets/rollback3.js +++ b/jstests/replsets/rollback3.js @@ -45,7 +45,7 @@ load("jstests/replsets/rslib.js"); ]}); // Make sure we have a master and that that master is node A - replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); var a_conn = conns[0]; a_conn.setSlaveOk(); diff --git a/jstests/replsets/rollback5.js b/jstests/replsets/rollback5.js index c85e86bbe7c..9c1a31ce100 100644 --- a/jstests/replsets/rollback5.js +++ b/jstests/replsets/rollback5.js @@ -21,7 +21,7 @@ var r = replTest.initiate({ "_id": "rollback5", }); // Make sure we have a master -replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); 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 4e32e51b49a..963ff2dcf0f 100644 --- a/jstests/replsets/rollback_auth.js +++ b/jstests/replsets/rollback_auth.js @@ -39,7 +39,7 @@ ]}); // Make sure we have a master - replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); 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 13cac4e8459..7fc3a413ba1 100644 --- a/jstests/replsets/rollback_cmd_unrollbackable.js +++ b/jstests/replsets/rollback_cmd_unrollbackable.js @@ -24,7 +24,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); +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"); diff --git a/jstests/replsets/rollback_collMod_PowerOf2Sizes.js b/jstests/replsets/rollback_collMod_PowerOf2Sizes.js index 0500e5f28e3..bf7799895f9 100644 --- a/jstests/replsets/rollback_collMod_PowerOf2Sizes.js +++ b/jstests/replsets/rollback_collMod_PowerOf2Sizes.js @@ -79,6 +79,6 @@ try { catch (e) { // Ignore network disconnect. } -replTest.waitForState(a_conn, replTest.PRIMARY); +replTest.waitForState(a_conn, ReplSetTest.State.PRIMARY); assert.eq(getOptions(a_conn), originalCollectionOptions); }()); diff --git a/jstests/replsets/rollback_collMod_fatal.js b/jstests/replsets/rollback_collMod_fatal.js index 03cde3e904c..0e44cf3fe9f 100644 --- a/jstests/replsets/rollback_collMod_fatal.js +++ b/jstests/replsets/rollback_collMod_fatal.js @@ -23,7 +23,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_different_h.js b/jstests/replsets/rollback_different_h.js index a9ca7d1aac3..cc2ee7a54d7 100644 --- a/jstests/replsets/rollback_different_h.js +++ b/jstests/replsets/rollback_different_h.js @@ -34,7 +34,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_dropdb.js b/jstests/replsets/rollback_dropdb.js index aba4264c561..674789db904 100644 --- a/jstests/replsets/rollback_dropdb.js +++ b/jstests/replsets/rollback_dropdb.js @@ -23,7 +23,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_empty_ns.js b/jstests/replsets/rollback_empty_ns.js index fea10564b43..66fd1deaa21 100644 --- a/jstests/replsets/rollback_empty_ns.js +++ b/jstests/replsets/rollback_empty_ns.js @@ -34,7 +34,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_empty_o.js b/jstests/replsets/rollback_empty_o.js index 73a887ee2d9..5f0c2b46c7e 100644 --- a/jstests/replsets/rollback_empty_o.js +++ b/jstests/replsets/rollback_empty_o.js @@ -34,7 +34,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_empty_o2.js b/jstests/replsets/rollback_empty_o2.js index d705aa999b6..b292bac406f 100644 --- a/jstests/replsets/rollback_empty_o2.js +++ b/jstests/replsets/rollback_empty_o2.js @@ -34,7 +34,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_fake_cmd.js b/jstests/replsets/rollback_fake_cmd.js index f4d54a1f146..524b951a700 100644 --- a/jstests/replsets/rollback_fake_cmd.js +++ b/jstests/replsets/rollback_fake_cmd.js @@ -34,7 +34,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/rollback_index.js b/jstests/replsets/rollback_index.js index 67360624a03..c06a0d1de42 100644 --- a/jstests/replsets/rollback_index.js +++ b/jstests/replsets/rollback_index.js @@ -36,7 +36,7 @@ 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); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // get master and do an initial write var master = replTest.getPrimary(); diff --git a/jstests/replsets/stepdown.js b/jstests/replsets/stepdown.js index 502f0cf8c4c..6048164ba62 100644 --- a/jstests/replsets/stepdown.js +++ b/jstests/replsets/stepdown.js @@ -35,7 +35,7 @@ var replTest = new ReplSetTest({ }); var nodes = replTest.startSet(); replTest.initiate(); -replTest.waitForState(nodes[0], replTest.PRIMARY, 60 * 1000); +replTest.waitForState(nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary(); // do a write diff --git a/jstests/replsets/stepdown_kill_other_ops.js b/jstests/replsets/stepdown_kill_other_ops.js index b37eda0f63e..c6b1c4724be 100644 --- a/jstests/replsets/stepdown_kill_other_ops.js +++ b/jstests/replsets/stepdown_kill_other_ops.js @@ -12,7 +12,7 @@ {"_id" : 1, "host" : nodes[1]}, {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var primary = replSet.getPrimary(); assert.eq(primary.host, nodes[0], "primary assumed to be node 0"); @@ -57,7 +57,7 @@ } jsTestLog("Waiting for former PRIMARY to become SECONDARY"); - replSet.waitForState(primary, replSet.SECONDARY, 30000); + replSet.waitForState(primary, ReplSetTest.State.SECONDARY, 30000); var newPrimary = replSet.getPrimary(); assert.neq(primary, newPrimary, "SECONDARY did not become PRIMARY"); diff --git a/jstests/replsets/stepdown_killop.js b/jstests/replsets/stepdown_killop.js index b3b09388808..4b763b7d60a 100644 --- a/jstests/replsets/stepdown_killop.js +++ b/jstests/replsets/stepdown_killop.js @@ -20,7 +20,7 @@ {"_id" : 1, "host" : nodes[1]}, {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var secondary = replSet.getSecondary(); jsTestLog('Disable replication on the SECONDARY ' + secondary.host); @@ -31,7 +31,7 @@ 'Failed to configure rsSyncApplyStop failpoint.' ); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.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 bdb11b56544..37308885c9a 100644 --- a/jstests/replsets/stepdown_long_wait_time.js +++ b/jstests/replsets/stepdown_long_wait_time.js @@ -19,7 +19,7 @@ {"_id" : 1, "host" : nodes[1]}, {"_id" : 2, "host" : nodes[2], "arbiterOnly" : true}]}); - replSet.waitForState(replSet.nodes[0], replSet.PRIMARY, 60 * 1000); + replSet.waitForState(replSet.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var primary = replSet.getPrimary(); var secondary = replSet.getSecondary(); @@ -88,7 +88,7 @@ ); jsTestLog("Wait for PRIMARY " + primary.host + " to completely step down."); - replSet.waitForState(primary, replSet.SECONDARY, secondaryCatchUpPeriodSecs * 1000); + replSet.waitForState(primary, ReplSetTest.State.SECONDARY, secondaryCatchUpPeriodSecs * 1000); var exitCode = stepDowner({checkExitSuccess: false}); assert.neq(0, exitCode, "expected replSetStepDown to close the shell's connection"); @@ -97,5 +97,5 @@ writer({checkExitSuccess: false}); jsTestLog("Wait for SECONDARY " + secondary.host + " to become PRIMARY"); - replSet.waitForState(secondary, replSet.PRIMARY, stepDownSecs * 1000); + replSet.waitForState(secondary, ReplSetTest.State.PRIMARY, stepDownSecs * 1000); })(); diff --git a/jstests/replsets/sync_passive.js b/jstests/replsets/sync_passive.js index fef16253896..76db6a4f838 100644 --- a/jstests/replsets/sync_passive.js +++ b/jstests/replsets/sync_passive.js @@ -29,7 +29,7 @@ config.members[0].priority = 2; config.members[2].priority = 0; replTest.initiate(config); -replTest.waitForState(replTest.nodes[0], replTest.PRIMARY, 60 * 1000); +replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); var master = replTest.getPrimary().getDB("test"); var server0 = master; diff --git a/jstests/replsets/tags.js b/jstests/replsets/tags.js index 47edb4fce11..87bc0075109 100644 --- a/jstests/replsets/tags.js +++ b/jstests/replsets/tags.js @@ -97,7 +97,7 @@ var ensurePrimary = function(nodeId, expectedWritableNodes) { jsTestLog('Node ' + nodeId + ' (' + replTest.nodes[nodeId].host + ') should be primary.'); - replTest.waitForState(replTest.nodes[nodeId], replTest.PRIMARY, 60 * 1000); + replTest.waitForState(replTest.nodes[nodeId], ReplSetTest.State.PRIMARY, 60 * 1000); primary = replTest.getPrimary(); var writeConcern = {writeConcern: {w: expectedWritableNodes, wtimeout: 30 * 1000}}; assert.writeOK(primary.getDB('foo').bar.insert({x: 100}, writeConcern)); diff --git a/jstests/replsets/test_command.js b/jstests/replsets/test_command.js index ac46d25fcbd..2e523c95953 100644 --- a/jstests/replsets/test_command.js +++ b/jstests/replsets/test_command.js @@ -22,7 +22,7 @@ assert.commandWorked( replSet.nodes[0].adminCommand({ replSetTest: 1, - waitForMemberState: replSet.PRIMARY, + waitForMemberState: ReplSetTest.State.PRIMARY, timeoutMillis: 60 * 1000, }), 'node 0' + replSet.nodes[0].host + ' failed to become primary' @@ -63,7 +63,7 @@ assert.commandFailedWithCode( primary.adminCommand({ replSetTest: 1, - waitForMemberState: replSet.PRIMARY, + waitForMemberState: ReplSetTest.State.PRIMARY, timeoutMillis: "what timeout", }), ErrorCodes.TypeMismatch, @@ -83,7 +83,7 @@ assert.commandFailedWithCode( primary.adminCommand({ replSetTest: 1, - waitForMemberState: replSet.PRIMARY, + waitForMemberState: ReplSetTest.State.PRIMARY, timeoutMillis: -1000, }), ErrorCodes.BadValue, @@ -93,7 +93,7 @@ assert.commandFailedWithCode( primary.adminCommand({ replSetTest: 1, - waitForMemberState: replSet.SECONDARY, + waitForMemberState: ReplSetTest.State.SECONDARY, timeoutMillis: 1000, }), ErrorCodes.ExceededTimeLimit, @@ -104,7 +104,7 @@ assert.commandWorked( secondary.adminCommand({ replSetTest: 1, - waitForMemberState: replSet.SECONDARY, + waitForMemberState: ReplSetTest.State.SECONDARY, timeoutMillis: 1000, }), 'replSetTest waitForMemberState(SECONDARY) failed on node 1 ' + diff --git a/jstests/replsets/two_nodes_priority_take_over.js b/jstests/replsets/two_nodes_priority_take_over.js index 227d3ee791f..7e9714c8621 100644 --- a/jstests/replsets/two_nodes_priority_take_over.js +++ b/jstests/replsets/two_nodes_priority_take_over.js @@ -31,7 +31,7 @@ var verbosity = { rst.nodes.forEach(function (node) {node.adminCommand(verbosity)}); // The first node will be the primary at the beginning. -rst.waitForState(rst.nodes[0], rst.PRIMARY, 60 * 1000); +rst.waitForState(rst.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000); // Get the term when replset is stable. var res = rst.getPrimary().adminCommand("replSetGetStatus"); @@ -47,7 +47,7 @@ conf.version = 2; reconfig(rst, conf); // The second node will take over the primary. -rst.waitForState(rst.nodes[1], rst.PRIMARY, 60 * 1000); +rst.waitForState(rst.nodes[1], ReplSetTest.State.PRIMARY, 60 * 1000); res = rst.getPrimary().adminCommand("replSetGetStatus"); assert.commandWorked(res); -- cgit v1.2.1