summaryrefslogtreecommitdiff
path: root/jstests/sharding/repl_monitor_refresh.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/repl_monitor_refresh.js')
-rw-r--r--jstests/sharding/repl_monitor_refresh.js112
1 files changed, 55 insertions, 57 deletions
diff --git a/jstests/sharding/repl_monitor_refresh.js b/jstests/sharding/repl_monitor_refresh.js
index 6767a165d9d..28e86ec8d32 100644
--- a/jstests/sharding/repl_monitor_refresh.js
+++ b/jstests/sharding/repl_monitor_refresh.js
@@ -3,73 +3,71 @@
* become invalid when a replica set reconfig happens.
*/
(function() {
-"use strict";
-
-var NODE_COUNT = 3;
-var st = new ShardingTest({ shards: { rs0: { nodes: NODE_COUNT, oplogSize: 10 }}});
-var replTest = st.rs0;
-var mongos = st.s;
-
-var shardDoc = mongos.getDB('config').shards.findOne();
-assert.eq(NODE_COUNT, shardDoc.host.split(',').length); // seed list should contain all nodes
-
-/* Make sure that the first node is not the primary (by making the second one primary).
- * We need to do this since the ReplicaSetMonitor iterates over the nodes one
- * by one and you can't remove a node that is currently the primary.
- */
-var connPoolStats = mongos.getDB('admin').runCommand({ connPoolStats: 1 });
-var targetHostName = connPoolStats['replicaSets'][replTest.name].hosts[1].addr;
-
-var priConn = replTest.getPrimary();
-var confDoc = priConn.getDB("local").system.replset.findOne();
-
-for (var idx = 0; idx < confDoc.members.length; idx++) {
- if (confDoc.members[idx].host == targetHostName) {
- confDoc.members[idx].priority = 100;
- }
- else {
- confDoc.members[idx].priority = 1;
+ "use strict";
+
+ var NODE_COUNT = 3;
+ var st = new ShardingTest({shards: {rs0: {nodes: NODE_COUNT, oplogSize: 10}}});
+ var replTest = st.rs0;
+ var mongos = st.s;
+
+ var shardDoc = mongos.getDB('config').shards.findOne();
+ assert.eq(NODE_COUNT, shardDoc.host.split(',').length); // seed list should contain all nodes
+
+ /* Make sure that the first node is not the primary (by making the second one primary).
+ * We need to do this since the ReplicaSetMonitor iterates over the nodes one
+ * by one and you can't remove a node that is currently the primary.
+ */
+ var connPoolStats = mongos.getDB('admin').runCommand({connPoolStats: 1});
+ var targetHostName = connPoolStats['replicaSets'][replTest.name].hosts[1].addr;
+
+ var priConn = replTest.getPrimary();
+ var confDoc = priConn.getDB("local").system.replset.findOne();
+
+ for (var idx = 0; idx < confDoc.members.length; idx++) {
+ if (confDoc.members[idx].host == targetHostName) {
+ confDoc.members[idx].priority = 100;
+ } else {
+ confDoc.members[idx].priority = 1;
+ }
}
-}
-confDoc.version++;
+ confDoc.version++;
-jsTest.log('Changing conf to ' + tojson(confDoc));
+ jsTest.log('Changing conf to ' + tojson(confDoc));
-try {
- priConn.getDB('admin').adminCommand({ replSetReconfig: confDoc });
-} catch (x) {
- print('Expected exception because of reconfig' + x);
-}
+ try {
+ priConn.getDB('admin').adminCommand({replSetReconfig: confDoc});
+ } catch (x) {
+ print('Expected exception because of reconfig' + x);
+ }
-ReplSetTest.awaitRSClientHosts(mongos, { host: targetHostName },
- { ok: true, ismaster: true });
+ ReplSetTest.awaitRSClientHosts(mongos, {host: targetHostName}, {ok: true, ismaster: true});
-// Remove first node from set
-confDoc.members.shift();
-confDoc.version++;
+ // Remove first node from set
+ confDoc.members.shift();
+ confDoc.version++;
-try {
- replTest.getPrimary().getDB('admin').adminCommand({ replSetReconfig: confDoc });
-} catch (x) {
- print('Expected exception because of reconfig: ' + x);
-}
+ try {
+ replTest.getPrimary().getDB('admin').adminCommand({replSetReconfig: confDoc});
+ } catch (x) {
+ print('Expected exception because of reconfig: ' + x);
+ }
-assert.soon(function() {
- var connPoolStats = mongos.getDB('admin').runCommand('connPoolStats');
- var replView = connPoolStats.replicaSets[replTest.name].hosts;
- jsTest.log('current replView: ' + tojson(replView));
+ assert.soon(function() {
+ var connPoolStats = mongos.getDB('admin').runCommand('connPoolStats');
+ var replView = connPoolStats.replicaSets[replTest.name].hosts;
+ jsTest.log('current replView: ' + tojson(replView));
- return replView.length == NODE_COUNT - 1;
-});
+ return replView.length == NODE_COUNT - 1;
+ });
-assert.soon(function() {
- shardDoc = mongos.getDB('config').shards.findOne();
- jsTest.log('shardDoc: ' + tojson(shardDoc));
- // seed list should contain one less node
- return shardDoc.host.split(',').length == NODE_COUNT - 1;
-});
+ assert.soon(function() {
+ shardDoc = mongos.getDB('config').shards.findOne();
+ jsTest.log('shardDoc: ' + tojson(shardDoc));
+ // seed list should contain one less node
+ return shardDoc.host.split(',').length == NODE_COUNT - 1;
+ });
-st.stop();
+ st.stop();
}()); \ No newline at end of file