// tests sharding with replica sets s = new ShardingTest( "rs1" , 3 /* numShards */, 1 /* verboseLevel */, 2 /* numMongos */, { rs : true , chunksize : 1 } ) s.adminCommand( { enablesharding : "test" } ); s.config.settings.find().forEach( printjson ) db = s.getDB( "test" ); bigString = "" while ( bigString.length < 10000 ) bigString += "asdasdasdasdadasdasdasdasdasdasdasdasda"; inserted = 0; num = 0; while ( inserted < ( 20 * 1024 * 1024 ) ){ db.foo.insert( { _id : num++ , s : bigString , x : Math.random() } ); inserted += bigString.length; } db.getLastError(); s.adminCommand( { shardcollection : "test.foo" , key : { _id : 1 } } ); assert.lt( 20 , s.config.chunks.count() , "setup2" ); function diff(){ var x = s.chunkCounts( "foo" ); var total = 0; var min = 1000000000; var max = 0; for ( var sn in x ){ total += x[sn]; if ( x[sn] < min ) min = x[sn]; if ( x[sn] > max ) max = x[sn]; } print( tojson(x) + " total: " + total + " min: " + min + " max: " + max ) return max - min; } assert.lt( 20 , diff() , "big differential here" ); print( diff() ) { // quick test for SERVER-2686 var mydbs = db.getMongo().getDBs().databases; for ( var i=0; i