summaryrefslogtreecommitdiff
path: root/jstests/replsets/rollback_resumable_index_build_complete.js
blob: 51f5988f4c9237d62281f21e989ca40bd1881909 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
 * Tests that resumable index builds restart and complete properly when rolling back from after the
 * index build completed to while the index build was still in progress.
 *
 * @tags: [
 *   requires_fcv_47,
 *   requires_majority_read_concern,
 *   requires_persistence,
 * ]
 */
(function() {
"use strict";

load('jstests/replsets/libs/rollback_resumable_index_build.js');

// TODO(SERVER-50775): Re-enable when stepdown issues are fixed in resumable index rollback tests.
if (true) {
    jsTestLog('Skipping test.');
    return;
}

const dbName = "test";
const insertsToBeRolledBack = [{a: 7}, {a: 8}];

const rollbackTest = new RollbackTest(jsTestName());
const coll = rollbackTest.getPrimary().getDB(dbName).getCollection(jsTestName());

assert.commandWorked(coll.insert([{a: 1}, {a: 2}, {a: 3}]));

// Rollback to before the index begins to be built.
RollbackResumableIndexBuildTest.runIndexBuildComplete(rollbackTest,
                                                      dbName,
                                                      coll.getName(),
                                                      {a: 1},
                                                      "hangAfterSettingUpIndexBuildUnlocked",
                                                      {},
                                                      insertsToBeRolledBack);

// Rollback to the collection scan phase.
RollbackResumableIndexBuildTest.runIndexBuildComplete(
    rollbackTest,
    dbName,
    coll.getName(),
    {a: 1},
    "hangIndexBuildDuringCollectionScanPhaseBeforeInsertion",
    {fieldsToMatch: {a: 2}},
    insertsToBeRolledBack);

// Rollback to the bulk load phase.
RollbackResumableIndexBuildTest.runIndexBuildComplete(rollbackTest,
                                                      dbName,
                                                      coll.getName(),
                                                      {a: 1},
                                                      "hangIndexBuildDuringBulkLoadPhase",
                                                      {iteration: 1},
                                                      insertsToBeRolledBack);

// Rollback to the drain writes phase.
RollbackResumableIndexBuildTest.runIndexBuildComplete(rollbackTest,
                                                      dbName,
                                                      coll.getName(),
                                                      {a: 1},
                                                      "hangIndexBuildDuringDrainWritesPhase",
                                                      {iteration: 1},
                                                      insertsToBeRolledBack,
                                                      [{a: 4}, {a: 5}, {a: 6}]);

rollbackTest.stop();
})();