summaryrefslogtreecommitdiff
path: root/jstests/concurrency
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2015-09-02 08:52:46 -0400
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2015-09-02 08:52:46 -0400
commit991e9908f571c25e78f2e8eaf7c26e20471c50e2 (patch)
treed83b7f29f34a8d811c88d2fb54ff2939e71cc09b /jstests/concurrency
parent7bb78ed5a98c25009d2f5295d091b3afd3b625f6 (diff)
downloadmongo-991e9908f571c25e78f2e8eaf7c26e20471c50e2.tar.gz
SERVER-20086 Avoid closing over $config.data in FSM tests.
Diffstat (limited to 'jstests/concurrency')
-rw-r--r--jstests/concurrency/fsm_workloads/yield.js7
-rw-r--r--jstests/concurrency/fsm_workloads/yield_geo_near.js16
-rw-r--r--jstests/concurrency/fsm_workloads/yield_geo_near_dedup.js10
-rw-r--r--jstests/concurrency/fsm_workloads/yield_rooted_or.js4
-rw-r--r--jstests/concurrency/fsm_workloads/yield_sort.js4
-rw-r--r--jstests/concurrency/fsm_workloads/yield_sort_merge.js4
-rw-r--r--jstests/concurrency/fsm_workloads/yield_text.js2
7 files changed, 22 insertions, 25 deletions
diff --git a/jstests/concurrency/fsm_workloads/yield.js b/jstests/concurrency/fsm_workloads/yield.js
index 8862ed9a16b..369db4a0c85 100644
--- a/jstests/concurrency/fsm_workloads/yield.js
+++ b/jstests/concurrency/fsm_workloads/yield.js
@@ -10,12 +10,9 @@ load('jstests/concurrency/fsm_workload_helpers/server_types.js'); // for isMongo
*/
var $config = (function() {
- // Define here so that both data.nDocs and data.genUpdateDoc can reference it
- var nDocs = 200;
-
var data = {
// Number of docs to insert at the beginning.
- nDocs: nDocs,
+ nDocs: 200,
// Batch size of queries to introduce more saving and restoring of states.
batchSize: 3,
// The words that can be found in the collection.
@@ -46,7 +43,7 @@ var $config = (function() {
* the update state should use for the update query.
*/
genUpdateDoc: function genUpdateDoc() {
- var newVal = Random.randInt(nDocs);
+ var newVal = Random.randInt(this.nDocs);
return { $set: { a: newVal } };
}
};
diff --git a/jstests/concurrency/fsm_workloads/yield_geo_near.js b/jstests/concurrency/fsm_workloads/yield_geo_near.js
index 5789152215f..08c106625f4 100644
--- a/jstests/concurrency/fsm_workloads/yield_geo_near.js
+++ b/jstests/concurrency/fsm_workloads/yield_geo_near.js
@@ -16,7 +16,7 @@ var $config = extendWorkload($config, function($config, $super) {
* environment. Unfortunately this means we cannot batch the request.
*/
$config.states.query = function geoNear(db, collName) {
- // This distance gets about 80 docs around the origin. There is one doc inserted
+ // This distance gets about 80 docs around the origin. There is one doc inserted
// every 1m^2 and the area scanned by a 5m radius is PI*(5m)^2 ~ 79.
var maxDistance = 5;
@@ -35,11 +35,11 @@ var $config = extendWorkload($config, function($config, $super) {
};
$config.data.genUpdateDoc = function genUpdateDoc() {
- var P = Math.floor(Math.sqrt($config.data.nDocs));
-
+ var P = Math.floor(Math.sqrt(this.nDocs));
+
// Move the point to another location within the PxP grid.
var newX = Random.randInt(P) - P/2;
- var newY = Random.randInt(P) - P/2
+ var newY = Random.randInt(P) - P/2;
return { $set: { geo: [newX, newY] } };
};
@@ -56,20 +56,20 @@ var $config = extendWorkload($config, function($config, $super) {
*/
$config.setup = function setup(db, collName, cluster) {
$super.setup.apply(this, arguments);
-
- var P = Math.floor(Math.sqrt($config.data.nDocs));
+
+ var P = Math.floor(Math.sqrt(this.nDocs));
var i = 0;
// Set up some points to query (in a PxP grid around 0,0).
var bulk = db[collName].initializeUnorderedBulkOp();
for (var x = 0; x < P; x++) {
for (var y = 0; y < P; y++) {
var coords = [x - P/2, y - P/2];
- bulk.find({ _id: i }).upsert().replaceOne($config.data.getReplaceSpec(i, coords));
+ bulk.find({ _id: i }).upsert().replaceOne(this.getReplaceSpec(i, coords));
i++;
}
}
assertAlways.writeOK(bulk.execute());
- assertAlways.commandWorked(db[collName].ensureIndex($config.data.getIndexSpec()));
+ assertAlways.commandWorked(db[collName].ensureIndex(this.getIndexSpec()));
};
return $config;
diff --git a/jstests/concurrency/fsm_workloads/yield_geo_near_dedup.js b/jstests/concurrency/fsm_workloads/yield_geo_near_dedup.js
index 70b2a6c7dc9..45aaf9ea721 100644
--- a/jstests/concurrency/fsm_workloads/yield_geo_near_dedup.js
+++ b/jstests/concurrency/fsm_workloads/yield_geo_near_dedup.js
@@ -12,16 +12,16 @@ var $config = extendWorkload($config, function($config, $super) {
/*
* Use geo $nearSphere query to find points near the origin. Note this should be done using the
- * geoNear command, rather than a $nearSphere query, as the $nearSphere query doesn't work in a
+ * geoNear command, rather than a $nearSphere query, as the $nearSphere query doesn't work in a
* sharded environment. Unfortunately this means we cannot batch the request.
- *
+ *
* Only points are covered in this test as there is no guarantee that geometries indexed in
- * multiple cells will be deduplicated correctly with interspersed updates. If multiple index
+ * multiple cells will be deduplicated correctly with interspersed updates. If multiple index
* cells for the same geometry occur in the same search interval, an update may cause geoNear
* to return the same document multiple times.
*/
$config.states.query = function geoNear(db, collName) {
- // This distance gets about 80 docs around the origin. There is one doc inserted
+ // This distance gets about 80 docs around the origin. There is one doc inserted
// every 1m^2 and the area scanned by a 5m radius is PI*(5m)^2 ~ 79.
var maxDistance = 5;
@@ -31,7 +31,7 @@ var $config = extendWorkload($config, function($config, $super) {
maxDistance: maxDistance,
spherical: true
});
- assertWhenOwnColl.commandWorked(res);
+ assertWhenOwnColl.commandWorked(res);
assertWhenOwnColl(function verifyResults() {
var results = res.results;
// TODO: Support non-primitive _id
diff --git a/jstests/concurrency/fsm_workloads/yield_rooted_or.js b/jstests/concurrency/fsm_workloads/yield_rooted_or.js
index 8e54c5c0c59..ee742067ff0 100644
--- a/jstests/concurrency/fsm_workloads/yield_rooted_or.js
+++ b/jstests/concurrency/fsm_workloads/yield_rooted_or.js
@@ -30,8 +30,8 @@ var $config = extendWorkload($config, function($config, $super) {
};
$config.data.genUpdateDoc = function genUpdateDoc() {
- var newC = Random.randInt($config.data.nDocs);
- var newD = Random.randInt($config.data.nDocs);
+ var newC = Random.randInt(this.nDocs);
+ var newD = Random.randInt(this.nDocs);
return { $set: { c: newC, d: newD } };
};
diff --git a/jstests/concurrency/fsm_workloads/yield_sort.js b/jstests/concurrency/fsm_workloads/yield_sort.js
index 84aeca383ca..6e4aac835a9 100644
--- a/jstests/concurrency/fsm_workloads/yield_sort.js
+++ b/jstests/concurrency/fsm_workloads/yield_sort.js
@@ -36,8 +36,8 @@ var $config = extendWorkload($config, function($config, $super) {
};
$config.data.genUpdateDoc = function genUpdateDoc() {
- var newA = Random.randInt($config.data.nDocs);
- var newC = Random.randInt($config.data.nDocs);
+ var newA = Random.randInt(this.nDocs);
+ var newC = Random.randInt(this.nDocs);
return { $set: { a: newA, c: newC } };
};
diff --git a/jstests/concurrency/fsm_workloads/yield_sort_merge.js b/jstests/concurrency/fsm_workloads/yield_sort_merge.js
index bef5820ae30..cea2a974090 100644
--- a/jstests/concurrency/fsm_workloads/yield_sort_merge.js
+++ b/jstests/concurrency/fsm_workloads/yield_sort_merge.js
@@ -40,8 +40,8 @@ var $config = extendWorkload($config, function($config, $super) {
};
$config.data.genUpdateDoc = function genUpdateDoc() {
- var newA = Random.randInt($config.data.nDocs);
- var newB = Random.randInt($config.data.nDocs);
+ var newA = Random.randInt(this.nDocs);
+ var newB = Random.randInt(this.nDocs);
return { $set: { a: newA, b: newB } };
};
diff --git a/jstests/concurrency/fsm_workloads/yield_text.js b/jstests/concurrency/fsm_workloads/yield_text.js
index c5f77cc4028..33f16e85de9 100644
--- a/jstests/concurrency/fsm_workloads/yield_text.js
+++ b/jstests/concurrency/fsm_workloads/yield_text.js
@@ -34,7 +34,7 @@ var $config = extendWorkload($config, function($config, $super) {
};
$config.data.genUpdateDoc = function genUpdateDoc() {
- var newWord = $config.data.words[Random.randInt($config.data.words.length)];
+ var newWord = this.words[Random.randInt(this.words.length)];
return { $set: { yield_text: newWord } };
};