summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2016-12-06 10:25:37 -0500
committerMisha Tyulenev <misha@mongodb.com>2016-12-06 10:25:37 -0500
commit9e2b483d013bc2c1f199010f720780d8db7f9c66 (patch)
tree3726b2d1692b0ef16ac30482ef1de4dc50788950 /jstests
parent350506d115d277d3a8c3559c603ae3d119a2746b (diff)
downloadmongo-9e2b483d013bc2c1f199010f720780d8db7f9c66.tar.gz
SERVER-26283 add tests for balancer shell commands
Diffstat (limited to 'jstests')
-rw-r--r--jstests/sharding/balancer_shell_commands.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/sharding/balancer_shell_commands.js b/jstests/sharding/balancer_shell_commands.js
new file mode 100644
index 00000000000..13bb89335f6
--- /dev/null
+++ b/jstests/sharding/balancer_shell_commands.js
@@ -0,0 +1,33 @@
+/**
+ * Test shell balancer commands.
+ * sh.setBalancerState
+ * sh.getBalancerLockDetails
+ * sh.getBalancerState
+ */
+
+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 and the balancer lock is still locked.
+ sh.setBalancerState(false);
+ var lock = sh.getBalancerLockDetails();
+ assert.eq("balancer", lock._id);
+ assert.eq(2, lock.state);
+ assert(!sh.getBalancerState(), "Failed to disable balancer");
+
+ // Test that the balancer can be enabled and the balancer lock is still locked.
+ sh.setBalancerState(true);
+ lock = sh.getBalancerLockDetails();
+ assert.eq("balancer", lock._id);
+ assert.eq(2, lock.state);
+ assert(sh.getBalancerState(), "Failed to enable balancer");
+
+ shardingTest.stop();
+})();