summaryrefslogtreecommitdiff
path: root/jstests/hooks/run_validate_collections.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/hooks/run_validate_collections.js')
-rw-r--r--jstests/hooks/run_validate_collections.js67
1 files changed, 33 insertions, 34 deletions
diff --git a/jstests/hooks/run_validate_collections.js b/jstests/hooks/run_validate_collections.js
index 171e3cd7c00..eeabba7e10e 100644
--- a/jstests/hooks/run_validate_collections.js
+++ b/jstests/hooks/run_validate_collections.js
@@ -3,41 +3,40 @@
'use strict';
(function() {
- load('jstests/libs/discover_topology.js'); // For Topology and DiscoverTopology.
- load('jstests/hooks/validate_collections.js'); // For CollectionValidator.
-
- assert.eq(typeof db, 'object', 'Invalid `db` object, is the shell connected to a mongod?');
- const topology = DiscoverTopology.findConnectedNodes(db.getMongo());
-
- const hostList = [];
- let setFCVHost;
-
- if (topology.type === Topology.kStandalone) {
- hostList.push(topology.mongod);
- setFCVHost = topology.mongod;
- } else if (topology.type === Topology.kReplicaSet) {
- hostList.push(...topology.nodes);
- setFCVHost = topology.primary;
- } else if (topology.type === Topology.kShardedCluster) {
- hostList.push(...topology.configsvr.nodes);
-
- for (let shardName of Object.keys(topology.shards)) {
- const shard = topology.shards[shardName];
-
- if (shard.type === Topology.kStandalone) {
- hostList.push(shard.mongod);
- } else if (shard.type === Topology.kReplicaSet) {
- hostList.push(...shard.nodes);
- } else {
- throw new Error('Unrecognized topology format: ' + tojson(topology));
- }
+load('jstests/libs/discover_topology.js'); // For Topology and DiscoverTopology.
+load('jstests/hooks/validate_collections.js'); // For CollectionValidator.
+
+assert.eq(typeof db, 'object', 'Invalid `db` object, is the shell connected to a mongod?');
+const topology = DiscoverTopology.findConnectedNodes(db.getMongo());
+
+const hostList = [];
+let setFCVHost;
+
+if (topology.type === Topology.kStandalone) {
+ hostList.push(topology.mongod);
+ setFCVHost = topology.mongod;
+} else if (topology.type === Topology.kReplicaSet) {
+ hostList.push(...topology.nodes);
+ setFCVHost = topology.primary;
+} else if (topology.type === Topology.kShardedCluster) {
+ hostList.push(...topology.configsvr.nodes);
+
+ for (let shardName of Object.keys(topology.shards)) {
+ const shard = topology.shards[shardName];
+
+ if (shard.type === Topology.kStandalone) {
+ hostList.push(shard.mongod);
+ } else if (shard.type === Topology.kReplicaSet) {
+ hostList.push(...shard.nodes);
+ } else {
+ throw new Error('Unrecognized topology format: ' + tojson(topology));
}
- // Any of the mongos instances can be used for setting FCV.
- setFCVHost = topology.mongos.nodes[0];
- } else {
- throw new Error('Unrecognized topology format: ' + tojson(topology));
}
+ // Any of the mongos instances can be used for setting FCV.
+ setFCVHost = topology.mongos.nodes[0];
+} else {
+ throw new Error('Unrecognized topology format: ' + tojson(topology));
+}
- new CollectionValidator().validateNodes(hostList, setFCVHost);
-
+new CollectionValidator().validateNodes(hostList, setFCVHost);
})();