summaryrefslogtreecommitdiff
path: root/jstests/sharding/move_primary_fails_without_database_version.js
blob: 01b2fe05eae426dba599a8ec5c0df8c1b037bf56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Tests that a movePrimary will fail if the database doesn't have a version in config.databases.

// Do not check metadata consistency as the database version is missing for testing purposes.
TestData.skipCheckMetadataConsistency = true;
TestData.skipCheckRoutingTableConsistency = true;

(function() {
"use strict";

const dbName = "test";

const st = new ShardingTest({shards: 2});

assert.commandWorked(st.s.getDB("config").getCollection("databases").insert({
    _id: dbName,
    primary: st.shard0.shardName
}));

assert.commandFailed(st.s.adminCommand({movePrimary: dbName, to: st.shard1.shardName}));

st.stop();
})();