summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2017-07-17 18:41:13 -0400
committerCharlie Swanson <charlie.swanson@mongodb.com>2017-07-19 16:35:31 -0400
commit2a8317c052e8a5e44a8816796b6201f30bcd8bfa (patch)
tree5790f76093a7500d3ea02151c6c147fd2fb8d043 /jstests
parentb6a4241890c6adfa72302e7806d28bd1e803c358 (diff)
downloadmongo-2a8317c052e8a5e44a8816796b6201f30bcd8bfa.tar.gz
SERVER-29299 Add currentOp as parallel op during basicPlus.js
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/evalc.js26
-rw-r--r--jstests/libs/parallelTester.js10
-rw-r--r--jstests/parallel/basicPlus.js3
3 files changed, 12 insertions, 27 deletions
diff --git a/jstests/core/evalc.js b/jstests/core/evalc.js
deleted file mode 100644
index 0d55790afe3..00000000000
--- a/jstests/core/evalc.js
+++ /dev/null
@@ -1,26 +0,0 @@
-t = db.jstests_evalc;
-t.drop();
-
-t2 = db.evalc_done;
-t2.drop();
-
-for (i = 0; i < 10; ++i) {
- t.save({i: i});
-}
-
-// SERVER-1610
-
-assert.eq(0, t2.count(), "X1");
-
-s = startParallelShell(
- "print( 'starting forked:' + Date() ); for ( i=0; i<10*1000; i++ ){ db.currentOp(); } print( 'ending forked:' + Date() ); db.evalc_done.insert( { x : 1 } ); ");
-
-print("starting eval: " + Date());
-assert.soon(function() {
- db.eval("db.jstests_evalc.count( {i:10} );");
- return t2.count() > 0;
-}, 'parallel shell failed to update ' + t2.getFullName(), 120000, 10);
-
-print("end eval: " + Date());
-
-s();
diff --git a/jstests/libs/parallelTester.js b/jstests/libs/parallelTester.js
index 672fa4a97b4..db784ab66c1 100644
--- a/jstests/libs/parallelTester.js
+++ b/jstests/libs/parallelTester.js
@@ -72,6 +72,10 @@ if (typeof _threadInject != "undefined") {
this._add("t.remove( " + tojson(obj) + " )");
};
+ EventGenerator.prototype.addCurrentOp = function() {
+ this._add("db.currentOp()");
+ };
+
EventGenerator.prototype.addUpdate = function(objOld, objNew) {
this._add("t.update( " + tojson(objOld) + ", " + tojson(objNew) + " )");
};
@@ -101,7 +105,11 @@ if (typeof _threadInject != "undefined") {
var collectionName = args.shift();
var host = args.shift();
var m = new Mongo(host);
- var t = m.getDB("test")[collectionName];
+
+ // We define 'db' and 't' as local variables so that calling eval() on the stringified
+ // JavaScript expression 'args[i][1]' can take advantage of using them.
+ var db = m.getDB("test");
+ var t = db[collectionName];
for (var i in args) {
sleep(args[i][0]);
eval(args[i][1]);
diff --git a/jstests/parallel/basicPlus.js b/jstests/parallel/basicPlus.js
index 2ecb20d6c21..778137ca0d8 100644
--- a/jstests/parallel/basicPlus.js
+++ b/jstests/parallel/basicPlus.js
@@ -21,6 +21,9 @@ for (var i = 4; i < 8; ++i) {
expected % 1000 == 0,
expected % 500 == 0);
g.addInsert({_id: j});
+ // Add currentOp commands running in parallel. Historically there have been many race
+ // conditions between various commands and the currentOp command.
+ g.addCurrentOp();
}
t.add(EventGenerator.dispatch, g.getEvents());
}