2010-08-01 08:02:10 +02:00
|
|
|
t = db.cursora
|
|
|
|
|
2011-01-01 23:27:10 +01:00
|
|
|
function run( n , atomic ){
|
2011-01-01 23:28:39 +01:00
|
|
|
if( !isNumber(n) ) {
|
|
|
|
print("n:");
|
|
|
|
printjson(n);
|
|
|
|
assert(isNumber(n), "cursora.js isNumber");
|
|
|
|
}
|
2010-08-01 08:02:10 +02:00
|
|
|
t.drop()
|
|
|
|
|
|
|
|
for ( i=0; i<n; i++ )
|
|
|
|
t.insert( { _id : i } )
|
2011-01-01 23:27:10 +01:00
|
|
|
db.getLastError()
|
|
|
|
|
2011-01-01 21:44:20 +01:00
|
|
|
print("cursora.js startParallelShell n:"+n+" atomic:"+atomic)
|
2011-01-01 23:27:10 +01:00
|
|
|
join = startParallelShell( "sleep(50); db.cursora.remove( {" + ( atomic ? "$atomic:true" : "" ) + "} ); db.getLastError();" );
|
|
|
|
|
|
|
|
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();
|
2011-01-01 21:52:36 +01:00
|
|
|
throw e;
|
|
|
|
}
|
2010-10-27 16:27:37 +02:00
|
|
|
|
2010-08-01 08:02:10 +02:00
|
|
|
join()
|
|
|
|
|
2011-01-01 21:52:36 +01:00
|
|
|
//print( "cursora.js num: " + num + " time:" + ( end.getTime() - start.getTime() ) )
|
2010-10-27 22:44:40 +02:00
|
|
|
assert.eq( 0 , t.count() , "after remove: " + tojson( ex ) )
|
2010-10-28 16:42:01 +02:00
|
|
|
// assert.lt( 0 , ex.nYields , "not enough yields : " + tojson( ex ) ); // TODO make this more reliable so cen re-enable assert
|
2010-08-02 18:45:34 +02:00
|
|
|
if ( n == num )
|
2011-01-01 21:44:20 +01:00
|
|
|
print( "cursora.js warning: shouldn't have counted all n: " + n + " num: " + num );
|
2010-08-01 08:02:10 +02:00
|
|
|
}
|
|
|
|
|
2010-10-20 05:22:57 +02:00
|
|
|
run( 1500 )
|
|
|
|
run( 5000 )
|
|
|
|
run( 1500 , true )
|
2011-01-01 23:27:10 +01:00
|
|
|
run( 5000 , true )
|
2011-01-01 21:44:20 +01:00
|
|
|
print("cursora.js SUCCESS")
|