-
Notifications
You must be signed in to change notification settings - Fork 5.6k
/
Copy pathrun_cleanup_hello_failures.js
31 lines (26 loc) · 1.33 KB
/
run_cleanup_hello_failures.js
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
import {DiscoverTopology, Topology} from "jstests/libs/discover_topology.js";
import {FixtureHelpers} from "jstests/libs/fixture_helpers.js";
function cleanupHelloFailInjection(connection) {
jsTestLog(`Cleanup Hello fail injection in ${connection}`);
let adminDB = connection.getDB('admin');
assert.commandWorked(adminDB.runCommand({configureFailPoint: "shardWaitInHello", mode: "off"}));
const res = assert.commandWorked(
adminDB.runCommand({getParameter: 1, "failpoint.shardWaitInHello": 1}));
assert.eq(res[`failpoint.shardWaitInHello`].mode, 0);
}
function doFailInjectionCleanup(db) {
let connectionsToPrimaries = FixtureHelpers.getPrimaries(db);
for (let connection of connectionsToPrimaries.concat(FixtureHelpers.getSecondaries(db))) {
cleanupHelloFailInjection(connection);
}
}
assert.eq(typeof db, 'object', 'Invalid `db` object, is the shell connected to a mongod?');
var cmdLineOpts = db.adminCommand('getCmdLineOpts');
const topology = DiscoverTopology.findConnectedNodes(db.getMongo());
jsTestLog(`Run Hello test suite cleanup in ${JSON.stringify(topology)},
Invoked with ${JSON.stringify(cmdLineOpts)},
topology type ${topology.type}`);
if (topology.type === Topology.kShardedCluster) {
doFailInjectionCleanup(db);
}
jsTestLog(`Hello fail hook completed`);