summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/sharding/migrateBig.js2
-rw-r--r--jstests/sharding/remove2.js3
-rw-r--r--src/mongo/shell/shardingtest.js12
3 files changed, 15 insertions, 2 deletions
diff --git a/jstests/sharding/migrateBig.js b/jstests/sharding/migrateBig.js
index c6b2ef28a97..d98459edd24 100644
--- a/jstests/sharding/migrateBig.js
+++ b/jstests/sharding/migrateBig.js
@@ -54,6 +54,8 @@ s.config.settings.update( { _id: "balancer" }, { $set : { stopped: false } } , t
assert.soon( function(){ var x = s.chunkDiff( "foo" , "test" ); print( "chunk diff: " + x ); return x < 2; } , "no balance happened" , 8 * 60 * 1000 , 2000 )
+assert.soon( function(){ return !s.isAnyBalanceInFlight(); } );
+
assert.eq( coll.count() , coll.find().itcount() );
s.stop()
diff --git a/jstests/sharding/remove2.js b/jstests/sharding/remove2.js
index 52e759ff969..daa5077431c 100644
--- a/jstests/sharding/remove2.js
+++ b/jstests/sharding/remove2.js
@@ -24,8 +24,7 @@ removeShard = function(st, replTest) {
// Need to wait for migration to be over... only works for inline deletes
checkNSLock = function() {
printjson( st.s.getDB( "config" ).locks.find().toArray() )
- return st.s.getDB( "config" ).locks.find({ _id : { $ne : "balancer" }, state : 2 })
- .count() == 0
+ return !st.isAnyBalanceInFlight();
}
assert.soon( checkNSLock, "migrations did not end?" )
diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js
index 6d4dc5b1ca8..b4e664a833f 100644
--- a/src/mongo/shell/shardingtest.js
+++ b/src/mongo/shell/shardingtest.js
@@ -972,6 +972,18 @@ ShardingTest.prototype.startBalancer = function( timeout, interval ) {
db = oldDB
}
+ShardingTest.prototype.isAnyBalanceInFlight = function() {
+ if ( this.config.locks.find({ _id : { $ne : "balancer" }, state : 2 }).count() > 0 )
+ return true;
+
+ var allCurrent = this.s.getDB( "admin" ).currentOp().inprog;
+ for ( var i = 0; i < allCurrent.length; i++ ) {
+ if ( allCurrent[i].name.indexOf( "cleanupOldData" ) == 0 )
+ return true;
+ }
+ return false;
+}
+
/**
* Kills the mongos with index n.
*/