s = new ShardingTest( "stats" , 2 , 1 , 1, { enableBalancer : 1 } ); s.adminCommand( { enablesharding : "test" } ); a = s._connections[0].getDB( "test" ); b = s._connections[1].getDB( "test" ); db = s.getDB( "test" ); function numKeys(o){ var num = 0; for (var x in o) num++; return num; } // ---------- load some data ----- // need collections sharded before and after main collection for proper test s.adminCommand( { shardcollection : "test.aaa" , key : { _id : 1 } } ); s.adminCommand( { shardcollection : "test.foo" , key : { _id : 1 } } ); // this collection is actually used s.adminCommand( { shardcollection : "test.zzz" , key : { _id : 1 } } ); N = 10000; s.adminCommand( { split : "test.foo" , middle : { _id : N/2 } } ) s.adminCommand({ moveChunk: "test.foo", find: { _id: 3 }, to: s.getNonPrimaries("test")[0], _waitForDelete: true }); var bulk = db.foo.initializeUnorderedBulkOp(); for ( i=0; i