(function () { var s = new ShardingTest({ name: "stats", shards: 2, mongos: 1, verbose: 1, other: { enableBalancer: true } }); s.adminCommand( { enablesharding : "test" } ); a = s._connections[0].getDB( "test" ); b = s._connections[1].getDB( "test" ); db = s.getDB( "test" ); s.ensurePrimaryShard('test', 'shard0001'); function numKeys(o){ var num = 0; for (var x in o) num++; return num; } db.foo.drop(); assert.commandFailed(db.foo.stats(), 'db.collection.stats() should fail on non-existent collection'); // ---------- 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