diff options
Diffstat (limited to 'jstests/noPassthrough/index_stepdown_after_init.js')
-rw-r--r-- | jstests/noPassthrough/index_stepdown_after_init.js | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/jstests/noPassthrough/index_stepdown_after_init.js b/jstests/noPassthrough/index_stepdown_after_init.js index f52fb44899e..a20beef7f00 100644 --- a/jstests/noPassthrough/index_stepdown_after_init.js +++ b/jstests/noPassthrough/index_stepdown_after_init.js @@ -52,13 +52,28 @@ IndexBuildTest.waitForIndexBuildToStop(testDB); const exitCode = createIdx({checkExitSuccess: false}); assert.neq(0, exitCode, 'expected shell to exit abnormally due to index build being terminated'); -// Wait for the IndexBuildCoordinator thread, not the command thread, to report the index build as -// failed. -checkLog.contains(primary, '[IndexBuildsCoordinatorMongod-0] Index build failed: '); +const enableTwoPhaseIndexBuild = + assert.commandWorked(primary.adminCommand({getParameter: 1, enableTwoPhaseIndexBuild: 1})) + .enableTwoPhaseIndexBuild; +if (!enableTwoPhaseIndexBuild) { + // Wait for the IndexBuildCoordinator thread, not the command thread, to report the index build + // as failed. + checkLog.contains(primary, '[IndexBuildsCoordinatorMongod-0] Index build failed: '); -// Check that no new index has been created. This verifies that the index build was aborted -// rather than successfully completed. -IndexBuildTest.assertIndexes(coll, 1, ['_id_']); + // Check that no new index has been created. This verifies that the index build was aborted + // rather than successfully completed. + IndexBuildTest.assertIndexes(coll, 1, ['_id_']); + rst.stopSet(); + return; +} + +// With two phase index builds, a stepdown will not abort the index build, which should complete +// after the node becomes primary again. +rst.awaitReplication(); +IndexBuildTest.assertIndexes(coll, 2, ['_id_', 'a_1']); + +const secondaryColl = rst.getSecondary().getCollection(coll.getFullName()); +IndexBuildTest.assertIndexes(secondaryColl, 2, ['_id_', 'a_1']); rst.stopSet(); })(); |