summaryrefslogtreecommitdiff
path: root/jstests/sharding/addshard4.js
blob: 4a44b5537b2edb6ed669cea52a43c97d800baf67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// a replica set's passive nodes should be okay to add as part of a shard config

s = new ShardingTest( "addshard4", 2 , 0 , 1 , {useHostname : true});

r = new ReplSetTest({name : "addshard4", nodes : 3, startPort : 31100});
r.startSet();

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();

var master = r.getMaster();

var members = config.members.map(function(elem) { return elem.host; });
var shardName = "addshard4/"+members.join(",");

print("adding shard "+shardName);

var result = s.adminCommand({"addshard" : shardName});

printjson(result);
assert.eq(result, true);

r = new ReplSetTest({name : "addshard42", nodes : 3, startPort : 31200});
r.startSet();

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();

master = r.getMaster();

print("adding shard addshard42");

result = s.adminCommand({"addshard" : "addshard42/"+config.members[2].host});

printjson(result);
assert.eq(result, true);