summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/genericSetFCVUsage/migration_between_mixed_FCV_mixed_version_mongods.js
blob: fe78152e5483b35eb9940ffd59ba6f0a5b634d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * Test that it is not possible to move a chunk from an upgrade featureCompatibilityVersion node to
 * a downgrade binary version node.
 */

(function() {
    "use strict";

    load("jstests/libs/feature_compatibility_version.js");

    let st = new ShardingTest({
        shards: [{binVersion: "latest"}, {binVersion: "last-stable"}],
        mongos: {binVersion: "latest"},
        other: {shardAsReplicaSet: false},
    });

    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 latestFCV. This will fail because the
    // featureCompatibilityVersion cannot be set to latestFCV on shard 1, but it will set the
    // featureCompatibilityVersion to latestFCV on shard 0.
    assert.commandFailed(st.s.adminCommand({setFeatureCompatibilityVersion: latestFCV}));
    checkFCV(st.configRS.getPrimary().getDB("admin"), lastStableFCV, latestFCV);
    checkFCV(st.shard0.getDB("admin"), latestFCV);
    checkFCV(st.shard1.getDB("admin"), lastStableFCV);

    // It is not possible to move a chunk from a latestFCV shard to a last-stable binary version
    // shard.
    assert.commandFailedWithCode(
        st.s.adminCommand(
            {moveChunk: testDB.coll.getFullName(), find: {a: 1}, to: st.shard1.shardName}),
        ErrorCodes.IncompatibleServerVersion);

    st.stop();
})();