From 73abf8b8a5ea0faec28b261ebaf589c29cd56593 Mon Sep 17 00:00:00 2001 From: Pavi Vetriselvan Date: Thu, 1 Apr 2021 16:41:45 +0000 Subject: SERVER-55715 delay_secs_field_changes_on_upgrade_downgrade.js should account for downgrading to 4.9 --- ...elay_secs_field_changes_on_upgrade_downgrade.js | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/jstests/multiVersion/delay_secs_field_changes_on_upgrade_downgrade.js b/jstests/multiVersion/delay_secs_field_changes_on_upgrade_downgrade.js index d44c2013ca9..daf51e42ccb 100644 --- a/jstests/multiVersion/delay_secs_field_changes_on_upgrade_downgrade.js +++ b/jstests/multiVersion/delay_secs_field_changes_on_upgrade_downgrade.js @@ -37,18 +37,32 @@ function runTest(downgradeFCV) { assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: downgradeFCV})); config = primary.adminCommand({replSetGetConfig: 1}).config; - assert.eq(config.members[1].slaveDelay, 10, tojson(config)); - assert.eq(config.members[1].hasOwnProperty('secondaryDelaySecs'), false, tojson(config)); + + // 'slaveDelay' is disallowed starting in FCV 4.9, so only check for it if + // downgradeFCV < 4.9. Otherwise, check that the config is still using 'secondaryDelaySecs'. + if (MongoRunner.compareBinVersions(downgradeFCV, "4.9") >= 0) { + assert.eq(config.members[1].secondaryDelaySecs, 10, tojson(config)); + assert.eq(config.members[1].hasOwnProperty('slaveDelay'), false, tojson(config)); + } else { + assert.eq(config.members[1].slaveDelay, 10, tojson(config)); + assert.eq(config.members[1].hasOwnProperty('secondaryDelaySecs'), false, tojson(config)); + } config.version++; - // Test that a reconfig with 'slaveDelay' works. + // The following reconfig will use 'slaveDelay' if FCV < 4.9 and 'secondaryDelaySecs' if + // FCV >= 4.9. Both should succeed. assert.commandWorked(primary.adminCommand({replSetReconfig: config})); - delete config.members[1].slaveDelay; - config.members[1].secondaryDelaySecs = 10; + if (MongoRunner.compareBinVersions(downgradeFCV, "4.9") >= 0) { + delete config.members[1].secondaryDelaySecs; + config.members[1].slaveDelay = 10; + } else { + delete config.members[1].slaveDelay; + config.members[1].secondaryDelaySecs = 10; + } config.version++; - // Test that a reconfig with 'secondaryDelaySecs' fails. + // Test that a reconfig with an incompatible field name fails. assert.commandFailedWithCode(primary.adminCommand({replSetReconfig: config}), ErrorCodes.NewReplicaSetConfigurationIncompatible); @@ -76,4 +90,4 @@ function runTest(downgradeFCV) { } runFeatureFlagMultiversionTest('featureFlagUseSecondaryDelaySecs', runTest); -}()); \ No newline at end of file +}()); -- cgit v1.2.1