diff options
author | Greg Studer <greg@10gen.com> | 2012-10-17 14:52:06 -0400 |
---|---|---|
committer | Greg Studer <greg@10gen.com> | 2012-10-17 16:06:01 -0400 |
commit | eb5bf5b804ee4f20ab5c9e5a77674fe051889f76 (patch) | |
tree | 94176d97ba4459acb91726e25d5de3d394374c02 /jstests | |
parent | 34107e2d9785dfbc2665a30a724bf68049f87309 (diff) | |
download | mongo-eb5bf5b804ee4f20ab5c9e5a77674fe051889f76.tar.gz |
SERVER-7376 test fixes for 2.3+ for slow migration cleanup
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/authCommands2.js | 9 | ||||
-rw-r--r-- | jstests/sharding/features2.js | 5 | ||||
-rw-r--r-- | jstests/sharding/key_string.js | 2 | ||||
-rw-r--r-- | jstests/sharding/prefix_shard_key.js | 19 |
4 files changed, 32 insertions, 3 deletions
diff --git a/jstests/sharding/authCommands2.js b/jstests/sharding/authCommands2.js index 5f403d70313..de724cd954f 100644 --- a/jstests/sharding/authCommands2.js +++ b/jstests/sharding/authCommands2.js @@ -74,6 +74,11 @@ assert.soon( function() { return x < 2 && configDB.locks.findOne({ _id : 'test.foo' }).state == 0; }, "no balance happened", 60000 ); +assert.soon( function(){ + print( "Waiting for migration cleanup to occur..." ) + return testDB.foo.find().itcount() == testDB.foo.count(); +}) + var map = function() { emit (this.i, this.j) }; var reduce = function( key, values ) { var jCount = 0; @@ -232,12 +237,12 @@ var checkAdminWriteOps = function( hasWriteAuth ) { checkCommandSucceeded( adminDB, {split : 'test.foo', find : {i : 1, j : 1}} ); chunk = configDB.chunks.findOne({ shard : st.rs0.name }); checkCommandSucceeded( adminDB, {moveChunk : 'test.foo', find : chunk.min, - to : st.rs1.name} ); + to : st.rs1.name, _waitForDelete : true} ); } else { checkCommandFailed( adminDB, {split : 'test.foo', find : {i : 1, j : 1}} ); chunkKey = { i : { $minKey : 1 }, j : { $minKey : 1 } }; checkCommandFailed( adminDB, {moveChunk : 'test.foo', find : chunkKey, - to : st.rs1.name} ); + to : st.rs1.name, _waitForDelete : true} ); } } diff --git a/jstests/sharding/features2.js b/jstests/sharding/features2.js index 507dc7ab545..4df8809caf6 100644 --- a/jstests/sharding/features2.js +++ b/jstests/sharding/features2.js @@ -28,6 +28,11 @@ assert.eq( 1 , s.onNumShards( "foo" ) , "A1" ); s.shardGo( "foo" , { x : 1 } , { x : 2 } , { x : 3 } ); +assert.soon( function(){ + print( "Waiting for migration cleanup to occur..." ); + return db.foo.count() == db.foo.find().itcount(); +}) + assert.eq( 2 , s.onNumShards( "foo" ) , "A2" ); assert.eq( "1,2,3" , db.foo.distinct( "x" ) , "distinct 4" ); diff --git a/jstests/sharding/key_string.js b/jstests/sharding/key_string.js index 63ed7771db8..990b0456665 100644 --- a/jstests/sharding/key_string.js +++ b/jstests/sharding/key_string.js @@ -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, _waitForDelete : true } ); +s.adminCommand( { movechunk : "test.foo" , find : { name : "allan" } , to : seconday.getMongo().name, _waitForDelete : true, _waitForDelete : true } ); s.printChunks(); diff --git a/jstests/sharding/prefix_shard_key.js b/jstests/sharding/prefix_shard_key.js index b077655fa04..b1854bb817d 100644 --- a/jstests/sharding/prefix_shard_key.js +++ b/jstests/sharding/prefix_shard_key.js @@ -55,6 +55,13 @@ assert.eq( 2, coll.getIndexes().length ); // make sure balancing happens s.awaitBalance( coll.getName(), db.getName() ); + +// Make sure our initial balance cleanup doesn't interfere with later migrations. +assert.soon( function(){ + print( "Waiting for migration cleanup to occur..." ); + return coll.count() == coll.find().itcount(); +}) + s.stopBalancer(); //test splitting @@ -92,6 +99,12 @@ var result4 = admin.runCommand( { movechunk : coll.getFullName() , find : { num printjson( result4 ); assert.eq( 1, result4.ok , "moveChunk failed after rebuilding index"); +// Make sure the previous migrates cleanup doesn't interfere with later tests +assert.soon( function(){ + print( "Waiting for migration cleanup to occur..." ); + return coll.count() == coll.find().itcount(); +}) + //******************Part 3******************** // Check chunk boundaries obeyed when using prefix shard key. @@ -138,6 +151,12 @@ for( i=0; i < 3; i++ ){ var moveRes = admin.runCommand( { moveChunk : coll2 + "", find : { skey : 0 }, to : shards[1]._id } ); assert.eq( moveRes.ok , 1 , "movechunk didn't work" ); + // Make sure our migration eventually goes through before testing individual shards + assert.soon( function(){ + print( "Waiting for migration cleanup to occur..." ); + return coll2.count() == coll2.find().itcount(); + }) + // check no orphaned docs on the shards assert.eq( 0 , shard0.getCollection( coll2 + "" ).find().itcount() ); assert.eq( 25 , shard1.getCollection( coll2 + "" ).find().itcount() ); |