summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/core/killop.js110
1 files changed, 55 insertions, 55 deletions
diff --git a/jstests/core/killop.js b/jstests/core/killop.js
index 66476ec10f4..7b44a8dacc4 100644
--- a/jstests/core/killop.js
+++ b/jstests/core/killop.js
@@ -11,66 +11,66 @@
* after 30 seconds of wall clock time have passed. For these operations to take a long time, the
* counted collection must not be empty; hence an initial write to the collection is required.
*/
+(function() {
+ 'use strict';
-t = db.jstests_killop;
-t.drop();
+ var t = db.jstests_killop;
+ t.save({x: 1});
-t.save({x: 1});
-
-/**
- * This function filters for the operations that we're looking for, based on their state and
- * the contents of their query object.
- */
-function ops() {
- p = db.currentOp().inprog;
- ids = [];
- for (var i in p) {
- var o = p[i];
- // We *can't* check for ns, b/c it's not guaranteed to be there unless the query is active,
- // which
- // it may not be in our polling cycle - particularly b/c we sleep every second in both the
- // query and
- // the assert
- if ((o.active || o.waitingForLock) && o.query && o.query.query && o.query.query.$where &&
- o.query.count == "jstests_killop") {
- ids.push(o.opid);
+ /**
+ * This function filters for the operations that we're looking for, based on their state and
+ * the contents of their query object.
+ */
+ function ops() {
+ var p = db.currentOp().inprog;
+ var ids = [];
+ for (var i in p) {
+ var o = p[i];
+ // We *can't* check for ns, b/c it's not guaranteed to be there unless the query is
+ // active, which it may not be in our polling cycle - particularly b/c we sleep every
+ // second in both the query and the assert
+ if ((o.active || o.waitingForLock) && o.query && o.query.query &&
+ o.query.query.$where && o.query.count == "jstests_killop") {
+ ids.push(o.opid);
+ }
}
+ return ids;
}
- return ids;
-}
-jsTestLog("Starting long-running $where operation");
-var s1 =
- startParallelShell("db.jstests_killop.count( { $where: function() { while( 1 ) { ; } } } )");
-var s2 =
- startParallelShell("db.jstests_killop.count( { $where: function() { while( 1 ) { ; } } } )");
+ jsTestLog("Starting long-running $where operation");
+ var s1 = startParallelShell(
+ "db.jstests_killop.count( { $where: function() { while( 1 ) { ; } } } )");
+ var s2 = startParallelShell(
+ "db.jstests_killop.count( { $where: function() { while( 1 ) { ; } } } )");
+
+ jsTestLog("Finding ops in currentOp() output");
+ var o = [];
+ assert.soon(
+ function() {
+ o = ops();
+ return o.length == 2;
+ },
+ {
+ toString: function() {
+ return tojson(db.currentOp().inprog);
+ }
+ },
+ 30000);
-jsTestLog("Finding ops in currentOp() output");
-o = [];
-assert.soon(
- function() {
- o = ops();
- return o.length == 2;
- },
- {
- toString: function() {
- return tojson(db.currentOp().inprog);
- }
- },
- 10000);
-start = new Date();
-jsTestLog("Killing ops");
-db.killOp(o[0]);
-db.killOp(o[1]);
+ var start = new Date();
+ jsTestLog("Killing ops");
+ db.killOp(o[0]);
+ db.killOp(o[1]);
-jsTestLog("Waiting for ops to terminate");
-[s1, s2].forEach(function(awaitShell) {
- var exitCode = awaitShell({checkExitSuccess: false});
- assert.neq(
- 0, exitCode, "expected shell to exit abnormally due to JS execution being terminated");
-});
+ jsTestLog("Waiting for ops to terminate");
+ [s1, s2].forEach(function(awaitShell) {
+ var exitCode = awaitShell({checkExitSuccess: false});
+ assert.neq(
+ 0, exitCode, "expected shell to exit abnormally due to JS execution being terminated");
+ });
-// don't want to pass if timeout killed the js function.
-var end = new Date();
-var diff = end - start;
-assert.lt(diff, 30000, "Start: " + start + "; end: " + end + "; diff: " + diff); \ No newline at end of file
+ // don't want to pass if timeout killed the js function.
+ var end = new Date();
+ var diff = end - start;
+ assert.lt(diff, 30000, "Start: " + start + "; end: " + end + "; diff: " + diff);
+})();