diff options
author | Aaron <aaron@10gen.com> | 2012-04-04 09:35:58 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2012-04-04 10:19:48 -0700 |
commit | 0d5b0e67d37e896df3e932da1dfd0b38d591ff87 (patch) | |
tree | cc128d604f9d951c5a38788433860f83f258d3c5 /jstests/count8.js | |
parent | 090476bf93e79687111d5310a658030b18b8dac0 (diff) | |
download | mongo-0d5b0e67d37e896df3e932da1dfd0b38d591ff87.tar.gz |
SERVER-5428 Remove yield validation from the count8.js test, but preserve sanity checks for drop on yield cases.
Diffstat (limited to 'jstests/count8.js')
-rw-r--r-- | jstests/count8.js | 66 |
1 files changed, 29 insertions, 37 deletions
diff --git a/jstests/count8.js b/jstests/count8.js index 41536bf7732..b5119388750 100644 --- a/jstests/count8.js +++ b/jstests/count8.js @@ -1,48 +1,40 @@ -// Test count yielding, in both fast and normal count modes. +// Drop a collection while a count operation is yielding, in both fast and normal count modes. t = db.jstests_count8; t.drop(); -function checkYield( dropCollection, fastCount, query ) { +function assertCollectionMissing( query ) { + assert.commandFailed( t.stats() ); + assert.eq( 0, t.count( query ) ); +} + +function checkDrop( fastCount, query ) { - obj = fastCount ? {a:true} : {a:1}; + obj = fastCount ? { a:true } : { a:1 }; query = query || obj; - passed = false; - for( nDocs = 20000; nDocs < 2000000; nDocs *= 2 ) { - - t.drop(); - t.ensureIndex( {a:1} ); - for( i = 0; i < nDocs; ++i ) { - t.insert( obj ); - } - db.getLastError(); - - if ( dropCollection ) { - p = startParallelShell( 'sleep( 30 ); db.jstests_count8.drop(); db.getLastError();' ); - } else { - p = startParallelShell( 'sleep( 30 ); db.jstests_count8.update( {$atomic:true}, {$set:{a:-1}}, false, true ); db.getLastError();' ); - } - - printjson( query ); - count = t.count( query ); - // We test that count yields by requesting a concurrent operation modifying the collection - // and checking that the count result is modified. - print( 'count: ' + count + ', nDocs: ' + nDocs ); - if ( count < nDocs ) { - passed = true; - p(); - break; - } - - p(); + nDocs = 40000; + + t.drop(); + t.ensureIndex( { a:1 } ); + for( i = 0; i < nDocs; ++i ) { + t.insert( obj ); } + db.getLastError(); + + // Trigger an imminent collection drop. If the drop operation runs while the count operation + // yields, count returns a valid result. Additionally mongod continues running and indicates + // the collection is no longer present. The same will be true if, in an alternative timing + // scenario, the drop operation runs before count starts or after count finishes. + p = startParallelShell( 'sleep( 15 ); db.jstests_count8.drop(); db.getLastError();' ); + + // The count command runs successfully so count() does not assert. + t.count( query ); + p(); - assert( passed ); + assertCollectionMissing( query ); } -checkYield( true, false ); -checkYield( false, false ); -checkYield( true, true ); -checkYield( false, true ); -checkYield( true, false, {$or:[{a:1},{a:2}]} ); +checkDrop( true ); +checkDrop( false ); +checkDrop( false, {$or:[{a:1},{a:2}]} ); |