summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/shard_does_not_hang_on_bad_config_server.js
blob: c7260e449485381b57b9383cbc51e685a499ee1e (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
(function() {
    'use strict';

    var conn = MongoRunner.runMongod();

    var res;

    var connA = new Mongo(conn.host);
    res = assert.commandFailed(connA.adminCommand({
        moveChunk: 'DummyDB.DummyColl',
        configdb: 'localhost:1',
        fromShard: 'DummyFromShard',
        toShard: 'DummyToShard',
        min: {Key: -1},
        max: {Key: 1},
        maxChunkSizeBytes: 1024,
        maxTimeMS: 10000
    }));
    assert.eq(ErrorCodes.ExceededTimeLimit, res.code);

    // Sharding state is now initialized at this point, although with an unreachable config.

    var connB = new Mongo(conn.host);
    res = assert.commandFailed(connB.adminCommand({
        moveChunk: 'DummyDB.DummyColl',
        configdb: 'localhost:1',
        fromShard: 'DummyFromShard',
        toShard: 'DummyToShard',
        min: {Key: -1},
        max: {Key: 1},
        maxChunkSizeBytes: 1024,
        maxTimeMS: 10000
    }));

    // Cannot reach config server.
    assert(res.code == ErrorCodes.HostUnreachable || res.code == ErrorCodes.ExceededTimeLimit,
           'Result was: ' + tojson(res));
    MongoRunner.stopMongod(conn);

})();