Files
mongo/jstests/replsets/rollback_unclean_shutdowns_parameter_obeyed.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

37 lines
1.3 KiB
JavaScript

/**
* Verify that the 'TestData.allowUncleanShutdowns' parameter is correctly obeyed in RollbackTest.
* We test that nodes can only be shut down with the SIGTERM signal (15), not SIGKILL (9), when
* allowUncleanShutdowns=false.
*
* @tags: [requires_persistence]
*/
import {RollbackTest} from "jstests/replsets/libs/rollback_test.js";
TestData.rollbackShutdowns = true;
// Only clean shutdowns should be allowed.
TestData.allowUncleanShutdowns = false;
let dbName = "test";
let collName = "coll";
// Execute a simple rollback. The specific documents are unimportant.
let rollbackTest = new RollbackTest(jsTestName());
assert.commandWorked(rollbackTest.getPrimary().getDB(dbName)[collName].insert({}));
let rollbackNode = rollbackTest.transitionToRollbackOperations();
assert.commandWorked(rollbackNode.getDB(dbName)[collName].insert({}));
// Neither of these should be allowed to shut down the node uncleanly.
const SIGKILL = 9;
rollbackTest.restartNode(1, SIGKILL);
rollbackTest.restartNode(1, SIGKILL);
rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
rollbackTest.transitionToSyncSourceOperationsDuringRollback();
rollbackTest.transitionToSteadyStateOperations();
// Make sure no unclean shutdowns occurred.
const subStr = "Detected unclean shutdown";
assert.eq(rawMongoProgramOutput(subStr).search(subStr), -1);
rollbackTest.stop();