summaryrefslogtreecommitdiff
path: root/jstests/sharding/balancer_shell_commands.js
blob: 611a0db85d135c6a88717b22de0818934f973e93 (plain)
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
32
33
34
35
/**
 * Test shell balancer commands.
 *  sh.setBalancerState
 *  sh.getBalancerState
 *
 *  @tags: [
 *   # SERVER-54796 sh.enableAutoSplit() writes to the config server
 *   # through mongos that doesn't support retries to config server
 *   does_not_support_stepdowns,
 * ]
 */

var db;

(function() {
"use strict";
var shardingTest =
    new ShardingTest({name: "shell_commands", shards: 1, mongos: 1, other: {enableBalancer: true}});
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");

sh.enableAutoSplit();
assert(!sh.getBalancerState(), "Autosplit-only should not classify the balancer as enabled");

// Test that the balancer can be re-enabled
sh.setBalancerState(true);
assert(sh.getBalancerState(), "Failed to re-enable balancer");

shardingTest.stop();
})();