2
// Tests initialization of an empty cluster with multiple mongoses.
3
// Starts a bunch of mongoses in parallel, and ensures that there's only a single config
4
// version initialization.
7
jsTest.log("Start config servers...")
9
var configSvrA = MongoRunner.runMongod({ verbose : 2 });
10
var configSvrB = MongoRunner.runMongod({ verbose : 2 });
11
var configSvrC = MongoRunner.runMongod({ verbose : 2 });
13
var configConnStr = [configSvrA.host, configSvrB.host, configSvrC.host].join(",");
15
var configConn = configSvrA;
17
// Start profiling the config db
18
configConn.getDB("config").setProfilingLevel(2);
21
// Start a bunch of mongoses which will probably interfere
24
jsTest.log("Starting first set of mongoses in parallel...");
27
for (var i = 0; i < 3; i++) {
28
var mongos = MongoRunner.runMongos({ binVersion : "latest",
29
configdb : configConnStr,
30
waitForConnect : false });
32
mongoses.push(mongos);
35
// Eventually connect to a mongo host, to be sure that the config upgrade happened
36
var mongosConn = null;
37
assert.soon(function() {
39
mongosConn = new Mongo(mongoses[0].host);
43
print("Waiting for connect...");
49
var version = mongosConn.getCollection("config.version").findOne();
52
// Start a second set of mongoses which should respect the initialized version
55
jsTest.log("Starting second set of mongoses...");
57
for (var i = 0; i < 3; i++) {
58
var mongos = MongoRunner.runMongos({ binVersion : "latest",
59
configdb : configConnStr,
60
waitForConnect : false });
62
mongoses.push(mongos);
65
// Eventually connect to a host
66
assert.soon(function() {
68
mongosConn = new Mongo(mongoses[mongoses.length - 1].host);
72
print("Waiting for connect...");
78
// Shut down our mongoses now that we've tested them
79
for (var i = 0; i < mongoses.length; i++) {
80
MongoRunner.stopMongos(mongoses[i]);
83
jsTest.log("Mongoses stopped...");
86
// Check version and that the version was only updated once
91
assert.eq(version.version, 3);
92
assert.eq(version.minCompatibleVersion, 3);
93
assert.eq(version.currentVersion, 4);
94
assert(version.clusterId);
95
assert.eq(version.excluding, undefined);
97
jsTest.log("Ensuring config.version collection only written once...");
99
var updates = configConn.getDB("config").system.profile.find({ op : "update",
100
ns : "config.version" }).toArray();
102
assert.eq(updates.length, 1);
104
MongoRunner.stopMongod(configSvrA);
105
MongoRunner.stopMongod(configSvrB);
106
MongoRunner.stopMongod(configSvrC);