summaryrefslogtreecommitdiff
path: root/jstests/multiVersion/zero_vote_arbiter_upgrade_downgrade.js
blob: 14e03de3bba68e1b6825cae7c206b6d6c2faf2e6 (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
/*
 * Test zero-vote arbiters during upgrade and downgrade between 2.6 and 2.8.
 * SERVER-13627.
 */

load('./jstests/multiVersion/libs/multi_rs.js');

var oldVersion = '2.6';
var newVersion = 'latest';

/*
 * Create a 2.6 replica set with a 0-vote arbiter and upgrade it to the latest
 * version. Check that we still have a quorum and can elect a primary. Downgrade
 * it, check again.
 */
(function upgradeAndDowngradeRSWithAZeroVoteArbiter() {
    var nodes = {
        n1: {binVersion: oldVersion},
        n2: {binVersion: oldVersion},
        a3: {binVersion: oldVersion}};

    var replTest = new ReplSetTest({nodes: nodes});
    replTest.startSet();
    var conf = replTest.getReplSetConfig();
    conf.members[2].votes = 0;
    replTest.initiate(conf);

    jsTestLog('Upgrade to ' + newVersion);
    replTest.upgradeSet(newVersion);

    // Should be able to elect a primary.
    replTest.getPrimary();

    jsTestLog('Config after upgrade:');
    printjson(replTest.conf());

    jsTestLog('Downgrade to ' + oldVersion);
    replTest.upgradeSet(oldVersion);

    // Should be able to elect a primary.
    replTest.getPrimary();
    jsTestLog('Config after downgrade:');
    printjson(replTest.conf());

    replTest.stopSet();
})();