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;
|
|
|
|
|
|
|
|
for ( ; i<500; i++ ){
|
|
|
|
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" );
|
|
|
|
|
2009-09-01 17:09:43 +02:00
|
|
|
assert.eq( 1 , s.config.chunks.count() );
|
2009-04-16 16:19:52 +02:00
|
|
|
assert.eq( 500 , primary.foo.count() );
|
|
|
|
|
|
|
|
print( "datasize: " + tojson( s.getServer( "test" ).getDB( "admin" ).runCommand( { datasize : "test.foo" } ) ) );
|
|
|
|
|
|
|
|
for ( ; i<800; i++ ){
|
|
|
|
coll.save( { num : i , s : bigString } );
|
|
|
|
}
|
|
|
|
|
2009-09-01 17:09:43 +02:00
|
|
|
assert.eq( 1 , s.config.chunks.count() );
|
2009-04-16 16:19:52 +02:00
|
|
|
|
|
|
|
for ( ; i<1500; i++ ){
|
|
|
|
coll.save( { num : i , s : bigString } );
|
|
|
|
}
|
|
|
|
|
2010-07-15 06:29:42 +02:00
|
|
|
assert.lte( 3 , s.config.chunks.count() , "shard didn't split A " );
|
2009-09-04 17:00:43 +02:00
|
|
|
s.printChunks();
|
2009-04-16 19:40:53 +02:00
|
|
|
|
2010-05-11 21:39:04 +02:00
|
|
|
for ( ; i<2800; 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
|
|
|
|
2010-07-15 06:29:42 +02:00
|
|
|
assert.lte( 4 , s.config.chunks.count() , "shard didn't split B " );
|
2009-09-04 17:00:43 +02:00
|
|
|
s.printChunks();
|
2009-04-16 16:19:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
s.stop();
|