summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/resumable_index_build_drain_writes_phase.js
blob: c6f78592a0aae04444c8a30a127e1df0c16af155 (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
/**
 * Tests that resumable index build state is written to disk upon clean shutdown when an index
 * build is in the drain writes phase, and that the index build is subsequently completed when the
 * node is started back up.
 *
 * @tags: [requires_persistence, requires_replication]
 */
(function() {
"use strict";

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

const dbName = "test";
const collName = "resumable_index_build_drain_writes_phase";

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

const primary = rst.getPrimary();
const coll = primary.getDB(dbName).getCollection(collName);

if (!ResumableIndexBuildTest.resumableIndexBuildsEnabled(primary)) {
    jsTestLog("Skipping test because resumable index builds are not enabled");
    rst.stopSet();
    return;
}

assert.commandWorked(coll.insert({a: 1}));

ResumableIndexBuildTest.run(rst,
                            dbName,
                            collName,
                            {a: 1},
                            "hangIndexBuildDuringDrainWritesPhase",
                            {iteration: 0},
                            [{a: 2}, {a: 3}]);
ResumableIndexBuildTest.run(rst,
                            dbName,
                            collName,
                            {a: 1},
                            "hangIndexBuildDuringDrainWritesPhase",
                            {iteration: 1},
                            [{a: 4}, {a: 5}],
                            [{a: 6}, {a: 7}]);

rst.stopSet();
})();