File: remove1.js

package info (click to toggle)
mongodb 1%3A2.4.10-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,464 kB
  • sloc: cpp: 740,225; ansic: 152,098; sh: 13,820; python: 11,864; makefile: 1,012; perl: 922; pascal: 617; java: 452; lisp: 222; asm: 174
file content (27 lines) | stat: -rw-r--r-- 1,418 bytes parent folder | download | duplicates (3)
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
s = new ShardingTest( "remove_shard1", 2 );

assert.eq( 2, s.config.shards.count() , "initial server count wrong" );

s.config.databases.insert({_id: 'local', partitioned: false, primary: 'shard0000'});
s.config.databases.insert({_id: 'needToMove', partitioned: false, primary: 'shard0000'});
s.config.getLastError();

// first remove puts in draining mode, the second tells me a db needs to move, the third 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.eq( s.admin.runCommand( { removeshard: "shard0000" } ).dbsToMove, ['needToMove'] , "didn't show db to move" );
s.getDB('needToMove').dropDatabase();
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" );

assert.isnull( s.config.databases.findOne({_id: 'local'}), 'should have removed local db');

// 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();