diff options
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/standalone_replication_recovery.js | 6 | ||||
-rw-r--r-- | jstests/replsets/validate_fails_during_rollback.js | 38 |
2 files changed, 44 insertions, 0 deletions
diff --git a/jstests/noPassthrough/standalone_replication_recovery.js b/jstests/noPassthrough/standalone_replication_recovery.js index 6ee47fc9c20..55a6bb8e00c 100644 --- a/jstests/noPassthrough/standalone_replication_recovery.js +++ b/jstests/noPassthrough/standalone_replication_recovery.js @@ -79,6 +79,9 @@ node = rst.start(node, {noReplSet: true, setParameter: {logComponentVerbosity: l reconnect(node); assertDocsInColl(node, []); +// Test that we can run the validate command on a standalone. +assert.commandWorked(node.getDB(dbName).runCommand({"validate": collName})); + jsTestLog("Test that on restart with the flag set we play recovery."); node = rst.restart(node, { noReplSet: true, @@ -87,6 +90,9 @@ node = rst.restart(node, { reconnect(node); assertDocsInColl(node, [3, 4, 5]); +// Test that we can run the validate command on a standalone that recovered. +assert.commandWorked(node.getDB(dbName).runCommand({"validate": collName})); + jsTestLog("Test that we go into read-only mode."); assert.commandFailedWithCode(getColl(node).insert({_id: 1}), ErrorCodes.IllegalOperation); diff --git a/jstests/replsets/validate_fails_during_rollback.js b/jstests/replsets/validate_fails_during_rollback.js new file mode 100644 index 00000000000..8c67d33fd1a --- /dev/null +++ b/jstests/replsets/validate_fails_during_rollback.js @@ -0,0 +1,38 @@ +/* + * This test makes sure the 'validate' command fails correctly during rollback. + */ +(function() { +"use strict"; + +load("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 NotMaster error. +assert.commandFailedWithCode(rollbackNode.getDB(dbName).runCommand({"validate": collName}), + ErrorCodes.NotMasterOrSecondary); + +assert.commandWorked(rollbackNode.adminCommand( + {configureFailPoint: "rollbackHangAfterTransitionToRollback", mode: "off"})); + +rollbackTest.transitionToSteadyStateOperations(); + +// Check the replica set. +rollbackTest.stop(); +}()); |