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

26 lines
771 B
JavaScript
Raw Normal View History

2010-05-25 02:33:01 +02:00
// check that there is preallocation on explicit createCollection() and no unncessary preallocation after restart
2010-01-20 02:20:34 +01:00
2010-05-25 02:33:01 +02:00
port = allocatePorts( 1 )[ 0 ];
2010-01-20 00:11:21 +01:00
2010-05-25 02:33:01 +02:00
var baseName = "jstests_preallocate2";
2010-01-20 00:11:21 +01:00
2010-01-20 02:20:34 +01:00
var m = startMongod( "--port", port, "--dbpath", "/data/db/" + baseName );
2010-01-20 00:11:21 +01:00
2010-05-25 02:33:01 +02:00
assert.eq( 0, m.getDBs().totalSize );
2010-01-20 00:11:21 +01:00
m.getDB( baseName ).createCollection( baseName + "1" );
2010-05-25 02:33:01 +02:00
assert.soon( function() { return m.getDBs().totalSize > 100000000; }, "expected second file to bring total size over 100MB" );
2010-01-20 02:20:34 +01:00
stopMongod( port );
2010-01-20 00:11:21 +01:00
2010-01-20 02:20:34 +01:00
var m = startMongoProgram( "mongod", "--port", port, "--dbpath", "/data/db/" + baseName );
2010-01-20 00:11:21 +01:00
size = m.getDBs().totalSize;
2010-01-20 00:11:21 +01:00
m.getDB( baseName ).createCollection( baseName + "2" );
sleep( 2000 ); // give prealloc a chance
assert.eq( size, m.getDBs().totalSize );