summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/libs/election_timing_test.js2
-rw-r--r--jstests/noPassthrough/backup_restore.js8
-rw-r--r--jstests/noPassthrough/initial_sync_cloner_dups.js4
-rw-r--r--jstests/replsets/apply_batch_only_goes_forward.js4
-rw-r--r--jstests/replsets/auth2.js6
-rw-r--r--jstests/replsets/auth_no_pri.js5
-rw-r--r--jstests/replsets/chaining_removal.js2
-rw-r--r--jstests/replsets/config_server_checks.js13
-rw-r--r--jstests/replsets/drain.js2
-rw-r--r--jstests/replsets/election_not_blocked.js4
-rw-r--r--jstests/replsets/initial_sync1.js7
-rw-r--r--jstests/replsets/maintenance.js2
-rw-r--r--jstests/replsets/oplog_term.js4
-rw-r--r--jstests/replsets/oplog_truncated_on_recovery.js2
-rw-r--r--jstests/replsets/priority_takeover_cascading_priorities.js2
-rw-r--r--jstests/replsets/priority_takeover_one_node_higher_priority.js6
-rw-r--r--jstests/replsets/priority_takeover_two_nodes_equal_priority.js71
-rw-r--r--jstests/replsets/replsetadd_profile.js2
-rw-r--r--jstests/replsets/replsetprio1.js6
-rw-r--r--jstests/replsets/replsetrestart1.js2
-rw-r--r--jstests/replsets/resync_with_write_load.js2
-rw-r--r--jstests/replsets/rollback.js2
-rw-r--r--jstests/replsets/rollback2.js2
-rwxr-xr-xjstests/replsets/rollback3.js2
-rw-r--r--jstests/replsets/rollback5.js2
-rw-r--r--jstests/replsets/rollback_auth.js2
-rw-r--r--jstests/replsets/rollback_cmd_unrollbackable.js2
-rw-r--r--jstests/replsets/rollback_collMod_PowerOf2Sizes.js2
-rw-r--r--jstests/replsets/rollback_collMod_fatal.js2
-rw-r--r--jstests/replsets/rollback_different_h.js2
-rw-r--r--jstests/replsets/rollback_dropdb.js2
-rw-r--r--jstests/replsets/rollback_empty_ns.js2
-rw-r--r--jstests/replsets/rollback_empty_o.js2
-rw-r--r--jstests/replsets/rollback_empty_o2.js2
-rw-r--r--jstests/replsets/rollback_fake_cmd.js2
-rw-r--r--jstests/replsets/rollback_index.js2
-rw-r--r--jstests/replsets/stepdown.js2
-rw-r--r--jstests/replsets/stepdown_kill_other_ops.js4
-rw-r--r--jstests/replsets/stepdown_killop.js4
-rw-r--r--jstests/replsets/stepdown_long_wait_time.js6
-rw-r--r--jstests/replsets/sync_passive.js2
-rw-r--r--jstests/replsets/tags.js2
-rw-r--r--jstests/replsets/test_command.js10
-rw-r--r--jstests/replsets/two_nodes_priority_take_over.js4
-rw-r--r--jstests/sharding/auth.js7
-rw-r--r--jstests/sharding/mongos_no_replica_set_refresh.js2
-rw-r--r--jstests/sharding/recovering_slaveok.js3
-rw-r--r--jstests/sharding/sharding_rs2.js188
-rw-r--r--jstests/slow2/rollback4.js10
-rw-r--r--src/mongo/shell/replsettest.js45
50 files changed, 227 insertions, 248 deletions
diff --git a/jstests/libs/election_timing_test.js b/jstests/libs/election_timing_test.js
index daf52b5c536..e20c9391b75 100644
--- a/jstests/libs/election_timing_test.js
+++ b/jstests/libs/election_timing_test.js
@@ -193,7 +193,7 @@ ElectionTimingTest.prototype.waitForNewPrimary = function(rst, secondary) {
assert.commandWorked(
secondary.adminCommand({
replSetTest: 1,
- waitForMemberState: rst.PRIMARY,
+ waitForMemberState: ReplSetTest.State.PRIMARY,
timeoutMillis: 60 * 1000
}),
"node " + secondary.host + " failed to become primary"
diff --git a/jstests/noPassthrough/backup_restore.js b/jstests/noPassthrough/backup_restore.js
index 0c2d9fd8d17..40d283873e7 100644
--- a/jstests/noPassthrough/backup_restore.js
+++ b/jstests/noPassthrough/backup_restore.js
@@ -255,7 +255,7 @@
}
// Wait up to 60 seconds until restarted node is in state secondary
- rst.waitForState(rst.getSecondaries(), rst.SECONDARY, 60 * 1000);
+ rst.waitForState(rst.getSecondaries(), ReplSetTest.State.SECONDARY, 60 * 1000);
// Add new hidden node to replSetTest
var hiddenCfg = {
@@ -289,7 +289,9 @@
' failed to reconfigure replSet ' + tojson(rsConfig));
// Wait up to 60 seconds until the new hidden node is in state RECOVERING.
- rst.waitForState(rst.nodes[numNodes], [rst.RECOVERING, rst.SECONDARY], 60 * 1000);
+ rst.waitForState(rst.nodes[numNodes],
+ [ReplSetTest.State.RECOVERING, ReplSetTest.State.SECONDARY],
+ 60 * 1000);
// Stop CRUD client and FSM client.
assert(checkProgram(crudPid), testName + ' CRUD client was not running at end of test');
@@ -298,7 +300,7 @@
stopMongoProgramByPid(fsmPid);
// Wait up to 60 seconds until the new hidden node is in state SECONDARY.
- rst.waitForState(rst.nodes[numNodes], rst.SECONDARY, 60 * 1000);
+ rst.waitForState(rst.nodes[numNodes], ReplSetTest.State.SECONDARY, 60 * 1000);
// Stop set.
rst.stopSet();
diff --git a/jstests/noPassthrough/initial_sync_cloner_dups.js b/jstests/noPassthrough/initial_sync_cloner_dups.js
index 0b4ec1368bc..eddbc26cfd9 100644
--- a/jstests/noPassthrough/initial_sync_cloner_dups.js
+++ b/jstests/noPassthrough/initial_sync_cloner_dups.js
@@ -78,7 +78,9 @@ replTest.reInitiate(awaitTimeout * 2);
secondary.setSlaveOk();
// Wait for the secondary to get ReplSetInitiate command.
replTest.waitForState(secondary,
- [replTest.STARTUP_2, replTest.RECOVERING, replTest.SECONDARY],
+ [ReplSetTest.State.STARTUP_2,
+ ReplSetTest.State.RECOVERING,
+ ReplSetTest.State.SECONDARY],
60 * 1000);
// This fail point will cause the first intial sync to fail, and leave an op in the buffer to
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);
diff --git a/jstests/sharding/auth.js b/jstests/sharding/auth.js
index 494c37ec601..8c643b1be64 100644
--- a/jstests/sharding/auth.js
+++ b/jstests/sharding/auth.js
@@ -1,7 +1,6 @@
// Tests administrative sharding operations and map-reduce work or fail as expected, when key-based
// authentication is used
(function() {
-
'use strict';
var adminUser = {
@@ -128,7 +127,7 @@ assert.eq(result.ok, 1, tojson(result));
s.getDB("admin").runCommand({enableSharding : "test"});
s.getDB("admin").runCommand({shardCollection : "test.foo", key : {x : 1}});
-d1.waitForState( d1.getSecondaries(), d1.SECONDARY, 5 * 60 * 1000 )
+d1.waitForState( d1.getSecondaries(), ReplSetTest.State.SECONDARY, 5 * 60 * 1000 )
s.getDB(testUser.db).createUser({user: testUser.username,
pwd: testUser.password,
@@ -250,8 +249,8 @@ assert.eq(count, 500);
logout(adminUser);
-d1.waitForState( d1.getSecondaries(), d1.SECONDARY, 5 * 60 * 1000 );
-d2.waitForState( d2.getSecondaries(), d2.SECONDARY, 5 * 60 * 1000 );
+d1.waitForState( d1.getSecondaries(), ReplSetTest.State.SECONDARY, 5 * 60 * 1000 );
+d2.waitForState( d2.getSecondaries(), ReplSetTest.State.SECONDARY, 5 * 60 * 1000 );
authutil.asCluster(d1.nodes, "jstests/libs/key1", function() { d1.awaitReplication(120000); });
authutil.asCluster(d2.nodes, "jstests/libs/key1", function() { d2.awaitReplication(120000); });
diff --git a/jstests/sharding/mongos_no_replica_set_refresh.js b/jstests/sharding/mongos_no_replica_set_refresh.js
index fb853189cf0..77d8c5e627e 100644
--- a/jstests/sharding/mongos_no_replica_set_refresh.js
+++ b/jstests/sharding/mongos_no_replica_set_refresh.js
@@ -20,7 +20,7 @@ var rsObj = st._rs[0].test;
assert.commandWorked(
rsObj.nodes[0].adminCommand({
replSetTest: 1,
- waitForMemberState: rsObj.PRIMARY,
+ waitForMemberState: ReplSetTest.State.PRIMARY,
timeoutMillis: 60 * 1000,
}),
'node 0 ' + rsObj.nodes[0].host + ' failed to become primary'
diff --git a/jstests/sharding/recovering_slaveok.js b/jstests/sharding/recovering_slaveok.js
index 8862103d129..656bcdb44dc 100644
--- a/jstests/sharding/recovering_slaveok.js
+++ b/jstests/sharding/recovering_slaveok.js
@@ -2,7 +2,6 @@
// RECOVERING state, and don't break
(function() {
-
'use strict';
var shardTest = new ShardingTest({ name: "recovering_slaveok",
@@ -89,7 +88,7 @@ rsA.restart(rsA.getSecondaries(),
print("9: wait for recovery");
-rsA.waitForState(rsA.getSecondaries(), rsA.SECONDARY, 5 * 60 * 1000 );
+rsA.waitForState(rsA.getSecondaries(), ReplSetTest.State.SECONDARY, 5 * 60 * 1000 );
print("10: check our regular and slaveOk query");
diff --git a/jstests/sharding/sharding_rs2.js b/jstests/sharding/sharding_rs2.js
index e3a2082ba8d..6ab976497c6 100644
--- a/jstests/sharding/sharding_rs2.js
+++ b/jstests/sharding/sharding_rs2.js
@@ -4,14 +4,16 @@
// do not support the command.
// @tags: [requires_fsync]
(function() {
+'use strict';
-var s = new ShardingTest({ shards: { rs0: { nodes: 2 }, rs1: { nodes: 2 } },
+var s = new ShardingTest({ shards: { rs0: { nodes: 2 },
+ rs1: { nodes: 2 } },
chunkSize: 1 });
var db = s.getDB("test");
var t = db.foo;
-s.adminCommand( { enablesharding : "test" } );
+s.adminCommand({ enablesharding: "test" });
s.ensurePrimaryShard('test', 'test-rs0');
// -------------------------------------------------------------------------------------------
@@ -19,57 +21,59 @@ s.ensurePrimaryShard('test', 'test-rs0');
// -------------------------------------------------------------------------------------------
-db.foo.save( { _id : 5 ,x : 17 } )
-assert.eq( 1 , db.foo.count() );
+db.foo.save({ _id: 5,x: 17 });
+assert.eq(1, db.foo.count());
-s.config.databases.find().forEach( printjson )
-s.config.shards.find().forEach( printjson )
+s.config.databases.find().forEach(printjson)
+s.config.shards.find().forEach(printjson)
-serverName = s.getServerName( "test" )
+var serverName = s.getServerName("test");
function countNodes(){
- var x = s.config.shards.findOne( { _id : serverName } );
- return x.host.split( "," ).length
+ var x = s.config.shards.findOne({ _id: serverName });
+ return x.host.split(",").length
}
-assert.eq( 2 , countNodes() , "A1" )
+assert.eq(2, countNodes(), "A1");
-rs = s.getRSEntry( serverName );
-rs.test.add()
+var rs = s.getRSEntry(serverName);
+rs.test.add();
try {
rs.test.reInitiate();
}
-catch ( e ){
+catch (e){
// this os ok as rs's may close connections on a change of master
- print( e );
+ print(e);
}
-assert.soon(
+assert.soon(
function(){
try {
- printjson( rs.test.getPrimary().getDB("admin").runCommand( "isMaster" ) )
- s.config.shards.find().forEach( printjsononeline );
+ printjson(rs.test.getPrimary().getDB("admin").runCommand("isMaster"));
+ s.config.shards.find().forEach(printjsononeline);
return countNodes() == 3;
}
- catch ( e ){
- print( e );
+ catch (e){
+ print(e);
}
- } , "waiting for config server to update" , 180 * 1000 , 1000 );
+ }, "waiting for config server to update", 180 * 1000, 1000);
// cleanup after adding node
-for ( i=0; i<5; i++ ){
+for (var i = 0; i < 5; i++) {
try {
db.foo.findOne();
}
- catch ( e ){}
+ catch (e) {
+
+ }
}
-jsTest.log( "Awaiting replication of all nodes, so spurious sync'ing queries don't upset our counts..." )
+jsTest.log("Awaiting replication of all nodes, so spurious sync'ing queries don't upset our counts...")
rs.test.awaitReplication()
// Make sure we wait for secondaries here - otherwise a secondary could come online later and be used for the
// count command before being fully replicated
-jsTest.log( "Awaiting secondary status of all nodes" )
-rs.test.waitForState( rs.test.getSecondaries(), rs.test.SECONDARY, 180 * 1000 )
+jsTest.log("Awaiting secondary status of all nodes")
+rs.test.waitForState(rs.test.getSecondaries(), ReplSetTest.State.SECONDARY, 180 * 1000)
// -------------------------------------------------------------------------------------------
// ---------- test routing to slaves ----------------
@@ -77,148 +81,154 @@ rs.test.waitForState( rs.test.getSecondaries(), rs.test.SECONDARY, 180 * 1000 )
// --- not sharded ----
-m = new Mongo( s.s.name );
-ts = m.getDB( "test" ).foo
+var m = new Mongo(s.s.name);
+var ts = m.getDB("test").foo
-before = rs.test.getPrimary().adminCommand( "serverStatus" ).opcounters
+var before = rs.test.getPrimary().adminCommand("serverStatus").opcounters;
-for ( i=0; i<10; i++ )
- assert.eq( 17 , ts.findOne().x , "B1" )
+for (var i = 0; i < 10; i++) {
+ assert.eq(17, ts.findOne().x, "B1");
+}
-m.setSlaveOk()
-for ( i=0; i<10; i++ )
- assert.eq( 17 , ts.findOne().x , "B2" )
+m.setSlaveOk();
-after = rs.test.getPrimary().adminCommand( "serverStatus" ).opcounters
+for (var i = 0; i < 10; i++) {
+ assert.eq(17, ts.findOne().x, "B2");
+}
+
+var after = rs.test.getPrimary().adminCommand("serverStatus").opcounters;
-printjson( before )
-printjson( after )
+printjson(before);
+printjson(after);
-assert.lte( before.query + 10 , after.query , "B3" )
+assert.lte(before.query + 10, after.query, "B3");
// --- add more data ----
-db.foo.ensureIndex( { x : 1 } )
+db.foo.ensureIndex({ x: 1 })
var bulk = db.foo.initializeUnorderedBulkOp();
-for ( i=0; i<100; i++ ){
- if ( i == 17 ) continue;
+for (var i = 0; i < 100; i++) {
+ if (i == 17) continue;
bulk.insert({ x: i });
}
assert.writeOK(bulk.execute({ w: 3 }));
// Counts pass the options of the connection - which is slaveOk'd, so we need to wait for
// replication for this and future tests to pass
-rs.test.awaitReplication()
+rs.test.awaitReplication();
-assert.eq( 100 , ts.count() , "B4" )
-assert.eq( 100 , ts.find().itcount() , "B5" )
-assert.eq( 100 , ts.find().batchSize(5).itcount() , "B6" )
+assert.eq(100, ts.count(), "B4");
+assert.eq(100, ts.find().itcount(), "B5");
+assert.eq(100, ts.find().batchSize(5).itcount(), "B6");
t.find().batchSize(3).next();
gc(); gc(); gc();
// --- sharded ----
-assert.eq( 100 , db.foo.count() , "C1" )
+assert.eq(100, db.foo.count(), "C1");
-s.adminCommand( { shardcollection : "test.foo" , key : { x : 1 } } );
+assert.commandWorked(s.s0.adminCommand({ shardcollection: "test.foo", key: { x: 1 } }));
// We're doing some manual chunk stuff, so stop the balancer first
-s.stopBalancer()
+s.stopBalancer();
-assert.eq( 100 , t.count() , "C2" )
-s.adminCommand( { split : "test.foo" , middle : { x : 50 } } )
+assert.eq(100, t.count(), "C2");
+assert.commandWorked(s.s0.adminCommand({ split: "test.foo", middle: { x: 50 } }));
-db.printShardingStatus()
+db.printShardingStatus();
-other = s.config.shards.findOne( { _id : { $ne : serverName } } );
+var other = s.config.shards.findOne({ _id: { $ne: serverName } });
assert.commandWorked(s.getDB('admin').runCommand({ moveChunk: "test.foo",
find: { x: 10 },
to: other._id,
_secondaryThrottle: true,
writeConcern: { w: 2 },
_waitForDelete: true }));
-assert.eq( 100 , t.count() , "C3" )
+assert.eq(100, t.count(), "C3");
-assert.eq( 50 , rs.test.getPrimary().getDB( "test" ).foo.count() , "C4" )
+assert.eq(50, rs.test.getPrimary().getDB("test").foo.count(), "C4");
// by non-shard key
-m = new Mongo( s.s.name );
-ts = m.getDB( "test" ).foo
+m = new Mongo(s.s.name);
+ts = m.getDB("test").foo
-before = rs.test.getPrimary().adminCommand( "serverStatus" ).opcounters
+before = rs.test.getPrimary().adminCommand("serverStatus").opcounters
-for ( i=0; i<10; i++ )
- assert.eq( 17 , ts.findOne( { _id : 5 } ).x , "D1" )
+for (var i = 0; i < 10; i++) {
+ assert.eq(17, ts.findOne({ _id: 5 }).x, "D1");
+}
m.setSlaveOk()
-for ( i=0; i<10; i++ )
- assert.eq( 17 , ts.findOne( { _id : 5 } ).x , "D2" )
+for (var i = 0; i < 10; i++) {
+ assert.eq(17, ts.findOne({ _id: 5 }).x, "D2");
+}
-after = rs.test.getPrimary().adminCommand( "serverStatus" ).opcounters
+after = rs.test.getPrimary().adminCommand("serverStatus").opcounters
-assert.lte( before.query + 10 , after.query , "D3" )
+assert.lte(before.query + 10, after.query, "D3")
// by shard key
-m = new Mongo( s.s.name );
+m = new Mongo(s.s.name);
m.forceWriteMode("commands");
db.printShardingStatus()
-ts = m.getDB( "test" ).foo
+ts = m.getDB("test").foo
-before = rs.test.getPrimary().adminCommand( "serverStatus" ).opcounters
+before = rs.test.getPrimary().adminCommand("serverStatus").opcounters
-for ( i=0; i<10; i++ )
- assert.eq( 57 , ts.findOne( { x : 57 } ).x , "E1" )
+for (var i = 0; i < 10; i++) {
+ assert.eq(57, ts.findOne({ x: 57 }).x, "E1");
+}
m.setSlaveOk()
-for ( i=0; i<10; i++ )
- assert.eq( 57 , ts.findOne( { x : 57 } ).x , "E2" )
+for (var i = 0; i < 10; i++) {
+ assert.eq(57, ts.findOne({ x: 57 }).x, "E2");
+}
-after = rs.test.getPrimary().adminCommand( "serverStatus" ).opcounters
+after = rs.test.getPrimary().adminCommand("serverStatus").opcounters
-assert.lte( before.query + 10 , after.query , "E3" )
+assert.lte(before.query + 10, after.query, "E3")
-assert.eq( 100 , ts.count() , "E4" )
-assert.eq( 100 , ts.find().itcount() , "E5" )
-printjson( ts.find().batchSize(5).explain() )
+assert.eq(100, ts.count(), "E4")
+assert.eq(100, ts.find().itcount(), "E5")
+printjson(ts.find().batchSize(5).explain())
// fsyncLock the secondaries
rs.test.getSecondaries().forEach(function(secondary) {
- assert.commandWorked(secondary.getDB( "test" ).fsyncLock());
+ assert.commandWorked(secondary.getDB("test").fsyncLock());
})
// Modify data only on the primary replica of the primary shard.
// { x: 60 } goes to the shard of "rs", which is the primary shard.
-assert.writeOK( ts.insert( { primaryOnly: true, x: 60 } ) );
+assert.writeOK(ts.insert({ primaryOnly: true, x: 60 }));
// Read from secondary through mongos, the doc is not there due to replication delay or fsync.
// But we can guarantee not to read from primary.
-assert.eq( 0, ts.find({ primaryOnly: true, x: 60 }).itcount() );
+assert.eq(0, ts.find({ primaryOnly: true, x: 60 }).itcount());
// Unlock the secondaries
rs.test.getSecondaries().forEach(function(secondary) {
- secondary.getDB( "test" ).fsyncUnlock();
+ secondary.getDB("test").fsyncUnlock();
})
// Clean up the data
-assert.writeOK( ts.remove( { primaryOnly: true, x: 60 }, { writeConcern: { w: 3 }} ) );
+assert.writeOK(ts.remove({ primaryOnly: true, x: 60 }, { writeConcern: { w: 3 }}));
-for ( i=0; i<10; i++ ) {
- m = new Mongo( s.s.name );
+for (var i = 0; i < 10; i++) {
+ m = new Mongo(s.s.name);
m.setSlaveOk();
- ts = m.getDB( "test" ).foo
- assert.eq( 100 , ts.find().batchSize(5).itcount() , "F2." + i )
+ ts = m.getDB("test").foo;
+ assert.eq(100, ts.find().batchSize(5).itcount(), "F2." + i);
}
-for ( i=0; i<10; i++ ) {
- m = new Mongo( s.s.name );
- ts = m.getDB( "test" ).foo
- assert.eq( 100 , ts.find().batchSize(5).itcount() , "F3." + i )
+for (var i = 0; i < 10; i++) {
+ m = new Mongo(s.s.name);
+ ts = m.getDB("test").foo;
+ assert.eq(100, ts.find().batchSize(5).itcount(), "F3." + i);
}
-
-printjson( db.adminCommand( "getShardMap" ) );
+printjson(db.adminCommand("getShardMap"));
s.stop();
diff --git a/jstests/slow2/rollback4.js b/jstests/slow2/rollback4.js
index e77a8c59f1e..0e33bd4e481 100644
--- a/jstests/slow2/rollback4.js
+++ b/jstests/slow2/rollback4.js
@@ -1,4 +1,6 @@
// Test a large rollback SERVER-2737
+(function() {
+'use strict';
var replTest = new ReplSetTest({ name: 'unicomplex',
nodes: 3,
@@ -17,7 +19,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);
+replTest.waitForState(replTest.nodes[0], ReplSetTest.State.PRIMARY, 60 * 1000);
// Make sure we have a master
var master = replTest.getPrimary();
var b_conn = conns[1];
@@ -25,7 +27,7 @@ b_conn.setSlaveOk();
var B = b_conn.getDB("admin");
// Make sure we have an arbiter
-replTest.waitForState(conns[2], replTest.ARBITER, 10000);
+replTest.waitForState(conns[2], ReplSetTest.State.ARBITER, 10000);
// Wait for initial replication
replTest.awaitReplication();
@@ -49,7 +51,7 @@ replTest.stop( 0 );
// node reports that it is primary, while in the refactored implementation (2.7.8+) it takes place
// after the node reports that it is primary via heartbeats, but before ismaster indicates that the
// node will accept writes.
-replTest.waitForState(conns[1], replTest.PRIMARY, 5 * 60 * 1000);
+replTest.waitForState(conns[1], ReplSetTest.State.PRIMARY, 5 * 60 * 1000);
master = replTest.getPrimary(5 * 60 * 1000);
// Save to new master, forcing rollback of old master
@@ -60,3 +62,5 @@ replTest.restart( 0 );
// Wait five minutes to ensure there is enough time for rollback
replTest.awaitSecondaryNodes(5*60*1000);
replTest.awaitReplication(5*60*1000);
+
+});
diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js
index 5695fe4c964..fbf2abb7d90 100644
--- a/src/mongo/shell/replsettest.js
+++ b/src/mongo/shell/replsettest.js
@@ -1062,49 +1062,6 @@ var ReplSetTest = function(opts) {
return master;
};
-
- /**
- * Overflows a replica set secondary or secondaries, specified by id or conn.
- */
- this.overflow = function(secondaries) {
- // Create a new collection to overflow, allow secondaries to replicate
- var master = this.getPrimary();
- var overflowColl = master.getCollection("_overflow.coll");
- overflowColl.insert({ replicated : "value" });
- this.awaitReplication();
-
- this.stop(secondaries);
-
- var count = master.getDB("local").oplog.rs.count();
- var prevCount = -1;
-
- // Insert batches of documents until we exceed the capped size for the oplog and truncate it.
-
- while (count > prevCount) {
- print("ReplSetTest overflow inserting 10000");
- var bulk = overflowColl.initializeUnorderedBulkOp();
- for (var i = 0; i < 10000; i++) {
- bulk.insert({ overflow : "Insert some large overflow value to eat oplog space faster." });
- }
- assert.writeOK(bulk.execute());
-
- prevCount = count;
- this.awaitReplication();
-
- count = master.getDB("local").oplog.rs.count();
-
- print("ReplSetTest overflow count : " + count + " prev : " + prevCount);
- }
-
- // Do one writeConcern:2 write in order to ensure that all of the oplog gets propagated to
- // the secondary which is online.
- assert.writeOK(overflowColl.insert({ overflow: "Last overflow value" },
- { writeConcern: { w: 2 } }));
-
- // Restart all our secondaries and wait for recovery state
- this.start(secondaries, { remember : true }, true, true);
- this.waitForState(secondaries, ReplSetTest.State.RECOVERING, 5 * 60 * 1000);
- };
//
// ReplSetTest initialization
@@ -1164,8 +1121,6 @@ var ReplSetTest = function(opts) {
}
_clearLiveNodes();
-
- Object.extend(this, ReplSetTest.State);
};
/**