From 75f2d53c1f0667e9b5cfab2ecfe71e22f1d6742d Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Tue, 13 Sep 2011 18:54:38 -0400 Subject: Prevent removeShard command from putting cluster into bad state SERVER-3318 --- jstests/sharding/remove1.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'jstests/sharding/remove1.js') diff --git a/jstests/sharding/remove1.js b/jstests/sharding/remove1.js index 9593bdf9acd..facc24e467a 100644 --- a/jstests/sharding/remove1.js +++ b/jstests/sharding/remove1.js @@ -4,13 +4,16 @@ assert.eq( 2, s.config.shards.count() , "initial server count wrong" ); // first remove puts in draining mode, the second actually removes assert( s.admin.runCommand( { removeshard: "shard0000" } ).ok , "failed to start draining shard" ); +assert( !s.admin.runCommand( { removeshard: "shard0001" } ).ok , "allowed two draining shards" ); assert( s.admin.runCommand( { removeshard: "shard0000" } ).ok , "failed to remove shard" ); assert.eq( 1, s.config.shards.count() , "removed server still appears in count" ); +assert( !s.admin.runCommand( { removeshard: "shard0001" } ).ok , "allowed removing last shard" ); + // should create a shard0002 shard conn = startMongodTest( 29000 ); assert( s.admin.runCommand( { addshard: "localhost:29000" } ).ok, "failed to add shard" ); assert.eq( 2, s.config.shards.count(), "new server does not appear in count" ); stopMongod( 29000 ); -s.stop(); \ No newline at end of file +s.stop(); -- cgit v1.2.1