2014-11-07 10:48:38 -08:00
|
|
|
// Test the downgrade of a replica set from latest version
|
2015-04-08 06:35:11 -04:00
|
|
|
// to last-stable version succeeds, while reads and writes continue.
|
2014-11-07 10:48:38 -08:00
|
|
|
|
|
|
|
|
load('./jstests/multiVersion/libs/multi_rs.js')
|
|
|
|
|
load('./jstests/libs/test_background_ops.js')
|
|
|
|
|
|
|
|
|
|
var newVersion = "latest";
|
2015-04-08 06:35:11 -04:00
|
|
|
var oldVersion = "last-stable";
|
2014-11-07 10:48:38 -08:00
|
|
|
|
|
|
|
|
var name = "replsetdowngrade";
|
|
|
|
|
var nodes = {n1: {binVersion: newVersion},
|
|
|
|
|
n2: {binVersion: newVersion},
|
|
|
|
|
n3: {binVersion: newVersion}};
|
|
|
|
|
|
2015-05-28 12:15:47 -04:00
|
|
|
var rst = new ReplSetTest({name: name, nodes: nodes, nodeOptions: {storageEngine: 'mmapv1'}});
|
2014-11-07 10:48:38 -08:00
|
|
|
rst.startSet();
|
2015-09-28 05:47:57 -04:00
|
|
|
var replSetConfig = rst.getReplSetConfig();
|
|
|
|
|
replSetConfig.protocolVersion = 0;
|
|
|
|
|
rst.initiate(replSetConfig);
|
2014-11-07 10:48:38 -08:00
|
|
|
|
|
|
|
|
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..");
|
2015-03-12 14:35:01 -04:00
|
|
|
rst.upgradeSet({ binVersion: oldVersion });
|
2014-11-07 10:48:38 -08:00
|
|
|
jsTest.log("Downgrade complete.");
|
|
|
|
|
|
|
|
|
|
primary = rst.getPrimary();
|
|
|
|
|
printjson(rst.status());
|
|
|
|
|
|
|
|
|
|
joinFindInsert();
|
|
|
|
|
rst.stopSet();
|