Files
mongo/jstests/sharding/libs/cluster_cardinality_parameter_util.js
Catalin Sumanaru de97aac8f6 SERVER-91379 Re-introduce eslint rule for missing semicolons (#23301)
GitOrigin-RevId: fd9cce5f9f201004e44ffdeabdb33cd93e79b451
2024-06-11 14:18:29 +00:00

39 lines
1.4 KiB
JavaScript

/**
* Tests that the cluster parameter "shardedClusterCardinalityForDirectConns" on the given replica
* set has the expected value.
*/
export function checkClusterParameter(rst, expectedValue) {
let res = assert.commandWorked(rst.getPrimary().adminCommand(
{getClusterParameter: "shardedClusterCardinalityForDirectConns"}));
assert.eq(res.clusterParameters[0].hasTwoOrMoreShards, expectedValue);
}
/**
* Interrupts the commands with the given names if they are running on the given node.
*/
export function interruptAdminCommand(node, cmdNames) {
const adminDB = node.getDB("admin");
const cmdNameFilter = [];
cmdNames.forEach(cmdName => {
cmdNameFilter.push({["command." + cmdName]: {$exists: true}});
});
const results =
adminDB
.aggregate([{$currentOp: {}}, {$match: {$or: cmdNameFilter}}],
{$readPreference: {mode: "primaryPreferred"}}) // specify secondary ok.
.toArray();
results.forEach(result => {
adminDB.killOp(result.opid);
});
}
export function interruptConfigsvrAddShard(configPrimary) {
interruptAdminCommand(configPrimary,
["_configsvrAddShard", "_configsvrTransitionToDedicatedConfigServer"]);
}
export function interruptConfigsvrRemoveShard(configPrimary) {
interruptAdminCommand(configPrimary,
["_configsvrRemoveShard", "_configsvrTransitionToDedicatedConfigServer"]);
}