summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/distinct_projection.js
blob: cf287cdb2106fb358a54b728422e4328ac32b36c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';

/**
 * distinct_projection.js
 *
 * Runs distinct, with a projection on an indexed field, and verifies the result.
 * The indexed field contains unique values.
 * Each thread operates on a separate collection.
 */
load('jstests/concurrency/fsm_libs/extend_workload.js');  // for extendWorkload
load('jstests/concurrency/fsm_workloads/distinct.js');    // for $config

var $config = extendWorkload($config, function($config, $super) {
    $config.data.prefix = 'distinct_projection_fsm';

    $config.states.distinct = function distinct(db, collName) {
        var query = {i: {$lt: this.numDocs / 2}};
        assertWhenOwnColl.eq(this.numDocs / 2, db[this.threadCollName].distinct('i', query).length);
    };

    return $config;
});