diff options
Diffstat (limited to 'jstests/noPassthrough/query_yield1.js')
-rw-r--r-- | jstests/noPassthrough/query_yield1.js | 148 |
1 files changed, 74 insertions, 74 deletions
diff --git a/jstests/noPassthrough/query_yield1.js b/jstests/noPassthrough/query_yield1.js index 4effd6b370f..74485c45cb0 100644 --- a/jstests/noPassthrough/query_yield1.js +++ b/jstests/noPassthrough/query_yield1.js @@ -1,93 +1,93 @@ (function() { - "use strict"; - if (0) { // Test disabled until SERVER-8579 is finished. Reminder ticket: SERVER-8342 - const conn = MongoRunner.runMongod({nojournal: ""}); - assert.neq(null, conn, "mongod failed to start."); - db = conn.getDB("test"); - - t = db.query_yield1; - t.drop(); - - N = 20000; - i = 0; - - q = function() { - var x = this.n; - for (var i = 0; i < 250; i++) { - x = x * 2; +"use strict"; +if (0) { // Test disabled until SERVER-8579 is finished. Reminder ticket: SERVER-8342 + const conn = MongoRunner.runMongod({nojournal: ""}); + assert.neq(null, conn, "mongod failed to start."); + db = conn.getDB("test"); + + t = db.query_yield1; + t.drop(); + + N = 20000; + i = 0; + + q = function() { + var x = this.n; + for (var i = 0; i < 250; i++) { + x = x * 2; + } + return false; + }; + + while (true) { + fill = function() { + var bulk = t.initializeUnorderedBulkOp(); + for (; i < N; i++) { + bulk.insert({_id: i, n: 1}); } - return false; + assert.writeOK(bulk.execute()); }; - while (true) { - fill = function() { - var bulk = t.initializeUnorderedBulkOp(); - for (; i < N; i++) { - bulk.insert({_id: i, n: 1}); - } - assert.writeOK(bulk.execute()); - }; - - timeQuery = function() { - return Date.timeFunc(function() { - assert.eq(0, t.find(q).itcount()); - }); - }; - - fill(); - timeQuery(); - timeQuery(); - time = timeQuery(); - print(N + "\t" + time); - if (time > 2000) - break; - - N *= 2; - } + timeQuery = function() { + return Date.timeFunc(function() { + assert.eq(0, t.find(q).itcount()); + }); + }; - // --- test 1 + fill(); + timeQuery(); + timeQuery(); + time = timeQuery(); + print(N + "\t" + time); + if (time > 2000) + break; - assert.eq(0, db.currentOp().inprog.length, "setup broken"); + N *= 2; + } - join = startParallelShell( - "print( 0 == db.query_yield1.find( function(){ var x=this.n; for ( var i=0; i<500; i++ ){ x = x * 2; } return false; } ).itcount() ); "); + // --- test 1 - assert.soon(function() { - var x = db.currentOp().inprog; - return x.length > 0; - }, "never doing query", 2000, 1); + assert.eq(0, db.currentOp().inprog.length, "setup broken"); - print("start query"); + join = startParallelShell( + "print( 0 == db.query_yield1.find( function(){ var x=this.n; for ( var i=0; i<500; i++ ){ x = x * 2; } return false; } ).itcount() ); "); - num = 0; - start = new Date(); - biggestMe = 0; - while (((new Date()).getTime() - start) < (time * 2)) { - var me = Date.timeFunc(function() { - t.insert({x: 1}); - }); - var x = db.currentOp(); + assert.soon(function() { + var x = db.currentOp().inprog; + return x.length > 0; + }, "never doing query", 2000, 1); - if (num++ == 0) { - assert.eq(1, x.inprog.length, "nothing in prog"); - } + print("start query"); - if (me > biggestMe) { - biggestMe = me; - print("biggestMe: " + biggestMe); - } - - assert.gt(200, me, "took too long for me to run"); + num = 0; + start = new Date(); + biggestMe = 0; + while (((new Date()).getTime() - start) < (time * 2)) { + var me = Date.timeFunc(function() { + t.insert({x: 1}); + }); + var x = db.currentOp(); - if (x.inprog.length == 0) - break; + if (num++ == 0) { + assert.eq(1, x.inprog.length, "nothing in prog"); } - join(); + if (me > biggestMe) { + biggestMe = me; + print("biggestMe: " + biggestMe); + } - var x = db.currentOp(); - assert.eq(0, x.inprog.length, "weird 2"); + assert.gt(200, me, "took too long for me to run"); - MongoRunner.stopMongod(conn); + if (x.inprog.length == 0) + break; } + + join(); + + var x = db.currentOp(); + assert.eq(0, x.inprog.length, "weird 2"); + + MongoRunner.stopMongod(conn); +} })(); |