mongo/jstests/replsets/validate_fails_during_rollback.js
Allison Easton 9f9c6ffab5 SERVER-114834 Add ReplicaSets passthrough with priority port enabled (#46506)
GitOrigin-RevId: 85fceb1ddbc4fe384aa29743f3e4eda67cb0e9e6
2026-01-21 10:04:56 +00:00

45 lines
1.3 KiB
JavaScript

/*
* This test makes sure the 'validate' command fails correctly during rollback.
*
* @tags: [
* requires_mongobridge,
* ]
*/
import {RollbackTest} from "jstests/replsets/libs/rollback_test.js";
const dbName = "test";
const collName = "coll";
// Set up Rollback Test.
let rollbackTest = new RollbackTest();
let rollbackNode = rollbackTest.transitionToRollbackOperations();
assert.commandWorked(
rollbackNode.adminCommand({configureFailPoint: "rollbackHangAfterTransitionToRollback", mode: "alwaysOn"}),
);
// Start rollback.
rollbackTest.transitionToSyncSourceOperationsBeforeRollback();
rollbackTest.transitionToSyncSourceOperationsDuringRollback();
// Wait for rollback to hang.
checkLog.contains(rollbackNode, "rollbackHangAfterTransitionToRollback fail point enabled.");
// Try to run the validate command on the rollback node. This should fail with a
// NotPrimaryOrSecondary error.
const result = assert.commandFailedWithCode(
rollbackNode.getDB(dbName).runCommand({"validate": collName}),
ErrorCodes.NotPrimaryOrSecondary,
);
jsTestLog("Validation failed on rollback node as expected: " + tojson(result));
assert.commandWorked(
rollbackNode.adminCommand({configureFailPoint: "rollbackHangAfterTransitionToRollback", mode: "off"}),
);
rollbackTest.transitionToSteadyStateOperations();
// Check the replica set.
rollbackTest.stop();