summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/resumable_timeseries_index_build_collection_scan_phase.js
blob: fa5bf21436ffae7e9d7a6e41a0c49d7c2fc6b28f (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * Tests that resumable index builds on time-series collections in the collection scan phase write
 * their state to disk upon clean shutdown and are resumed from the same phase to completion when
 * the node is started back up.
 *
 * @tags: [
 *   requires_majority_read_concern,
 *   requires_persistence,
 *   requires_replication,
 *   requires_wiredtiger,
 * ]
 */
(function() {
"use strict";

load("jstests/noPassthrough/libs/index_build.js");

const rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();

const dbName = "test";
const db = rst.getPrimary().getDB(dbName);
const coll = db.timeseries_resumable_index_build;
coll.drop();

const timeFieldName = "time";
const metaFieldName = 'meta';
assert.commandWorked(db.createCollection(
    coll.getName(), {timeseries: {timeField: timeFieldName, metaField: metaFieldName}}));

// Use different metadata fields to guarantee creating three individual buckets in the buckets
// collection.
for (let i = 0; i < 3; i++) {
    assert.commandWorked(coll.insert({
        _id: i,
        measurement: "measurement",
        time: ISODate(),
        meta: i,
    }));
}

const bucketColl = db.getCollection("system.buckets." + coll.getName());
ResumableIndexBuildTest.run(
    rst,
    dbName,
    bucketColl.getName(),
    [[{"control.min.time": 1}, {"control.max.time": 1}]],
    [{name: "hangIndexBuildDuringCollectionScanPhaseAfterInsertion", logIdWithBuildUUID: 20386}],
    /*iteration=*/0,
    ["collection scan"],
    [{numScannedAfterResume: 2}]);

rst.stopSet();
})();