summaryrefslogtreecommitdiff
path: root/jstests/sharding/addshard4.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/addshard4.js')
-rw-r--r--jstests/sharding/addshard4.js77
1 files changed, 39 insertions, 38 deletions
diff --git a/jstests/sharding/addshard4.js b/jstests/sharding/addshard4.js
index 2a66cbc74fe..de2c8a17c10 100644
--- a/jstests/sharding/addshard4.js
+++ b/jstests/sharding/addshard4.js
@@ -1,60 +1,61 @@
// A replica set's passive nodes should be okay to add as part of a shard config
(function() {
-var s = new ShardingTest({ name: "addshard4",
- shards: 2,
- mongos: 1,
- other: {useHostname : true} });
+ var s = new ShardingTest({name: "addshard4", shards: 2, mongos: 1, other: {useHostname: true}});
-var r = new ReplSetTest({name: "addshard4", nodes: 3});
-r.startSet();
+ var r = new ReplSetTest({name: "addshard4", nodes: 3});
+ r.startSet();
-var config = r.getReplSetConfig();
-config.members[2].priority = 0;
+ var config = r.getReplSetConfig();
+ config.members[2].priority = 0;
-r.initiate(config);
-//Wait for replica set to be fully initialized - could take some time
-//to pre-allocate files on slow systems
-r.awaitReplication();
+ r.initiate(config);
+ // Wait for replica set to be fully initialized - could take some time
+ // to pre-allocate files on slow systems
+ r.awaitReplication();
-var master = r.getPrimary();
+ var master = r.getPrimary();
-var members = config.members.map(function(elem) { return elem.host; });
-var shardName = "addshard4/"+members.join(",");
-var invalidShardName = "addshard4/foobar";
+ var members = config.members.map(function(elem) {
+ return elem.host;
+ });
+ var shardName = "addshard4/" + members.join(",");
+ var invalidShardName = "addshard4/foobar";
-print("adding shard "+shardName);
+ print("adding shard " + shardName);
-// First try adding shard with the correct replica set name but incorrect hostname
-// This will make sure that the metadata for this replica set name is cleaned up
-// so that the set can be added correctly when it has the proper hostnames.
-assert.throws(function() {s.adminCommand({"addshard" : invalidShardName});});
+ // First try adding shard with the correct replica set name but incorrect hostname
+ // This will make sure that the metadata for this replica set name is cleaned up
+ // so that the set can be added correctly when it has the proper hostnames.
+ assert.throws(function() {
+ s.adminCommand({"addshard": invalidShardName});
+ });
-var result = s.adminCommand({"addshard" : shardName});
+ var result = s.adminCommand({"addshard": shardName});
-printjson(result);
-assert.eq(result, true);
+ printjson(result);
+ assert.eq(result, true);
-r = new ReplSetTest({name : "addshard42", nodes : 3});
-r.startSet();
+ r = new ReplSetTest({name: "addshard42", nodes: 3});
+ r.startSet();
-config = r.getReplSetConfig();
-config.members[2].arbiterOnly = true;
+ config = r.getReplSetConfig();
+ config.members[2].arbiterOnly = true;
-r.initiate(config);
-// Wait for replica set to be fully initialized - could take some time
-// to pre-allocate files on slow systems
-r.awaitReplication();
+ r.initiate(config);
+ // Wait for replica set to be fully initialized - could take some time
+ // to pre-allocate files on slow systems
+ r.awaitReplication();
-master = r.getPrimary();
+ master = r.getPrimary();
-print("adding shard addshard42");
+ print("adding shard addshard42");
-result = s.adminCommand({"addshard" : "addshard42/"+config.members[2].host});
+ result = s.adminCommand({"addshard": "addshard42/" + config.members[2].host});
-printjson(result);
-assert.eq(result, true);
+ printjson(result);
+ assert.eq(result, true);
-s.stop();
+ s.stop();
})();