summaryrefslogtreecommitdiff
path: root/jstests/sharding/diffservers1.js
blob: 0dbfa0b9502128221cbeec746a99c3e5d35e5538 (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.writeOK(test1.insert({a: 1}));
    assert.writeOK(test1.insert({a: 2}));
    assert.writeOK(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();
})();