2009-04-16 16:19:52 +02:00
|
|
|
// auto1.js
|
|
|
|
|
|
|
|
s = new ShardingTest( "auto1" , 2 , 1 , 1 );
|
|
|
|
|
2009-08-30 17:22:58 +02:00
|
|
|
s.adminCommand( { enablesharding : "test" } );
|
|
|
|
s.adminCommand( { shardcollection : "test.foo" , key : { num : 1 } } );
|
2009-04-16 16:19:52 +02:00
|
|
|
|
|
|
|
bigString = "";
|
|
|
|
while ( bigString.length < 1024 * 50 )
|
|
|
|
bigString += "asocsancdnsjfnsdnfsjdhfasdfasdfasdfnsadofnsadlkfnsaldknfsad";
|
|
|
|
|
|
|
|
db = s.getDB( "test" )
|
|
|
|
coll = db.foo;
|
|
|
|
|
|
|
|
var i=0;
|
|
|
|
|
2010-07-24 03:54:53 +02:00
|
|
|
for ( ; i<100; i++ ){
|
2009-04-16 16:19:52 +02:00
|
|
|
coll.save( { num : i , s : bigString } );
|
|
|
|
}
|
2010-05-24 17:17:29 +02:00
|
|
|
db.getLastError();
|
2009-04-21 03:50:43 +02:00
|
|
|
|
2009-04-16 16:19:52 +02:00
|
|
|
primary = s.getServer( "test" ).getDB( "test" );
|
|
|
|
|
2010-07-24 14:58:36 +02:00
|
|
|
counts = []
|
|
|
|
|
2010-07-24 03:54:53 +02:00
|
|
|
s.printChunks();
|
2010-07-24 14:58:36 +02:00
|
|
|
counts.push( s.config.chunks.count() );
|
2010-07-24 03:54:53 +02:00
|
|
|
assert.eq( 100 , primary.foo.count() );
|
2009-04-16 16:19:52 +02:00
|
|
|
|
|
|
|
print( "datasize: " + tojson( s.getServer( "test" ).getDB( "admin" ).runCommand( { datasize : "test.foo" } ) ) );
|
|
|
|
|
2010-07-24 06:06:38 +02:00
|
|
|
for ( ; i<200; i++ ){
|
2009-04-16 16:19:52 +02:00
|
|
|
coll.save( { num : i , s : bigString } );
|
|
|
|
}
|
2010-11-13 07:25:05 +01:00
|
|
|
db.getLastError();
|
2009-04-16 16:19:52 +02:00
|
|
|
|
2010-07-24 03:54:53 +02:00
|
|
|
s.printChunks()
|
2010-10-25 17:57:38 +02:00
|
|
|
s.printChangeLog()
|
2010-07-24 14:58:36 +02:00
|
|
|
counts.push( s.config.chunks.count() );
|
2009-04-16 16:19:52 +02:00
|
|
|
|
2010-07-24 03:54:53 +02:00
|
|
|
for ( ; i<400; i++ ){
|
2009-04-16 16:19:52 +02:00
|
|
|
coll.save( { num : i , s : bigString } );
|
|
|
|
}
|
2010-11-13 07:25:05 +01:00
|
|
|
db.getLastError();
|
2009-04-16 16:19:52 +02:00
|
|
|
|
2009-09-04 17:00:43 +02:00
|
|
|
s.printChunks();
|
2010-10-25 17:57:38 +02:00
|
|
|
s.printChangeLog()
|
2010-07-24 14:58:36 +02:00
|
|
|
counts.push( s.config.chunks.count() );
|
2009-04-16 19:40:53 +02:00
|
|
|
|
2010-07-24 06:06:38 +02:00
|
|
|
for ( ; i<700; i++ ){
|
2009-04-16 19:40:53 +02:00
|
|
|
coll.save( { num : i , s : bigString } );
|
|
|
|
}
|
2010-07-02 18:16:06 +02:00
|
|
|
db.getLastError();
|
2009-04-16 19:40:53 +02:00
|
|
|
|
2009-09-04 17:00:43 +02:00
|
|
|
s.printChunks();
|
2010-10-25 17:57:38 +02:00
|
|
|
s.printChangeLog()
|
2010-07-24 14:58:36 +02:00
|
|
|
counts.push( s.config.chunks.count() );
|
|
|
|
|
|
|
|
assert( counts[counts.length-1] > counts[0] , "counts 1 : " + tojson( counts ) )
|
|
|
|
sorted = counts.slice(0)
|
2010-08-03 16:11:11 +02:00
|
|
|
sorted.sort();
|
2010-07-24 14:58:36 +02:00
|
|
|
assert.eq( counts , sorted , "counts 2 : " + tojson( counts ) )
|
2009-04-16 16:19:52 +02:00
|
|
|
|
2010-07-24 14:58:36 +02:00
|
|
|
print( counts )
|
2009-04-16 16:19:52 +02:00
|
|
|
|
2010-07-24 15:00:57 +02:00
|
|
|
printjson( db.stats() )
|
|
|
|
|
2009-04-16 16:19:52 +02:00
|
|
|
s.stop();
|