diff options
author | Randolph Tan <randolph@10gen.com> | 2014-01-14 14:09:42 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-02-28 16:26:33 -0500 |
commit | 5595b945603b0712c537787e31e6da661c424fee (patch) | |
tree | 90945ee3fe4931032f3af2d397bb755fbf5d30ef /jstests/core/cursora.js | |
parent | cd62080dcb036e83f8fca6d68d9bcab67bf7a21c (diff) | |
download | mongo-5595b945603b0712c537787e31e6da661c424fee.tar.gz |
SERVER-12127 migrate js tests to jscore suite when not related to writes
Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api
Diffstat (limited to 'jstests/core/cursora.js')
-rw-r--r-- | jstests/core/cursora.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/jstests/core/cursora.js b/jstests/core/cursora.js new file mode 100644 index 00000000000..6710c1e9dc6 --- /dev/null +++ b/jstests/core/cursora.js @@ -0,0 +1,49 @@ +t = db.cursora + +function run( n , atomic ){ + if( !isNumber(n) ) { + print("n:"); + printjson(n); + assert(isNumber(n), "cursora.js isNumber"); + } + t.drop() + + var bulk = t.initializeUnorderedBulkOp(); + for ( i=0; i<n; i++ ) + bulk.insert( { _id : i } ); + assert.writeOK(bulk.execute()); + + print("cursora.js startParallelShell n:"+n+" atomic:"+atomic) + join = startParallelShell( "sleep(50);" + + "db.cursora.remove({" + ( atomic ? "$atomic:true" : "" ) + "});" ); + + var start = null; + var ex = null; + var num = null; + var end = null; + try { + start = new Date() + ex = t.find(function () { num = 2; for (var x = 0; x < 1000; x++) num += 2; return num > 0; }).sort({ _id: -1 }).explain() + num = ex.n + end = new Date() + } + catch (e) { + print("cursora.js FAIL " + e); + join(); + throw e; + } + + join() + + //print( "cursora.js num: " + num + " time:" + ( end.getTime() - start.getTime() ) ) + assert.eq( 0 , t.count() , "after remove: " + tojson( ex ) ) + // assert.lt( 0 , ex.nYields , "not enough yields : " + tojson( ex ) ); // TODO make this more reliable so cen re-enable assert + if ( n == num ) + print( "cursora.js warning: shouldn't have counted all n: " + n + " num: " + num ); +} + +run( 1500 ) +run( 5000 ) +run( 1500 , true ) +run( 5000 , true ) +print("cursora.js SUCCESS") |