diff --git a/jstests/capped2.js b/jstests/capped2.js index a9b209efa8f..3a48eedba2b 100644 --- a/jstests/capped2.js +++ b/jstests/capped2.js @@ -1,6 +1,10 @@ db.capped2.drop(); db._dbCommand( { create: "capped2", capped: true, size: 1000, $nExtents: 11, autoIndexId: false } ); -t = db.capped2; +tzz = db.capped2; + +function debug( x ) { +// print( x ); +} var val = new Array( 2000 ); var c = ""; @@ -9,43 +13,45 @@ for( i = 0; i < 2000; ++i, c += "-" ) { } function checkIncreasing( i ) { - res = t.find().sort( { $natural: -1 } ); - assert( res.hasNext() ); + res = tzz.find().sort( { $natural: -1 } ); + assert( res.hasNext(), "A" ); var j = i; while( res.hasNext() ) { - assert.eq( val[ j-- ].a, res.next().a ); + assert.eq( val[ j-- ].a, res.next().a, "B" ); } - res = t.find().sort( { $natural: 1 } ); - assert( res.hasNext() ); + res = tzz.find().sort( { $natural: 1 } ); + assert( res.hasNext(), "C" ); while( res.hasNext() ) - assert.eq( val[ ++j ].a, res.next().a ); - assert.eq( j, i ); + assert.eq( val[ ++j ].a, res.next().a, "D" ); + assert.eq( j, i, "E" ); } function checkDecreasing( i ) { - res = t.find().sort( { $natural: -1 } ); - assert( res.hasNext() ); + res = tzz.find().sort( { $natural: -1 } ); + assert( res.hasNext(), "F" ); var j = i; while( res.hasNext() ) { - assert.eq( val[ j++ ].a, res.next().a ); + assert.eq( val[ j++ ].a, res.next().a, "G" ); } - res = t.find().sort( { $natural: 1 } ); - assert( res.hasNext() ); + res = tzz.find().sort( { $natural: 1 } ); + assert( res.hasNext(), "H" ); while( res.hasNext() ) - assert.eq( val[ --j ].a, res.next().a ); - assert.eq( j, i ); + assert.eq( val[ --j ].a, res.next().a, "I" ); + assert.eq( j, i, "J" ); } for( i = 0 ;; ++i ) { - t.save( val[ i ] ); - if ( t.count() == 0 ) { - assert( i > 100 ); + debug( "capped 2: " + i ); + tzz.save( val[ i ] ); + if ( tzz.count() == 0 ) { + assert( i > 100, "K" ); break; } checkIncreasing( i ); } for( i = 600 ; i >= 0 ; --i ) { - t.save( val[ i ] ); + debug( "capped 2: " + i ); + tzz.save( val[ i ] ); checkDecreasing( i ); } diff --git a/jstests/capped4.js b/jstests/capped4.js index 71fe5f0c05f..14d5bd00521 100644 --- a/jstests/capped4.js +++ b/jstests/capped4.js @@ -13,16 +13,16 @@ d = t.find().sort( { i: -1 } ).limit( 2 ); d.next(); d.next(); -for( i = 20; i < 40; ++i ) { +for( i = 20; t.findOne( { i:19 } ); ++i ) { t.save( { i : i } ); } -assert( !t.findOne( { i : 19 } ) ); -assert( !c.hasNext() ); -assert( !d.hasNext() ); -assert( t.find().sort( { i : 1 } ).hint( { i : 1 } ).toArray().length > 10 ); +//assert( !t.findOne( { i : 19 } ), "A" ); +assert( !c.hasNext(), "B" ); +assert( !d.hasNext(), "C" ); +assert( t.find().sort( { i : 1 } ).hint( { i : 1 } ).toArray().length > 10, "D" ); -assert( t.findOne( { i : 38 } ) ); -t.remove( { i : 38 } ); -assert( db.getLastError().indexOf( "capped" ) >= 0 ); +assert( t.findOne( { i : i - 1 } ), "E" ); +t.remove( { i : i - 1 } ); +assert( db.getLastError().indexOf( "capped" ) >= 0, "F" ); -assert( t.validate().valid ); +assert( t.validate().valid, "G" );