2016-04-22 20:10:33 +02:00
|
|
|
/**
|
|
|
|
* Tests that the config server connection string in the shard identity document of both the
|
|
|
|
* primary and secondary will get updated whenever the config server membership changes.
|
2016-05-06 22:12:40 +02:00
|
|
|
* @tags: [requires_persistence]
|
2016-04-22 20:10:33 +02:00
|
|
|
*/
|
2017-10-06 21:12:40 +02:00
|
|
|
|
|
|
|
// Checking UUID consistency involves talking to a shard node, which in this test is shutdown
|
|
|
|
TestData.skipCheckingUUIDsConsistentAcrossCluster = true;
|
|
|
|
|
2016-04-22 20:10:33 +02:00
|
|
|
(function() {
|
2019-07-27 00:20:35 +02:00
|
|
|
"use strict";
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
load('jstests/replsets/rslib.js');
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var st = new ShardingTest({shards: {rs0: {nodes: 2}}});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var shardPri = st.rs0.getPrimary();
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
// Note: Adding new replica set member by hand because of SERVER-24011.
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var newNode =
|
|
|
|
MongoRunner.runMongod({configsvr: '', replSet: st.configRS.name, storageEngine: 'wiredTiger'});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var replConfig = st.configRS.getReplSetConfigFromNode();
|
|
|
|
replConfig.version += 1;
|
|
|
|
replConfig.members.push({_id: 3, host: newNode.host});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
reconfig(st.configRS, replConfig);
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
/**
|
|
|
|
* Returns true if the shardIdentity document has all the replica set member nodes in the
|
|
|
|
* expectedConfigStr.
|
|
|
|
*/
|
|
|
|
var checkConfigStrUpdated = function(conn, expectedConfigStr) {
|
|
|
|
var shardIdentity = conn.getDB('admin').system.version.findOne({_id: 'shardIdentity'});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var shardConfigsvrStr = shardIdentity.configsvrConnectionString;
|
|
|
|
var shardConfigReplName = shardConfigsvrStr.split('/')[0];
|
|
|
|
var expectedReplName = expectedConfigStr.split('/')[0];
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.eq(expectedReplName, shardConfigReplName);
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var expectedHostList = expectedConfigStr.split('/')[1].split(',');
|
|
|
|
var shardConfigHostList = shardConfigsvrStr.split('/')[1].split(',');
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
if (expectedHostList.length != shardConfigHostList.length) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
for (var x = 0; x < expectedHostList.length; x++) {
|
|
|
|
if (shardConfigsvrStr.indexOf(expectedHostList[x]) == -1) {
|
|
|
|
return false;
|
2016-04-22 20:10:33 +02:00
|
|
|
}
|
2019-07-27 00:20:35 +02:00
|
|
|
}
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
return true;
|
|
|
|
};
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var origConfigConnStr = st.configRS.getURL();
|
|
|
|
var expectedConfigStr = origConfigConnStr + ',' + newNode.host;
|
|
|
|
assert.soon(function() {
|
|
|
|
return checkConfigStrUpdated(st.rs0.getPrimary(), expectedConfigStr);
|
|
|
|
});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
var secConn = st.rs0.getSecondary();
|
|
|
|
secConn.setSlaveOk(true);
|
|
|
|
assert.soon(function() {
|
|
|
|
return checkConfigStrUpdated(secConn, expectedConfigStr);
|
|
|
|
});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
//
|
|
|
|
// Remove the newly added member from the config replSet while the shards are down.
|
|
|
|
// Check that the shard identity document will be updated with the new replSet connection
|
|
|
|
// string when they come back up.
|
|
|
|
//
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
st.rs0.stop(0);
|
|
|
|
st.rs0.stop(1);
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
MongoRunner.stopMongod(newNode);
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
replConfig = st.configRS.getReplSetConfigFromNode();
|
|
|
|
replConfig.version += 1;
|
|
|
|
replConfig.members.pop();
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
reconfig(st.configRS, replConfig);
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
st.rs0.restart(0, {shardsvr: ''});
|
|
|
|
st.rs0.restart(1, {shardsvr: ''});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
st.rs0.waitForMaster();
|
|
|
|
st.rs0.awaitSecondaryNodes();
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
assert.soon(function() {
|
|
|
|
return checkConfigStrUpdated(st.rs0.getPrimary(), origConfigConnStr);
|
|
|
|
});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
secConn = st.rs0.getSecondary();
|
|
|
|
secConn.setSlaveOk(true);
|
|
|
|
assert.soon(function() {
|
|
|
|
return checkConfigStrUpdated(secConn, origConfigConnStr);
|
|
|
|
});
|
2016-04-22 20:10:33 +02:00
|
|
|
|
2019-07-27 00:20:35 +02:00
|
|
|
st.stop();
|
2016-04-22 20:10:33 +02:00
|
|
|
})();
|