blob: bbc06c11490e3a5a6cf7c336b433831266348989 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Multiversion initial sync test.
load("./jstests/multiVersion/libs/multi_rs.js");
load("./jstests/replsets/rslib.js");
var oldVersion = "last-stable";
var newVersion = "latest";
var name = "multiversioninitsync";
var multitest = function(replSetVersion, newNodeVersion) {
var nodes = {
n1: {binVersion: replSetVersion},
n2: {binVersion: replSetVersion}
};
print("Start up a two-node " + replSetVersion + " replica set.");
var rst = new ReplSetTest({name: name, nodes: nodes});
rst.startSet();
var config = rst.getReplSetConfig();
// Set protocol version to 0 for 3.2 replset.
if (replSetVersion == newVersion) {
config.protocolVersion = 0;
}
rst.initiate(config);
// Wait for a primary node.
var primary = rst.getPrimary();
// Insert some data and wait for replication.
for (var i = 0; i < 25; i++) {
primary.getDB("foo").foo.insert({_id: i});
}
rst.awaitReplication();
print("Bring up a new node with version " + newNodeVersion + " and add to set.");
rst.add({binVersion: newNodeVersion});
rst.reInitiate();
// Wait for a primary node.
var primary = rst.getPrimary();
var secondaries = rst.getSecondaries();
print("Wait for new node to be synced.");
rst.awaitReplication();
rst.stopSet();
};
// *****************************************
// Test A:
// "Latest" version secondary is synced from
// an old ReplSet.
// *****************************************
multitest(oldVersion, newVersion);
// *****************************************
// Test B:
// Old Secondary is synced from a "latest"
// version ReplSet.
// *****************************************
multitest(newVersion, oldVersion);
|