0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/sharding/auto1.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

// 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 } } );
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 } );
}
s.adminCommand( "connpoolsync" );
primary = s.getServer( "test" ).getDB( "test" );
assert.eq( 1 , s.config.chunks.count() );
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 } );
}
assert.eq( 1 , s.config.chunks.count() );
for ( ; i<1500; i++ ){
coll.save( { num : i , s : bigString } );
}
assert.eq( 3 , s.config.chunks.count() , "shard didn't split A " );
s.printShards();
2009-04-16 19:40:53 +02:00
for ( ; i<3000; i++ ){
coll.save( { num : i , s : bigString } );
}
assert.eq( 4 , s.config.chunks.count() , "shard didn't split B " );
s.printShards();
s.stop();