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
|
// Test the downgrade of a replica set from latest version
// to last-stable version succeeds, while reads and writes continue.
load('./jstests/multiVersion/libs/multi_rs.js');
load('./jstests/libs/test_background_ops.js');
var newVersion = "latest";
var oldVersion = "last-stable";
var name = "replsetdowngrade";
var nodes = {
n1: {binVersion: newVersion},
n2: {binVersion: newVersion},
n3: {binVersion: newVersion}
};
var rst = new ReplSetTest({name: name, nodes: nodes, nodeOptions: {storageEngine: 'mmapv1'}});
rst.startSet();
var replSetConfig = rst.getReplSetConfig();
replSetConfig.protocolVersion = 0;
rst.initiate(replSetConfig);
var primary = rst.getPrimary();
var coll = "test.foo";
jsTest.log("Inserting documents into collection.");
for (var i = 0; i < 10; i++) {
primary.getCollection(coll).insert({_id: i, str: "hello world"});
}
function insertDocuments(rsURL, coll) {
var coll = new Mongo(rsURL).getCollection(coll);
var count = 10;
while (!isFinished()) {
assert.writeOK(coll.insert({_id: count, str: "hello world"}));
count++;
}
}
jsTest.log("Starting parallel operations during downgrade..");
var joinFindInsert = startParallelOps(primary, insertDocuments, [rst.getURL(), coll]);
jsTest.log("Downgrading replica set..");
rst.upgradeSet({binVersion: oldVersion});
jsTest.log("Downgrade complete.");
primary = rst.getPrimary();
printjson(rst.status());
joinFindInsert();
rst.stopSet();
|