summaryrefslogtreecommitdiff
path: root/jstests/replsets/rollbacktest_unittest.js
blob: 4cc2728b259c6e47cedd7d00955bdcacf4e7ebf5 (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
/**
 * Test of the RollbackTest helper library.
 */
(function() {
"use strict";

load("jstests/replsets/rslib.js");
load("jstests/replsets/libs/rollback_test.js");

let checkDataConsistencyCallCount = 0;
let stopSetCallCount = 0;

const rollbackTest = new RollbackTest("rollbacktest_unittest");
rollbackTest._checkDataConsistencyImpl = function() {
    ++checkDataConsistencyCallCount;
};

const rst = rollbackTest.getTestFixture();
rst.stopSet = function(signal, forRestart, opts) {
    // Unconditionally skip in rst.stopSet because rbt.stop does its own validation.
    assert.eq(opts, {"skipCheckDBHashes": true, "skipValidation": true});
    ++stopSetCallCount;

    // We don't care about doing the regular stopSet actions.
    for (let i = rst.nodeList().length - 1; i >= 0; --i) {
        rst.stop(i);
    }
};

rollbackTest.transitionToRollbackOperations();
rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
rollbackTest.transitionToSyncSourceOperationsDuringRollback();
rollbackTest.transitionToSteadyStateOperations();

rollbackTest.stop();

assert.eq(checkDataConsistencyCallCount, 1);
assert.eq(stopSetCallCount, 1);
})();