summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/map_reduce_replace.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/concurrency/fsm_workloads/map_reduce_replace.js')
-rw-r--r--jstests/concurrency/fsm_workloads/map_reduce_replace.js82
1 files changed, 40 insertions, 42 deletions
diff --git a/jstests/concurrency/fsm_workloads/map_reduce_replace.js b/jstests/concurrency/fsm_workloads/map_reduce_replace.js
index ce268bf5e20..3db3685a7ad 100644
--- a/jstests/concurrency/fsm_workloads/map_reduce_replace.js
+++ b/jstests/concurrency/fsm_workloads/map_reduce_replace.js
@@ -15,45 +15,43 @@ load('jstests/concurrency/fsm_libs/extend_workload.js'); // for extendWo
load('jstests/concurrency/fsm_workloads/map_reduce_inline.js'); // for $config
load('jstests/concurrency/fsm_workload_helpers/drop_utils.js'); // for dropCollections
-var $config =
- extendWorkload($config,
- function($config, $super) {
-
- // Use the workload name as a prefix for the collection name,
- // since the workload name is assumed to be unique.
- var prefix = 'map_reduce_replace';
-
- function uniqueCollectionName(prefix, tid) {
- return prefix + tid;
- }
-
- $config.states.init = function init(db, collName) {
- $super.states.init.apply(this, arguments);
-
- this.outCollName = uniqueCollectionName(prefix, this.tid);
- assertAlways.commandWorked(db.createCollection(this.outCollName));
- };
-
- $config.states.mapReduce = function mapReduce(db, collName) {
- var fullName = db[this.outCollName].getFullName();
- assertAlways(db[this.outCollName].exists() !== null,
- "output collection '" + fullName + "' should exist");
-
- var options = {
- finalize: this.finalizer,
- out: {replace: this.outCollName},
- query: {key: {$exists: true}, value: {$exists: true}},
- sort: {_id: -1} // sort key must be an existing index
- };
-
- var res = db[collName].mapReduce(this.mapper, this.reducer, options);
- assertAlways.commandWorked(res);
- };
-
- $config.teardown = function teardown(db, collName, cluster) {
- var pattern = new RegExp('^' + prefix + '\\d+$');
- dropCollections(db, pattern);
- };
-
- return $config;
- });
+var $config = extendWorkload($config, function($config, $super) {
+
+ // Use the workload name as a prefix for the collection name,
+ // since the workload name is assumed to be unique.
+ var prefix = 'map_reduce_replace';
+
+ function uniqueCollectionName(prefix, tid) {
+ return prefix + tid;
+ }
+
+ $config.states.init = function init(db, collName) {
+ $super.states.init.apply(this, arguments);
+
+ this.outCollName = uniqueCollectionName(prefix, this.tid);
+ assertAlways.commandWorked(db.createCollection(this.outCollName));
+ };
+
+ $config.states.mapReduce = function mapReduce(db, collName) {
+ var fullName = db[this.outCollName].getFullName();
+ assertAlways(db[this.outCollName].exists() !== null,
+ "output collection '" + fullName + "' should exist");
+
+ var options = {
+ finalize: this.finalizer,
+ out: {replace: this.outCollName},
+ query: {key: {$exists: true}, value: {$exists: true}},
+ sort: {_id: -1} // sort key must be an existing index
+ };
+
+ var res = db[collName].mapReduce(this.mapper, this.reducer, options);
+ assertAlways.commandWorked(res);
+ };
+
+ $config.teardown = function teardown(db, collName, cluster) {
+ var pattern = new RegExp('^' + prefix + '\\d+$');
+ dropCollections(db, pattern);
+ };
+
+ return $config;
+});