Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

SERVER-1395 make group yield test adaptive

  • Loading branch information...
commit b6010485ee059a23daed5a6b0c3f68704ddecaf4 1 parent b3204f8
@astaple astaple authored
Showing with 34 additions and 16 deletions.
  1. +34 −16 jstests/group7.js
View
50 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 );
Please sign in to comment.
Something went wrong with that request. Please try again.