diff options
author | Huayu Ouyang <huayu.ouyang@mongodb.com> | 2020-10-06 15:47:19 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-10-08 21:08:43 +0000 |
commit | c390a3ed067ab283d8d3859b1f60b6fb004e7536 (patch) | |
tree | c668eecad4e33d903a8cd1adddab38ebb38157cc /jstests | |
parent | ecceabf2c79cd9dbbba11705d3d50d99a48f70f5 (diff) | |
download | mongo-c390a3ed067ab283d8d3859b1f60b6fb004e7536.tar.gz |
SERVER-50421 Alias internalValidateFeaturesAsMaster server parameter
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/multiVersion/internal_validate_features_as_master_upgrade_to_latest.js | 91 | ||||
-rw-r--r-- | jstests/noPassthrough/internal_validate_features_as_primary.js | 87 |
2 files changed, 178 insertions, 0 deletions
diff --git a/jstests/multiVersion/internal_validate_features_as_master_upgrade_to_latest.js b/jstests/multiVersion/internal_validate_features_as_master_upgrade_to_latest.js new file mode 100644 index 00000000000..d6de3d3fad1 --- /dev/null +++ b/jstests/multiVersion/internal_validate_features_as_master_upgrade_to_latest.js @@ -0,0 +1,91 @@ +/** + * Tests that setting internalValidateFeaturesOnMaster on 4.4 and then + * upgrading to latest does not cause server to crash and that the + * original server parameter is still set. + */ +(function() { +"use strict"; +load('./jstests/multiVersion/libs/multi_rs.js'); // Used for upgradeSet. + +function runChecksBeforeUpgrade(db, internalValidateFeaturesBool) { + // Verify that we can get the internalValidateFeaturesAsMaster parameter on 4.4. + let res = db.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1}); + assert.commandWorked(res); + assert.eq(res.internalValidateFeaturesAsMaster, internalValidateFeaturesBool); + + // Verify that we cannot get the internalValidateFeaturesAsPrimary parameter on 4.4. + res = db.adminCommand({getParameter: 1, internalValidateFeaturesAsPrimary: 1}); + assert.commandFailed(res); +} + +function runChecksAfterUpgrade(db, port, internalValidateFeaturesBool) { + // Verify that we can still get the internalValidateFeaturesAsMaster parameter on the latest + // binary. + let res = db.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1}); + assert.commandWorked(res); + assert.eq(res.internalValidateFeaturesAsMaster, internalValidateFeaturesBool); + + // However, trying to use the deprecated internalValidateFeaturesAsMaster parameter results + // in a deprecation warning log. + const joinShell = startParallelShell( + "db.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1});", port); + joinShell(); + assert(rawMongoProgramOutput().match( + "\"Use of deprecated server parameter name\",\"attr\":{\"deprecatedName\":\"internalValidateFeaturesAsMaster\"")); + + // Verify that we can also get the internalValidateFeaturesAsPrimary parameter on the latest + // binary. + res = db.adminCommand({getParameter: 1, internalValidateFeaturesAsPrimary: 1}); + assert.commandWorked(res); + assert.eq(res.internalValidateFeaturesAsPrimary, internalValidateFeaturesBool); +} + +function replicaSetTest() { + jsTestLog("Testing on replica set with version last-lts"); + const nodes = { + 0: {binVersion: "4.4"}, + 1: {binVersion: "4.4"}, + }; + + const rst = new ReplSetTest({nodes: nodes}); + rst.startSet(); + rst.initiate(); + let primary = rst.getPrimary(); + + runChecksBeforeUpgrade(primary, true); + + jsTestLog("Upgrading set to latest"); + rst.upgradeSet({binVersion: "latest"}); + primary = rst.getPrimary(); + + jsTestLog("Testing on replica set with version latest"); + runChecksAfterUpgrade(primary, primary.port, true); + + rst.stopSet(); +} + +function standaloneTest() { + jsTestLog("Testing on standalone with version last-lts"); + let conn = MongoRunner.runMongod( + {binVersion: "4.4", setParameter: "internalValidateFeaturesAsMaster=0"}); + assert.neq(null, conn, "mongod was unable to start up"); + + let db = conn.getDB("admin"); + runChecksBeforeUpgrade(db, false); + + MongoRunner.stopMongod(conn); + + jsTest.log("Testing on standalone with version latest"); + conn = MongoRunner.runMongod( + {binVersion: "latest", setParameter: "internalValidateFeaturesAsMaster=0"}); + assert.neq(null, conn, "mongod was unable to start up"); + + db = conn.getDB("admin"); + runChecksAfterUpgrade(db, conn.port, false); + + MongoRunner.stopMongod(conn); +} + +replicaSetTest(); +standaloneTest(); +})(); diff --git a/jstests/noPassthrough/internal_validate_features_as_primary.js b/jstests/noPassthrough/internal_validate_features_as_primary.js new file mode 100644 index 00000000000..5dbc7154e39 --- /dev/null +++ b/jstests/noPassthrough/internal_validate_features_as_primary.js @@ -0,0 +1,87 @@ +/** + * Tests that the internalValidateFeaturesAsPrimary server parameter + * and the deprecated alias internalValidateFeaturesAsMaster both work. + * @tags: [requires_fcv_48] + */ +(function() { +"use strict"; + +// internalValidateFeaturesAsPrimary can be set via startup parameter. +let conn = MongoRunner.runMongod({setParameter: "internalValidateFeaturesAsPrimary=0"}); +assert.neq(null, conn, "mongod was unable to start up"); +let res = conn.adminCommand({getParameter: 1, internalValidateFeaturesAsPrimary: 1}); +assert.commandWorked(res); +assert.eq(res.internalValidateFeaturesAsPrimary, false); + +// Even though we set internalValidateFeaturesAsPrimary, verify that calling +// getParameter with the deprecated alias internalValidateFeaturesAsMaster works +// and uses the value we set for internalValidateFeaturesAsPrimary. +res = conn.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1}); +assert.commandWorked(res); +assert.eq(res.internalValidateFeaturesAsMaster, false); + +// Use of deprecated parameter shows deprecation message. +let joinShell = startParallelShell( + "db.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1});", conn.port); +joinShell(); +assert(rawMongoProgramOutput().match( + "\"Use of deprecated server parameter name\",\"attr\":{\"deprecatedName\":\"internalValidateFeaturesAsMaster\"")); +MongoRunner.stopMongod(conn); + +// internalValidateFeaturesAsMaster can be set via startup parameter. +conn = MongoRunner.runMongod({setParameter: "internalValidateFeaturesAsMaster=1"}); +assert.neq(null, conn, "mongod was unable to start up"); +res = conn.adminCommand({getParameter: 1, internalValidateFeaturesAsMaster: 1}); +assert.commandWorked(res); +assert.eq(res.internalValidateFeaturesAsMaster, true); + +// Verify that calling getParameter with internalValidateFeaturesAsPrimary +// uses the value we set for internalValidateFeaturesAsMaster. +res = conn.adminCommand({getParameter: 1, internalValidateFeaturesAsPrimary: 1}); +assert.commandWorked(res); +assert.eq(res.internalValidateFeaturesAsPrimary, true); +MongoRunner.stopMongod(conn); + +// internalValidateFeaturesAsPrimary cannot be set with --replSet. +conn = MongoRunner.runMongod( + {replSet: "replSetName", setParameter: "internalValidateFeaturesAsPrimary=0"}); +assert.eq(null, conn, "mongod was unexpectedly able to start up"); + +conn = MongoRunner.runMongod( + {replSet: "replSetName", setParameter: "internalValidateFeaturesAsPrimary=1"}); +assert.eq(null, conn, "mongod was unexpectedly able to start up"); + +// Correct error message is logged based on parameter name. +conn = MongoRunner.runMongod({}); +joinShell = startParallelShell(() => { + MongoRunner.runMongod( + {replSet: "replSetName", setParameter: "internalValidateFeaturesAsPrimary=0"}); +}, conn.port); +joinShell(); +let joinShellOutput = rawMongoProgramOutput(); +assert(joinShellOutput.match( + "Cannot specify both internalValidateFeaturesAsPrimary and replication.replSet")); +assert(!joinShellOutput.match( + "Cannot specify both internalValidateFeaturesAsMaster and replication.replSet")); + +clearRawMongoProgramOutput(); +joinShell = startParallelShell(() => { + MongoRunner.runMongod( + {replSet: "replSetName", setParameter: "internalValidateFeaturesAsMaster=0"}); +}, conn.port); +joinShell(); +joinShellOutput = rawMongoProgramOutput(); +assert(joinShellOutput.match( + "Cannot specify both internalValidateFeaturesAsMaster and replication.replSet")); +assert(!joinShellOutput.match( + "Cannot specify both internalValidateFeaturesAsPrimary and replication.replSet")); + +MongoRunner.stopMongod(conn); + +// internalValidateFeaturesAsPrimary cannot be set via runtime parameter. +conn = MongoRunner.runMongod({}); +assert.commandFailed(conn.adminCommand({setParameter: 1, internalValidateFeaturesAsPrimary: true})); +assert.commandFailed( + conn.adminCommand({setParameter: 1, internalValidateFeaturesAsPrimary: false})); +MongoRunner.stopMongod(conn); +}()); |