summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/map_reduce_replace_remove.js
blob: 1bd48dce23023fffdc4a5a6786493ab64704c6fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';

/**
 * map_reduce_replace_remove.js
 *
 * Generates some random data and inserts it into a collection. Runs a map-reduce command over the
 * collection that computes the frequency counts of the 'value' field and stores the results in an
 * existing collection. Some of the random data from the source collection is removed while the
 * map-reduce operations are running to verify the cursor state is saved and restored correctly on
 * yields.
 *
 * This workload was designed to reproduce SERVER-15539.
 * @tags: [
 *   # mapReduce does not support afterClusterTime.
 *   does_not_support_causal_consistency,
 * ]
 */
load('jstests/concurrency/fsm_libs/extend_workload.js');          // for extendWorkload
load('jstests/concurrency/fsm_workloads/map_reduce_replace.js');  // for $config

var $config = extendWorkload($config, function($config, $super) {
    $config.states.remove = function remove(db, collName) {
        for (var i = 0; i < 20; ++i) {
            var res = db[collName].remove({value: {$gte: Random.randInt(this.numDocs / 10)}},
                                          {justOne: true});
            assertAlways.commandWorked(res);
            assertAlways.lte(0, res.nRemoved, tojson(res));
        }
    };

    $config.transitions = {
        init: {mapReduce: 0.5, remove: 0.5},
        mapReduce: {mapReduce: 0.5, remove: 0.5},
        remove: {mapReduce: 0.5, remove: 0.5}
    };

    return $config;
});