diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-10-30 15:46:36 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2017-11-09 09:39:44 -0500 |
commit | 271879b7a67c9d9b36778692f2a77e04c6403a1f (patch) | |
tree | a4e8911bcb4ac5a0a494725db9b65e92b0f44ae6 /jstests/multiVersion | |
parent | 9a7ab2468ec94462890395cc591cd629d1dd9f7c (diff) | |
download | mongo-271879b7a67c9d9b36778692f2a77e04c6403a1f.tar.gz |
SERVER-31631 Bump minimum outgoing wire version for mongod when featureCompatibilityVersion is 3.6
Diffstat (limited to 'jstests/multiVersion')
-rw-r--r-- | jstests/multiVersion/feature_compatibility_version_lagging_secondary.js | 68 | ||||
-rw-r--r-- | jstests/multiVersion/migration_between_mixed_FCV_mixed_version_mongods.js | 47 |
2 files changed, 115 insertions, 0 deletions
diff --git a/jstests/multiVersion/feature_compatibility_version_lagging_secondary.js b/jstests/multiVersion/feature_compatibility_version_lagging_secondary.js new file mode 100644 index 00000000000..b56e219cac3 --- /dev/null +++ b/jstests/multiVersion/feature_compatibility_version_lagging_secondary.js @@ -0,0 +1,68 @@ +// Tests that a primary with upgrade featureCompatibilityVersion cannot connect with a secondary +// with a lower binary version. +(function() { + "use strict"; + + load("jstests/libs/write_concern_util.js"); + + const latest = "latest"; + const downgrade = "3.4"; + + const upgradeFCV = "3.6"; + const downgradeFCV = "3.4"; + + function testProtocolVersion(protocolVersion) { + jsTestLog("Testing connections between mixed-version mixed-featureCompatibilityVersion " + + "nodes in a replica set using protocol version " + protocolVersion); + + // Start a new replica set with two latest version nodes. + let rst = new ReplSetTest({ + protocolVersion: protocolVersion, + nodes: [{binVersion: latest}, {binVersion: latest, rsConfig: {priority: 0}}], + settings: {chainingAllowed: false} + }); + rst.startSet(); + + // The default value for 'catchUpTimeoutMillis' on 3.6 is -1. A 3.4 secondary will refuse to + // join a replica set with catchUpTimeoutMillis=-1. + let replSetConfig = rst.getReplSetConfig(); + replSetConfig.settings.catchUpTimeoutMillis = 2000; + rst.initiate(replSetConfig); + + let primary = rst.getPrimary(); + let latestSecondary = rst.getSecondary(); + + // Set the featureCompatibilityVersion to the downgrade version so that a downgrade node can + // join the set. + assert.commandWorked( + primary.getDB("admin").runCommand({setFeatureCompatibilityVersion: downgradeFCV})); + + // Add a downgrade node to the set. + let downgradeSecondary = rst.add({binVersion: downgrade, rsConfig: {priority: 0}}); + rst.reInitiate(); + + // Wait for the downgrade secondary to finish initial sync. + rst.awaitSecondaryNodes(); + rst.awaitReplication(); + + // Stop replication on the downgrade secondary. + stopServerReplication(downgradeSecondary); + + // Set the featureCompatibilityVersion to the upgrade version. This will not replicate to + // the downgrade secondary, but the downgrade secondary will no longer be able to + // communicate with the rest of the set. + assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: upgradeFCV})); + + // Shut down the latest version secondary. + rst.stop(latestSecondary); + + // The primary should step down, since it can no longer see a majority of the replica set. + rst.waitForState(primary, ReplSetTest.State.SECONDARY); + + restartServerReplication(downgradeSecondary); + rst.stopSet(); + } + + testProtocolVersion(0); + testProtocolVersion(1); +})(); diff --git a/jstests/multiVersion/migration_between_mixed_FCV_mixed_version_mongods.js b/jstests/multiVersion/migration_between_mixed_FCV_mixed_version_mongods.js new file mode 100644 index 00000000000..7c79af655b0 --- /dev/null +++ b/jstests/multiVersion/migration_between_mixed_FCV_mixed_version_mongods.js @@ -0,0 +1,47 @@ +/** + * Test that it is not possible to move a chunk from an upgrade featureCompatibilityVersion node to + * a downgrade binary version node. + */ + +// This test will not end with consistent UUIDs, since there is inconsistent +// featureCompatibilityVersion across the cluster. +TestData.skipCheckingUUIDsConsistentAcrossCluster = true; + +(function() { + "use strict"; + + load("jstests/libs/feature_compatibility_version.js"); + + const upgradeVersion = "3.6"; + const downgradeVersion = "3.4"; + + let st = new ShardingTest({ + shards: [{binVersion: "latest"}, {binVersion: downgradeVersion}], + mongos: {binVersion: "latest"} + }); + + let testDB = st.s.getDB("test"); + + // Create a sharded collection with primary shard 0. + assert.commandWorked(st.s.adminCommand({enableSharding: testDB.getName()})); + st.ensurePrimaryShard(testDB.getName(), st.shard0.shardName); + assert.commandWorked( + st.s.adminCommand({shardCollection: testDB.coll.getFullName(), key: {a: 1}})); + + // Set the featureCompatibilityVersion to 3.6. This will fail because the + // featureCompatibilityVersion cannot be set to 3.6 on shard 1, but it will set the + // featureCompatibilityVersion to 3.6 on shard 0. + assert.commandFailed(st.s.adminCommand({setFeatureCompatibilityVersion: upgradeVersion})); + checkFCV(st.configRS.getPrimary().getDB("admin"), downgradeVersion, upgradeVersion); + checkFCV(st.shard0.getDB("admin"), upgradeVersion); + checkFCV34(st.shard1.getDB("admin"), downgradeVersion); + + // It is not possible to move a chunk from an upgrade featureCompatibilityVersion shard to a + // downgrade shard. + assert.commandFailedWithCode( + st.s.adminCommand( + {moveChunk: testDB.coll.getFullName(), find: {a: 1}, to: st.shard1.shardName}), + ErrorCodes.IncompatibleServerVersion); + + st.stop(); +})(); |