summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/create_index_background_wildcard.js
blob: 46f37adb3eeec6aea4a310fff722befde1bf4ebd (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
'use strict';

/**
 * Executes the create_index_background.js workload, but with a wildcard index.
 *
 * @tags: [creates_background_indexes]
 */
load('jstests/concurrency/fsm_libs/extend_workload.js');               // For extendWorkload.
load('jstests/concurrency/fsm_workloads/create_index_background.js');  // For $config.

var $config = extendWorkload($config, function($config, $super) {
    $config.data.getIndexSpec = function() {
        return {"$**": 1};
    };

    $config.data.extendDocument = function extendDocument(originalDoc) {
        const fieldName = "arrayField";

        // Be sure we're not overwriting an existing field.
        assertAlways.eq(originalDoc.hasOwnProperty(fieldName), false);

        // Insert a field which has an array as the value, to exercise the special multikey
        // metadata functionality wildcard indexes rely on.
        originalDoc[fieldName] = [1, 2, "string", this.tid];
        return originalDoc;
    };

    $config.setup = function setup() {
        $super.setup.apply(this, arguments);
    };

    return $config;
});