diff options
author | Aaron <aaron@10gen.com> | 2011-08-09 02:43:10 +0000 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2011-08-09 02:43:10 +0000 |
commit | b6010485ee059a23daed5a6b0c3f68704ddecaf4 (patch) | |
tree | fadd3bd00409a3eb2720a3a37e70d77024b9ebdf | |
parent | b3204f84900ce4bba3b21902360463e4215defcd (diff) | |
download | mongo-b6010485ee059a23daed5a6b0c3f68704ddecaf4.tar.gz |
SERVER-1395 make group yield test adaptive
-rw-r--r-- | jstests/group7.js | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/jstests/group7.js b/jstests/group7.js index 7461b65b569..5bf9232577c 100644 --- a/jstests/group7.js +++ b/jstests/group7.js @@ -3,23 +3,41 @@ t = db.jstests_group7; t.drop(); -a = 0; -for( i = 0; i < 3000; ++i ) { +function checkForYield( docs, updates ) { + t.drop(); + a = 0; + for( var i = 0; i < docs; ++i ) { t.save( {a:a} ); -} -db.getLastError(); + } + db.getLastError(); + + // Iteratively update all a values atomically. + p = startParallelShell( 'for( a = 0; a < ' + updates + '; ++a ) { db.jstests_group7.update( {$atomic:true}, {$set:{a:a}}, false, true ); db.getLastError(); }' ); -// Iteratively update all a values atomically. -p = startParallelShell( 'for( a = 0; a < 300; ++a ) { db.jstests_group7.update( {$atomic:true}, {$set:{a:a}}, false, true ); db.getLastError(); }' ); + for( var i = 0; i < updates; ++i ) { + ret = t.group({key:{a:1},reduce:function(){},initial:{}}); + // Check if group sees more than one a value, indicating that it yielded. + if ( ret.length > 1 ) { + p(); + return true; + } + printjson( ret ); + } -assert.soon( function() { - ret = t.group({key:{a:1},reduce:function(){},initial:{}}); - // Check if group sees more than one a value, indicating that it yielded. - if ( ret.length > 1 ) { - return true; - } - printjson( ret ); - return false; - } ); + p(); + return false; +} -p(); +var yielded = false; +var docs = 1500; +var updates = 50; +for( var j = 1; j <= 6; ++j ) { + if ( checkForYield( docs, updates ) ) { + yielded = true; + break; + } + // Increase docs and updates to encourage yielding. + docs *= 2; + updates *= 2; +} +assert( yielded );
\ No newline at end of file |