summaryrefslogtreecommitdiff
path: root/jstests/sharding/mongos_precache_routing_info.js
blob: 7a0f4031d88a8cc7305e06d611266a72f8f3b374 (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
47
48
49
50
51
52
53
54
55
(function() {
'use strict';

// create
var s = new ShardingTest({
    shards: 2,
    other: {
        mongosOptions:
            {setParameter: {'failpoint.skipClusterParameterRefresh': "{'mode':'alwaysOn'}"}}
    }
});
var db = s.getDB("test");
var ss = db.serverStatus();

const shardCommand = {
    shardcollection: "test.foo",
    key: {num: 1}
};

// shard
assert.commandWorked(s.s0.adminCommand({enablesharding: "test"}));
assert.commandWorked(s.s0.adminCommand(shardCommand));

// split numSplits times
const numSplits = 2;
var i;
for (i = 0; i < numSplits; i++) {
    var midKey = {num: i};
    assert.commandWorked(s.s0.adminCommand({split: "test.foo", middle: midKey}));
}

// restart mongos
s.restartMongos(0);
db = s.getDB("test");

// check for # refreshes started
ss = db.serverStatus();
assert.eq(1, ss.shardingStatistics.catalogCache.countFullRefreshesStarted);

// does not pre cache when set parameter is disabled
s.restartMongos(0, {
    restart: true,
    setParameter: {
        loadRoutingTableOnStartup: false,
        'failpoint.skipClusterParameterRefresh': "{'mode':'alwaysOn'}"
    },
});
db = s.getDB("test");

// check for # refreshes started
ss = db.serverStatus();
assert.eq(0, ss.shardingStatistics.catalogCache.countFullRefreshesStarted);

s.stop();
})();