Skip to content

Commit

Permalink
SERVER-7376 test fixes for 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Studer committed Oct 17, 2012
1 parent 3e4f2ab commit 34107e2
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 24 deletions.
4 changes: 2 additions & 2 deletions jstests/sharding/addshard5.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ coll.insert({ hello : "world" })
assert.eq( null, coll.getDB().getLastError() )

// Migrate the collection to and from shard2 so shard1 loads the shard2 host
printjson( admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[1]._id }) )
printjson( admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[0]._id }) )
printjson( admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[1]._id, _waitForDelete : true }) )
printjson( admin.runCommand({ moveChunk : coll + "", find : { _id : 0 }, to : shards[0]._id, _waitForDelete : true }) )

//
// Drop and re-add shard with last shard's host
Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/count1.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ assert.eq( 6 , db.foo.find().count() , "basic count after split " );
assert.eq( 6 , db.foo.find().sort( { name : 1 } ).count() , "basic count after split sorted " );

// part 4
s.adminCommand( { movechunk : "test.foo" , find : { name : "allan" } , to : secondary.getMongo().name } );
s.adminCommand( { movechunk : "test.foo" , find : { name : "allan" } , to : secondary.getMongo().name , _waitForDelete : true } );

assert.eq( 3 , primary.foo.find().toArray().length , "primary count" );
assert.eq( 3 , secondary.foo.find().toArray().length , "secondary count" );
Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/count2.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ assert.eq( 3, db2.count( { name : { $gte: "aaa" , $lt: "ddd" } } ) , "initial co

s1.printChunks( "test.foo" )

s1.adminCommand( { movechunk : "test.foo" , find : { name : "aaa" } , to : s1.getOther( s1.getServer( "test" ) ).name } );
s1.adminCommand( { movechunk : "test.foo" , find : { name : "aaa" } , to : s1.getOther( s1.getServer( "test" ) ).name, _waitForDelete : true });

assert.eq( 3, db1.count( { name : { $gte: "aaa" , $lt: "ddd" } } ) , "post count mongos1" );

Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/error1.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ db.foo2.save( { _id : 3 , num : 15 } );
db.foo2.save( { _id : 4 , num : 20 } );

s.adminCommand( { split : "test.foo2" , middle : { num : 10 } } );
s.adminCommand( { movechunk : "test.foo2" , find : { num : 20 } , to : s.getOther( s.getServer( "test" ) ).name } );
s.adminCommand( { movechunk : "test.foo2" , find : { num : 20 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } );

print( "a: " + a.foo2.count() );
print( "b: " + b.foo2.count() );
Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/geo_near_random2.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.insertPts(5000);
for (var i = (test.nPts/10); i < test.nPts; i+= (test.nPts/10)){
s.adminCommand({split: ('test.' + testName), middle: {_id: i} });
try {
s.adminCommand({moveChunk: ('test.' + testName), find: {_id: i-1}, to: ('shard000' + (i%3))});
s.adminCommand({moveChunk: ('test.' + testName), find: {_id: i-1}, to: ('shard000' + (i%3)), _waitForDelete : true });
} catch (e) {
// ignore this error
if (! e.match(/that chunk is already on that shard/)){
Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/key_many.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ for ( var i=0; i<types.length; i++ ){
s.adminCommand( { split : longName , find : makeObjectDotted( curT.values[3] ) } );
s.adminCommand( { split : longName , find : makeObjectDotted( curT.values[3] ) } );

s.adminCommand( { movechunk : longName , find : makeObjectDotted( curT.values[0] ) , to : secondary.getMongo().name } );
s.adminCommand( { movechunk : longName , find : makeObjectDotted( curT.values[0] ) , to : secondary.getMongo().name, _waitForDelete : true } );

s.printChunks();

Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/key_string.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ s.adminCommand( { split : "test.foo" , find : { name : "joe" } } ); // [Minkey -
s.adminCommand( { split : "test.foo" , find : { name : "joe" } } ); // * [allan -> sara) , [sara -> Maxkey)
s.adminCommand( { split : "test.foo" , find : { name : "joe" } } ); // [alan -> joe) , [joe -> sara]

s.adminCommand( { movechunk : "test.foo" , find : { name : "allan" } , to : seconday.getMongo().name } );
s.adminCommand( { movechunk : "test.foo" , find : { name : "allan" } , to : seconday.getMongo().name, _waitForDelete : true } );

s.printChunks();

Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/limit_push.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ s.adminCommand( { shardcollection : "test.limit_push" , key : { x : 1 } } );

// Now split the and move the data between the shards
s.adminCommand( { split : "test.limit_push", middle : { x : 50 }} );
s.adminCommand( { moveChunk: "test.limit_push", find : { x : 51}, to : "shard0000" })
s.adminCommand( { moveChunk: "test.limit_push", find : { x : 51}, to : "shard0000", _waitForDelete : true })

// Check that the chunck have split correctly
assert.eq( 2 , s.config.chunks.count() , "wrong number of chunks");
Expand Down
4 changes: 2 additions & 2 deletions jstests/sharding/multi_mongos1.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ s1.adminCommand( { split : "test.foo" , middle : { num : 1 } } );
s1.adminCommand( { split : "test.foo" , middle : { num : N } } );

// s2 is now stale w.r.t boundaires around { num: 1 }
res = s2.getDB( "admin" ).runCommand( { movechunk : "test.foo" , find : { num : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name } );
res = s2.getDB( "admin" ).runCommand( { movechunk : "test.foo" , find : { num : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name, _waitForDelete : true } );
assert.eq( 0 , res.ok , "a move with stale boundaries should not have succeeded" + tojson(res) );

// s2 must have reloaded as a result of a failed move; retrying should work
res = s2.getDB( "admin" ).runCommand( { movechunk : "test.foo" , find : { num : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name } );
res = s2.getDB( "admin" ).runCommand( { movechunk : "test.foo" , find : { num : 1 } , to : s1.getOther( s1.getServer( "test" ) ).name, _waitForDelete : true } );
assert.eq( 1 , res.ok , "mongos did not reload after a failed migrate" + tojson(res) );

// s1 is not stale about the boundaries of [MinKey->1)
Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/no_empty_reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var fullShard = st.getShard( coll, { _id : 1 } )
var emptyShard = st.getShard( coll, { _id : -1 } )

var admin = st.s.getDB( "admin" )
printjson( admin.runCommand({ moveChunk : "" + coll, find : { _id : -1 }, to : fullShard.shardName }) )
printjson( admin.runCommand({ moveChunk : "" + coll, find : { _id : -1 }, to : fullShard.shardName, _waitForDelete : true }) )

jsTestLog( "Resetting shard version via first mongos..." )

Expand Down
10 changes: 5 additions & 5 deletions jstests/sharding/shard2.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ placeCheck( 2 );
// NOTE: at this point we have 2 shard on 1 server

// test move shard
assert.throws( function(){ s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : primary.getMongo().name } ); } );
assert.throws( function(){ s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : "adasd" } ) } );
assert.throws( function(){ s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : primary.getMongo().name, _waitForDelete : true } ); } );
assert.throws( function(){ s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : "adasd", _waitForDelete : true } ) } );

s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : secondary.getMongo().name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : secondary.getMongo().name, _waitForDelete : true } );
assert.eq( 2 , secondary.foo.find().length() , "secondary should have 2 after move shard" );
assert.eq( 1 , primary.foo.find().length() , "primary should only have 1 after move shard" );

Expand Down Expand Up @@ -221,10 +221,10 @@ assert.eq( 2 , s.onNumShards( "foo" ) , "on 2 shards" );

secondary.foo.insert( { num : -3 } );

s.adminCommand( { movechunk : "test.foo" , find : { num : -2 } , to : secondary.getMongo().name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : -2 } , to : secondary.getMongo().name, _waitForDelete : true } );
assert.eq( 1 , s.onNumShards( "foo" ) , "on 1 shards" );

s.adminCommand( { movechunk : "test.foo" , find : { num : -2 } , to : primary.getMongo().name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : -2 } , to : primary.getMongo().name, _waitForDelete : true } );
assert.eq( 2 , s.onNumShards( "foo" ) , "on 2 shards again" );
assert.eq( 3 , s.config.chunks.count() , "only 3 chunks" );

Expand Down
8 changes: 4 additions & 4 deletions jstests/sharding/shard3.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ assert.eq( 0 , secondary.count() , "s1" )
assert.eq( 1 , s.onNumShards( "foo" ) , "on 1 shards" );

s.adminCommand( { split : "test.foo" , middle : { num : 2 } } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } );

assert( primary.find().toArray().length > 0 , "blah 1" );
assert( secondary.find().toArray().length > 0 , "blah 2" );
Expand Down Expand Up @@ -89,7 +89,7 @@ assert( a.findOne( { num : 1 } ) , "pre move 1" )
s.printCollectionInfo( "test.foo" );
myto = s.getOther( s.getServer( "test" ) ).name
print( "counts before move: " + tojson( s.shardCounts( "foo" ) ) );
s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : myto } )
s.adminCommand( { movechunk : "test.foo" , find : { num : 1 } , to : myto, _waitForDelete : true } )
print( "counts after move: " + tojson( s.shardCounts( "foo" ) ) );
s.printCollectionInfo( "test.foo" );
assert.eq( 1 , s.onNumShards( "foo" ) , "on 1 shard again" );
Expand Down Expand Up @@ -132,7 +132,7 @@ s.adminCommand( { shardcollection : "test.foo" , key : { num : 1 } } );
a.save( { num : 2 } );
a.save( { num : 3 } );
s.adminCommand( { split : "test.foo" , middle : { num : 2 } } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } );
s.printShardingStatus();

s.printCollectionInfo( "test.foo" , "after dropDatabase setup" );
Expand Down Expand Up @@ -165,7 +165,7 @@ assert.eq( 3 , dba.foo.count() , "Ba" );
assert.eq( 3 , dbb.foo.count() , "Bb" );

s.adminCommand( { split : "test2.foo" , middle : { num : 2 } } );
s.adminCommand( { movechunk : "test2.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test2" ) ).name } );
s.adminCommand( { movechunk : "test2.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test2" ) ).name, _waitForDelete : true } );

assert.eq( 2 , s.onNumShards( "foo" , "test2" ) , "B on 2 shards" );

Expand Down
3 changes: 2 additions & 1 deletion jstests/sharding/shard4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// shard4.js

s = new ShardingTest( "shard4" , 2 , 50 , 2 );
s.stopBalancer()

s2 = s._mongos[1];

Expand All @@ -19,7 +20,7 @@ assert.eq( 7 , s.getDB( "test" ).foo.find().toArray().length , "normal A" );
assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other A" );

s.adminCommand( { split : "test.foo" , middle : { num : 4 } } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } );

assert( s._connections[0].getDB( "test" ).foo.find().toArray().length > 0 , "blah 1" );
assert( s._connections[1].getDB( "test" ).foo.find().toArray().length > 0 , "blah 2" );
Expand Down
2 changes: 1 addition & 1 deletion jstests/sharding/shard5.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assert.eq( 7 , s.getDB( "test" ).foo.find().toArray().length , "normal A" );
assert.eq( 7 , s2.getDB( "test" ).foo.find().toArray().length , "other A" );

s.adminCommand( { split : "test.foo" , middle : { num : 4 } } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name } );
s.adminCommand( { movechunk : "test.foo" , find : { num : 3 } , to : s.getOther( s.getServer( "test" ) ).name, _waitForDelete : true } );

assert( s._connections[0].getDB( "test" ).foo.find().toArray().length > 0 , "blah 1" );
assert( s._connections[1].getDB( "test" ).foo.find().toArray().length > 0 , "blah 2" );
Expand Down
2 changes: 1 addition & 1 deletion jstests/slowNightly/sharding_rs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ s.adminCommand( { split : "test.foo" , middle : { x : 50 } } )
db.printShardingStatus()

other = s.config.shards.findOne( { _id : { $ne : serverName } } );
s.adminCommand( { moveChunk : "test.foo" , find : { x : 10 } , to : other._id } )
s.adminCommand( { moveChunk : "test.foo" , find : { x : 10 } , to : other._id, _waitForDelete : true } )
assert.eq( 100 , t.count() , "C3" )

assert.eq( 50 , rs.test.getMaster().getDB( "test" ).foo.count() , "C4" )
Expand Down

0 comments on commit 34107e2

Please sign in to comment.