0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 00:17:37 +01:00
mongodb/jstests/sharding/balancer_shell_commands.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

26 lines
768 B
JavaScript

/**
* Test shell balancer commands.
* sh.setBalancerState
* sh.getBalancerState
*/
import {ShardingTest} from "jstests/libs/shardingtest.js";
var shardingTest =
new ShardingTest({name: "shell_commands", shards: 1, mongos: 1, other: {enableBalancer: true}});
// `sh` test runner commands assume the presence of a global `db` object
globalThis.db = shardingTest.getDB("test");
assert(sh.getBalancerState(), "Balancer should have been enabled during cluster setup");
// Test that the balancer can be disabled
sh.setBalancerState(false);
assert(!sh.getBalancerState(), "Failed to disable balancer");
// Test that the balancer can be re-enabled
sh.setBalancerState(true);
assert(sh.getBalancerState(), "Failed to re-enable balancer");
shardingTest.stop();