summaryrefslogtreecommitdiff
path: root/jstests/sharding/mongos_no_replica_set_refresh.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/sharding/mongos_no_replica_set_refresh.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/sharding/mongos_no_replica_set_refresh.js')
-rw-r--r--jstests/sharding/mongos_no_replica_set_refresh.js222
1 files changed, 109 insertions, 113 deletions
diff --git a/jstests/sharding/mongos_no_replica_set_refresh.js b/jstests/sharding/mongos_no_replica_set_refresh.js
index c6a8a1e05b0..b9080f950fc 100644
--- a/jstests/sharding/mongos_no_replica_set_refresh.js
+++ b/jstests/sharding/mongos_no_replica_set_refresh.js
@@ -2,136 +2,132 @@
load("jstests/replsets/rslib.js");
(function() {
- 'use strict';
-
- var five_minutes = 5 * 60 * 1000;
-
- var numRSHosts = function() {
- var result = assert.commandWorked(rsObj.nodes[0].adminCommand({ismaster: 1}));
- return result.hosts.length + result.passives.length;
- };
-
- var numMongosHosts = function() {
- var commandResult = assert.commandWorked(mongos.adminCommand("connPoolStats"));
- var result = commandResult.replicaSets[rsObj.name];
- return result.hosts.length;
- };
-
- var configServerURL = function() {
- var result = config.shards.find().toArray()[0];
- return result.host;
- };
-
- var checkNumHosts = function(expectedNumHosts) {
- jsTest.log("Waiting for the shard to discover that it now has " + expectedNumHosts +
- " hosts.");
- var numHostsSeenByShard;
-
- // Use a high timeout (5 minutes) because replica set refreshes are only done every 30
- // seconds.
- assert.soon(
- function() {
- numHostsSeenByShard = numRSHosts();
- return numHostsSeenByShard === expectedNumHosts;
- },
- function() {
- return ("Expected shard to see " + expectedNumHosts + " hosts but found " +
- numHostsSeenByShard);
- },
- five_minutes);
-
- jsTest.log("Waiting for the mongos to discover that the shard now has " + expectedNumHosts +
- " hosts.");
- var numHostsSeenByMongos;
-
- // Use a high timeout (5 minutes) because replica set refreshes are only done every 30
- // seconds.
- assert.soon(
- function() {
- numHostsSeenByMongos = numMongosHosts();
- return numHostsSeenByMongos === expectedNumHosts;
- },
- function() {
- return ("Expected mongos to see " + expectedNumHosts +
- " hosts on shard but found " + numHostsSeenByMongos);
- },
- five_minutes);
- };
-
- var st = new ShardingTest({
- name: 'mongos_no_replica_set_refresh',
- shards: 1,
- mongos: 1,
- other: {
- rs0: {
- nodes: [
- {},
- {rsConfig: {priority: 0}},
- {rsConfig: {priority: 0}},
- ],
- }
- }
- });
-
- var rsObj = st.rs0;
- assert.commandWorked(rsObj.nodes[0].adminCommand({
- replSetTest: 1,
- waitForMemberState: ReplSetTest.State.PRIMARY,
- timeoutMillis: 60 * 1000,
- }),
- 'node 0 ' + rsObj.nodes[0].host + ' failed to become primary');
+'use strict';
- var mongos = st.s;
- var config = mongos.getDB("config");
+var five_minutes = 5 * 60 * 1000;
- printjson(mongos.getCollection("foo.bar").findOne());
+var numRSHosts = function() {
+ var result = assert.commandWorked(rsObj.nodes[0].adminCommand({ismaster: 1}));
+ return result.hosts.length + result.passives.length;
+};
- jsTestLog("Removing a node from the shard's replica set.");
+var numMongosHosts = function() {
+ var commandResult = assert.commandWorked(mongos.adminCommand("connPoolStats"));
+ var result = commandResult.replicaSets[rsObj.name];
+ return result.hosts.length;
+};
- var rsConfig = rsObj.getReplSetConfigFromNode(0);
+var configServerURL = function() {
+ var result = config.shards.find().toArray()[0];
+ return result.host;
+};
- var removedNode = rsConfig.members.pop();
- rsConfig.version++;
- reconfig(rsObj, rsConfig);
+var checkNumHosts = function(expectedNumHosts) {
+ jsTest.log("Waiting for the shard to discover that it now has " + expectedNumHosts + " hosts.");
+ var numHostsSeenByShard;
- // Wait for the election round to complete
- rsObj.getPrimary();
+ // Use a high timeout (5 minutes) because replica set refreshes are only done every 30
+ // seconds.
+ assert.soon(
+ function() {
+ numHostsSeenByShard = numRSHosts();
+ return numHostsSeenByShard === expectedNumHosts;
+ },
+ function() {
+ return ("Expected shard to see " + expectedNumHosts + " hosts but found " +
+ numHostsSeenByShard);
+ },
+ five_minutes);
- checkNumHosts(rsConfig.members.length);
+ jsTest.log("Waiting for the mongos to discover that the shard now has " + expectedNumHosts +
+ " hosts.");
+ var numHostsSeenByMongos;
- jsTest.log("Waiting for config.shards to reflect that " + removedNode.host +
- " has been removed.");
+ // Use a high timeout (5 minutes) because replica set refreshes are only done every 30
+ // seconds.
assert.soon(
function() {
- return configServerURL().indexOf(removedNode.host) < 0;
+ numHostsSeenByMongos = numMongosHosts();
+ return numHostsSeenByMongos === expectedNumHosts;
},
function() {
- return (removedNode.host + " was removed from " + rsObj.name +
- ", but is still seen in config.shards");
- });
+ return ("Expected mongos to see " + expectedNumHosts + " hosts on shard but found " +
+ numHostsSeenByMongos);
+ },
+ five_minutes);
+};
+
+var st = new ShardingTest({
+ name: 'mongos_no_replica_set_refresh',
+ shards: 1,
+ mongos: 1,
+ other: {
+ rs0: {
+ nodes: [
+ {},
+ {rsConfig: {priority: 0}},
+ {rsConfig: {priority: 0}},
+ ],
+ }
+ }
+});
- jsTestLog("Adding the node back to the shard's replica set.");
+var rsObj = st.rs0;
+assert.commandWorked(rsObj.nodes[0].adminCommand({
+ replSetTest: 1,
+ waitForMemberState: ReplSetTest.State.PRIMARY,
+ timeoutMillis: 60 * 1000,
+}),
+ 'node 0 ' + rsObj.nodes[0].host + ' failed to become primary');
- config.shards.update({_id: rsObj.name}, {$set: {host: rsObj.name + "/" + rsObj.nodes[0].host}});
- printjson(config.shards.find().toArray());
+var mongos = st.s;
+var config = mongos.getDB("config");
- rsConfig.members.push(removedNode);
- rsConfig.version++;
- reconfig(rsObj, rsConfig);
+printjson(mongos.getCollection("foo.bar").findOne());
- checkNumHosts(rsConfig.members.length);
+jsTestLog("Removing a node from the shard's replica set.");
- jsTest.log("Waiting for config.shards to reflect that " + removedNode.host +
- " has been re-added.");
- assert.soon(
- function() {
- return configServerURL().indexOf(removedNode.host) >= 0;
- },
- function() {
- return (removedNode.host + " was re-added to " + rsObj.name +
- ", but is not seen in config.shards");
- });
+var rsConfig = rsObj.getReplSetConfigFromNode(0);
+
+var removedNode = rsConfig.members.pop();
+rsConfig.version++;
+reconfig(rsObj, rsConfig);
+
+// Wait for the election round to complete
+rsObj.getPrimary();
+
+checkNumHosts(rsConfig.members.length);
+
+jsTest.log("Waiting for config.shards to reflect that " + removedNode.host + " has been removed.");
+assert.soon(
+ function() {
+ return configServerURL().indexOf(removedNode.host) < 0;
+ },
+ function() {
+ return (removedNode.host + " was removed from " + rsObj.name +
+ ", but is still seen in config.shards");
+ });
+
+jsTestLog("Adding the node back to the shard's replica set.");
+
+config.shards.update({_id: rsObj.name}, {$set: {host: rsObj.name + "/" + rsObj.nodes[0].host}});
+printjson(config.shards.find().toArray());
- st.stop();
+rsConfig.members.push(removedNode);
+rsConfig.version++;
+reconfig(rsObj, rsConfig);
+
+checkNumHosts(rsConfig.members.length);
+
+jsTest.log("Waiting for config.shards to reflect that " + removedNode.host + " has been re-added.");
+assert.soon(
+ function() {
+ return configServerURL().indexOf(removedNode.host) >= 0;
+ },
+ function() {
+ return (removedNode.host + " was re-added to " + rsObj.name +
+ ", but is not seen in config.shards");
+ });
+st.stop();
}());