diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
commit | 5d342a758c6095b4d30aba0750b54f13b8916f51 (patch) | |
tree | 762e9aa84781f5e3b96db2c02d356c29cf0217c0 /jstests/capped8.js | |
parent | cbe2d992e9cd1ea66af9fa91df006106775d3073 (diff) | |
download | mongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz |
Imported Upstream version 2.0.0
Diffstat (limited to 'jstests/capped8.js')
-rw-r--r-- | jstests/capped8.js | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/jstests/capped8.js b/jstests/capped8.js index cce0eec..e5b28dc 100644 --- a/jstests/capped8.js +++ b/jstests/capped8.js @@ -9,25 +9,39 @@ function debug( x ) { } /** Generate an object with a string field of specified length */ -function obj( size ) { - return {a:new Array( size + 1 ).toString()};; +function obj( size, x ) { + return {X:x, a:new Array( size + 1 ).toString()};; } function withinOne( a, b ) { assert( Math.abs( a - b ) <= 1, "not within one: " + a + ", " + b ) } +var X = 0; + /** * Insert enough documents of the given size spec that the collection will * contain only documents having this size spec. */ -function insertMany( size ) { +function insertManyRollingOver( objsize ) { // Add some variability, as the precise number can trigger different cases. - n = 250 + Random.randInt( 10 ); + X++; + n = 250 + Random.randInt(10); + + assert(t.count() == 0 || t.findOne().X != X); + for( i = 0; i < n; ++i ) { - t.save( obj( size ) ); + t.save( obj( objsize, X ) ); debug( t.count() ); } + + if (t.findOne().X != X) { + printjson(t.findOne()); + print("\n\nERROR didn't roll over in insertManyRollingOver " + objsize); + print("approx amountwritten: " + (objsize * n)); + printjson(t.stats()); + assert(false); + } } /** @@ -37,10 +51,10 @@ function insertMany( size ) { function insertAndTruncate( first ) { myInitialCount = t.count(); // Insert enough documents to make the capped allocation loop over. - insertMany( 50 ); + insertManyRollingOver( 150 ); myFiftyCount = t.count(); // Insert documents that are too big to fit in the smaller extents. - insertMany( 2000 ); + insertManyRollingOver( 5000 ); myTwokCount = t.count(); if ( first ) { initialCount = myInitialCount; @@ -69,18 +83,24 @@ function testTruncate() { insertAndTruncate( false ); } +var pass = 1; + +print("pass " + pass++); t.drop(); -db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000, 10000, 1000 ] } ); +db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000, 10000, 4000 ] } ); testTruncate(); +print("pass " + pass++); t.drop(); -db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000, 1000, 1000 ] } ); +db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000, 1000, 4000 ] } ); testTruncate(); +print("pass " + pass++); t.drop(); -db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000, 1000 ] } ); +db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000, 4000 ] } ); testTruncate(); +print("pass " + pass++); t.drop(); db._dbCommand( { create:"jstests_capped8", capped: true, $nExtents: [ 10000 ] } ); testTruncate(); |