summaryrefslogtreecommitdiff
path: root/jstests/hooks/run_check_repl_dbhash.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:42:24 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-26 18:42:24 -0400
commitc1a45ebbb0530e3d0201321d725527f1eb83ffce (patch)
treef523079dc5ded3052eefbdcaae424b7502df5b25 /jstests/hooks/run_check_repl_dbhash.js
parentc9599d8610c3da0b7c3da65667aff821063cf5b9 (diff)
downloadmongo-c1a45ebbb0530e3d0201321d725527f1eb83ffce.tar.gz
Apply formatting per `clang-format-7.0.1`
Diffstat (limited to 'jstests/hooks/run_check_repl_dbhash.js')
-rw-r--r--jstests/hooks/run_check_repl_dbhash.js155
1 files changed, 77 insertions, 78 deletions
diff --git a/jstests/hooks/run_check_repl_dbhash.js b/jstests/hooks/run_check_repl_dbhash.js
index bae3943964e..9067d4359ad 100644
--- a/jstests/hooks/run_check_repl_dbhash.js
+++ b/jstests/hooks/run_check_repl_dbhash.js
@@ -3,106 +3,105 @@
'use strict';
(function() {
- load('jstests/libs/discover_topology.js'); // For Topology and DiscoverTopology.
- load('jstests/libs/parallelTester.js'); // For ScopedThread.
+load('jstests/libs/discover_topology.js'); // For Topology and DiscoverTopology.
+load('jstests/libs/parallelTester.js'); // For ScopedThread.
- function checkReplicatedDataHashesThread(hosts) {
- load('jstests/libs/override_methods/implicitly_retry_on_background_op_in_progress.js');
+function checkReplicatedDataHashesThread(hosts) {
+ load('jstests/libs/override_methods/implicitly_retry_on_background_op_in_progress.js');
- try {
- const excludedDBs = jsTest.options().excludedDBsFromDBHash;
- const rst = new ReplSetTest(hosts[0]);
- rst.checkReplicatedDataHashes(undefined, excludedDBs);
- if (TestData.checkCollectionCounts) {
- rst.checkCollectionCounts();
- }
- return {ok: 1};
- } catch (e) {
- return {ok: 0, hosts: hosts, error: e.toString(), stack: e.stack};
+ try {
+ const excludedDBs = jsTest.options().excludedDBsFromDBHash;
+ const rst = new ReplSetTest(hosts[0]);
+ rst.checkReplicatedDataHashes(undefined, excludedDBs);
+ if (TestData.checkCollectionCounts) {
+ rst.checkCollectionCounts();
}
+ return {ok: 1};
+ } catch (e) {
+ return {ok: 0, hosts: hosts, error: e.toString(), stack: e.stack};
}
+}
- const startTime = Date.now();
- assert.neq(typeof db, 'undefined', 'No `db` object, is the shell connected to a mongod?');
+const startTime = Date.now();
+assert.neq(typeof db, 'undefined', 'No `db` object, is the shell connected to a mongod?');
- let skipped = false;
- try {
- const conn = db.getMongo();
- const topology = DiscoverTopology.findConnectedNodes(conn);
+let skipped = false;
+try {
+ const conn = db.getMongo();
+ const topology = DiscoverTopology.findConnectedNodes(conn);
- if (topology.type === Topology.kStandalone) {
+ if (topology.type === Topology.kStandalone) {
+ print('Skipping data consistency checks for cluster because we are connected to a' +
+ ' stand-alone mongod: ' + tojsononeline(topology));
+ skipped = true;
+ return;
+ }
+
+ if (topology.type === Topology.kReplicaSet) {
+ if (topology.nodes.length === 1) {
print('Skipping data consistency checks for cluster because we are connected to a' +
- ' stand-alone mongod: ' + tojsononeline(topology));
+ ' 1-node replica set: ' + tojsononeline(topology));
skipped = true;
return;
}
- if (topology.type === Topology.kReplicaSet) {
- if (topology.nodes.length === 1) {
- print('Skipping data consistency checks for cluster because we are connected to a' +
- ' 1-node replica set: ' + tojsononeline(topology));
- skipped = true;
- return;
- }
+ const excludedDBs = jsTest.options().excludedDBsFromDBHash;
+ new ReplSetTest(topology.nodes[0]).checkReplicatedDataHashes(undefined, excludedDBs);
+ return;
+ }
- const excludedDBs = jsTest.options().excludedDBsFromDBHash;
- new ReplSetTest(topology.nodes[0]).checkReplicatedDataHashes(undefined, excludedDBs);
- return;
- }
+ if (topology.type !== Topology.kShardedCluster) {
+ throw new Error('Unrecognized topology format: ' + tojson(topology));
+ }
- if (topology.type !== Topology.kShardedCluster) {
- throw new Error('Unrecognized topology format: ' + tojson(topology));
+ const threads = [];
+ try {
+ if (topology.configsvr.nodes.length > 1) {
+ const thread =
+ new ScopedThread(checkReplicatedDataHashesThread, topology.configsvr.nodes);
+ threads.push(thread);
+ thread.start();
+ } else {
+ print('Skipping data consistency checks for 1-node CSRS: ' + tojsononeline(topology));
}
- const threads = [];
- try {
- if (topology.configsvr.nodes.length > 1) {
- const thread =
- new ScopedThread(checkReplicatedDataHashesThread, topology.configsvr.nodes);
- threads.push(thread);
- thread.start();
- } else {
- print('Skipping data consistency checks for 1-node CSRS: ' +
+ for (let shardName of Object.keys(topology.shards)) {
+ const shard = topology.shards[shardName];
+
+ if (shard.type === Topology.kStandalone) {
+ print('Skipping data consistency checks for stand-alone shard: ' +
tojsononeline(topology));
+ continue;
}
- for (let shardName of Object.keys(topology.shards)) {
- const shard = topology.shards[shardName];
-
- if (shard.type === Topology.kStandalone) {
- print('Skipping data consistency checks for stand-alone shard: ' +
- tojsononeline(topology));
- continue;
- }
-
- if (shard.type !== Topology.kReplicaSet) {
- throw new Error('Unrecognized topology format: ' + tojson(topology));
- }
-
- if (shard.nodes.length > 1) {
- const thread = new ScopedThread(checkReplicatedDataHashesThread, shard.nodes);
- threads.push(thread);
- thread.start();
- } else {
- print('Skipping data consistency checks for 1-node replica set shard: ' +
- tojsononeline(topology));
- }
+ if (shard.type !== Topology.kReplicaSet) {
+ throw new Error('Unrecognized topology format: ' + tojson(topology));
}
- } finally {
- // Wait for each thread to finish. Throw an error if any thread fails.
- const returnData = threads.map(thread => {
- thread.join();
- return thread.returnData();
- });
- returnData.forEach(res => {
- assert.commandWorked(res, 'data consistency checks failed');
- });
+ if (shard.nodes.length > 1) {
+ const thread = new ScopedThread(checkReplicatedDataHashesThread, shard.nodes);
+ threads.push(thread);
+ thread.start();
+ } else {
+ print('Skipping data consistency checks for 1-node replica set shard: ' +
+ tojsononeline(topology));
+ }
}
} finally {
- if (!skipped) {
- const totalTime = Date.now() - startTime;
- print('Finished data consistency checks for cluster in ' + totalTime + ' ms.');
- }
+ // Wait for each thread to finish. Throw an error if any thread fails.
+ const returnData = threads.map(thread => {
+ thread.join();
+ return thread.returnData();
+ });
+
+ returnData.forEach(res => {
+ assert.commandWorked(res, 'data consistency checks failed');
+ });
+ }
+} finally {
+ if (!skipped) {
+ const totalTime = Date.now() - startTime;
+ print('Finished data consistency checks for cluster in ' + totalTime + ' ms.');
}
+}
})();