summaryrefslogtreecommitdiff
path: root/jstests/sharding/config_rs_change.js
blob: 46a4897996cc610a66679ac376374ca24f6ea81c (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
// Tests that mongos can be given a connection string for the config servers that doesn't exactly
// match the replset config on the config servers, and that it can successfully update it's view
// of the config replset config during startup.

var configRS = new ReplSetTest({name: "configRS", nodes: 1, useHostName: true});
configRS.startSet({configsvr: '', storageEngine: 'wiredTiger'});
var replConfig = configRS.getReplSetConfig();
replConfig.configsvr = true;
configRS.initiate(replConfig);

// Ensure the featureCompatibilityVersion is lastLTSFCV so that the mongos can connect if its
// binary version is lastLTS.
assert.commandWorked(
    configRS.getPrimary().adminCommand({setFeatureCompatibilityVersion: lastLTSFCV}));

// Build a seed list for the config servers to pass to mongos that uses "localhost" for the
// hostnames even though the replica set config uses the hostname.
var configHosts = [];
for (var i = 0; i < configRS.ports.length; i++) {
    configHosts.push("localhost:" + configRS.ports[i]);
}
var configSeedList = configRS.name + "/" + configHosts.join(",");

var mongos = MongoRunner.runMongos({configdb: configSeedList});

// Do some basic operations to ensure that mongos started up successfully despite the discrepancy
// in the config server replset configuration.
assert.commandWorked(mongos.getDB('admin').runCommand('serverStatus'));

MongoRunner.stopMongos(mongos);
configRS.stopSet();