summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2012-12-31 00:22:25 -0500
committerDan Pasette <dan@10gen.com>2013-03-06 15:47:23 -0500
commita3f7825c1e5f0b1d27cb1d75a080f34d63669d67 (patch)
tree7abf7cad38fe007afa0c39c198b318a78f12c59e
parent77dff908bcbe0f13a2cfc5b48bfda750e4619ce6 (diff)
downloadmongo-a3f7825c1e5f0b1d27cb1d75a080f34d63669d67.tar.gz
try to make sharding tests more reliable when needing balancing to be done
-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.
*/