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

69 lines
1.4 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;
2010-07-24 03:54:53 +02:00
for ( ; i<100; i++ ){
coll.save( { num : i , s : bigString } );
}
2010-05-24 17:17:29 +02:00
db.getLastError();
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() );
print( "datasize: " + tojson( s.getServer( "test" ).getDB( "admin" ).runCommand( { datasize : "test.foo" } ) ) );
for ( ; i<200; i++ ){
coll.save( { num : i , s : bigString } );
}
db.getLastError();
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() );
2010-07-24 03:54:53 +02:00
for ( ; i<400; i++ ){
coll.save( { num : i , s : bigString } );
}
db.getLastError();
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
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
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 ) )
2010-07-24 14:58:36 +02:00
print( counts )
2010-07-24 15:00:57 +02:00
printjson( db.stats() )
s.stop();