diff options
Diffstat (limited to 'jstests/mmap_v1/capped7.js')
-rw-r--r-- | jstests/mmap_v1/capped7.js | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/jstests/mmap_v1/capped7.js b/jstests/mmap_v1/capped7.js index 0405cefa5a0..fa19c17af12 100644 --- a/jstests/mmap_v1/capped7.js +++ b/jstests/mmap_v1/capped7.js @@ -3,10 +3,10 @@ Random.setRandomSeed(); db.capped7.drop(); -db._dbCommand( { create: "capped7", capped: true, size: 1000, $nExtents: 11, autoIndexId: false } ); +db._dbCommand({create: "capped7", capped: true, size: 1000, $nExtents: 11, autoIndexId: false}); tzz = db.capped7; -var ten = new Array( 11 ).toString().replace( /,/g, "-" ); +var ten = new Array(11).toString().replace(/,/g, "-"); count = 0; @@ -15,16 +15,16 @@ count = 0; * count doesn't increase on insert. */ function insertUntilFull() { -count = tzz.count(); + count = tzz.count(); var j = 0; -while( 1 ) { - tzz.save( {i:ten,j:j++} ); - var newCount = tzz.count(); - if ( count == newCount ) { - break; + while (1) { + tzz.save({i: ten, j: j++}); + var newCount = tzz.count(); + if (count == newCount) { + break; + } + count = newCount; } - count = newCount; -} } insertUntilFull(); @@ -32,58 +32,58 @@ insertUntilFull(); // oldCount == count before empty oldCount = count; -assert.eq.automsg( "11", "tzz.stats().numExtents" ); +assert.eq.automsg("11", "tzz.stats().numExtents"); // oldSize == size before empty var oldSize = tzz.stats().storageSize; -assert.commandWorked( db._dbCommand( { emptycapped: "capped7" } ) ); +assert.commandWorked(db._dbCommand({emptycapped: "capped7"})); // check that collection storage parameters are the same after empty -assert.eq.automsg( "11", "tzz.stats().numExtents" ); -assert.eq.automsg( "oldSize", "tzz.stats().storageSize" ); +assert.eq.automsg("11", "tzz.stats().numExtents"); +assert.eq.automsg("oldSize", "tzz.stats().storageSize"); // check that the collection is empty after empty -assert.eq.automsg( "0", "tzz.find().itcount()" ); -assert.eq.automsg( "0", "tzz.count()" ); +assert.eq.automsg("0", "tzz.find().itcount()"); +assert.eq.automsg("0", "tzz.count()"); // check that we can reuse the empty collection, inserting as many documents // as we were able to the first time through. insertUntilFull(); -assert.eq.automsg( "oldCount", "count" ); -assert.eq.automsg( "oldCount", "tzz.find().itcount()" ); -assert.eq.automsg( "oldCount", "tzz.count()" ); +assert.eq.automsg("oldCount", "count"); +assert.eq.automsg("oldCount", "tzz.find().itcount()"); +assert.eq.automsg("oldCount", "tzz.count()"); -assert.eq.automsg( "11", "tzz.stats().numExtents" ); +assert.eq.automsg("11", "tzz.stats().numExtents"); var oldSize = tzz.stats().storageSize; -assert.commandWorked( db._dbCommand( { emptycapped: "capped7" } ) ); +assert.commandWorked(db._dbCommand({emptycapped: "capped7"})); // check that the collection storage parameters are unchanged after another empty -assert.eq.automsg( "11", "tzz.stats().numExtents" ); -assert.eq.automsg( "oldSize", "tzz.stats().storageSize" ); +assert.eq.automsg("11", "tzz.stats().numExtents"); +assert.eq.automsg("oldSize", "tzz.stats().storageSize"); // insert an arbitrary number of documents -var total = Random.randInt( 2000 ); -for( var j = 1; j <= total; ++j ) { - tzz.save( {i:ten,j:j} ); +var total = Random.randInt(2000); +for (var j = 1; j <= total; ++j) { + tzz.save({i: ten, j: j}); // occasionally check that only the oldest documents are removed to make room // for the newest documents - if ( Random.rand() > 0.95 ) { - assert.automsg( "j >= tzz.count()" ); - assert.eq.automsg( "tzz.count()", "tzz.find().itcount()" ); - var c = tzz.find().sort( {$natural:-1} ); + if (Random.rand() > 0.95) { + assert.automsg("j >= tzz.count()"); + assert.eq.automsg("tzz.count()", "tzz.find().itcount()"); + var c = tzz.find().sort({$natural: -1}); var k = j; - assert.automsg( "c.hasNext()" ); - while( c.hasNext() ) { - assert.eq.automsg( "c.next().j", "k--" ); + assert.automsg("c.hasNext()"); + while (c.hasNext()) { + assert.eq.automsg("c.next().j", "k--"); } // check the same thing with a reverse iterator as well - var c = tzz.find().sort( {$natural:1} ); - assert.automsg( "c.hasNext()" ); - while( c.hasNext() ) { - assert.eq.automsg( "c.next().j", "++k" ); - } - assert.eq.automsg( "j", "k" ); + var c = tzz.find().sort({$natural: 1}); + assert.automsg("c.hasNext()"); + while (c.hasNext()) { + assert.eq.automsg("c.next().j", "++k"); + } + assert.eq.automsg("j", "k"); } } |