summaryrefslogtreecommitdiff
path: root/jstests/hooks/run_check_routing_table_consistency.js
blob: 305ac9550bc2885954925a184742187ad9635a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict';

(function() {
load('jstests/libs/check_routing_table_consistency_helpers.js');  // For check implementation.
load('jstests/libs/discover_topology.js');  // For Topology and DiscoverTopology.

assert.neq(typeof db, 'undefined', 'No `db` object, is the shell connected to a server?');

const conn = db.getMongo();
const topology = DiscoverTopology.findConnectedNodes(conn);

if (topology.type !== Topology.kShardedCluster) {
    throw new Error(
        'Routing table consistency check must be run against a sharded cluster, but got: ' +
        tojson(topology));
}
RoutingTableConsistencyChecker.run(db.getMongo());
})();