summaryrefslogtreecommitdiff
path: root/jstests/sharding/diffservers1.js
blob: 3c9499b73aaf21c5526a80c1e31198ace5a04d76 (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
(function() {
'use strict';

var s = new ShardingTest({shards: 2});

assert.eq(2, s.config.shards.count(), "server count wrong");

var test1 = s.getDB("test1").foo;
assert.commandWorked(test1.insert({a: 1}));
assert.commandWorked(test1.insert({a: 2}));
assert.commandWorked(test1.insert({a: 3}));
assert.eq(3, test1.count());

assert.commandFailed(s.s0.adminCommand({addshard: "sdd$%", maxTimeMS: 60000}), "Bad hostname");

var portWithoutHostRunning = allocatePort();
assert.commandFailed(
    s.s0.adminCommand({addshard: "127.0.0.1:" + portWithoutHostRunning, maxTimeMS: 60000}),
    "Host which is not up");
assert.commandFailed(
    s.s0.adminCommand({addshard: "10.0.0.1:" + portWithoutHostRunning, maxTimeMS: 60000}),
    "Allowed shard in IP when config is localhost");

s.stop();
})();