summaryrefslogtreecommitdiff
path: root/jstests/replsets/tags2.js
blob: 16fa2157cde2ec43e3c407fa3a2ff4310b686491 (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
// Change a write concern mode from 2 to 3 servers
// @tags: [multiversion_incompatible]

(function() {
"use strict";

var host = getHostName();
var replTest = new ReplSetTest({nodes: 4});
var nodes = replTest.startSet();
var ports = replTest.ports;
var conf = {
    _id: replTest.name,
    members: [
        {_id: 0, host: host + ":" + ports[0], tags: {"backup": "A"}},
        {_id: 1, host: host + ":" + ports[1], tags: {"backup": "B"}},
        {_id: 2, host: host + ":" + ports[2], tags: {"backup": "C"}},
        {_id: 3, host: host + ":" + ports[3], tags: {"backup": "D"}, arbiterOnly: true}
    ],
    settings: {getLastErrorModes: {backedUp: {backup: 2}}}
};

print("arbiters can't have tags");
var result = nodes[0].getDB("admin").runCommand({replSetInitiate: conf});
printjson(result);
assert.eq(result.ok, 0);

conf.members.pop();
replTest.stop(3);
replTest.remove(3);
replTest.initiate(conf);

replTest.awaitReplication();

var primary = replTest.getPrimary();
var db = primary.getDB("test");
var wtimeout = ReplSetTest.kDefaultTimeoutMS;

assert.commandWorked(db.foo.insert({x: 1}, {writeConcern: {w: 'backedUp', wtimeout: wtimeout}}));

var nextVersion = replTest.getReplSetConfigFromNode().version + 1;
conf.version = nextVersion;
conf.settings.getLastErrorModes.backedUp.backup = 3;
primary.getDB("admin").runCommand({replSetReconfig: conf});
replTest.awaitReplication();

primary = replTest.getPrimary();
var db = primary.getDB("test");
assert.commandWorked(db.foo.insert({x: 2}, {writeConcern: {w: 'backedUp', wtimeout: wtimeout}}));

nextVersion++;
conf.version = nextVersion;
conf.members[0].priorty = 3;
conf.members[2].priorty = 0;
primary.getDB("admin").runCommand({replSetReconfig: conf});

primary = replTest.getPrimary();
var db = primary.getDB("test");
assert.commandWorked(db.foo.insert({x: 3}, {writeConcern: {w: 'backedUp', wtimeout: wtimeout}}));

replTest.stopSet();
}());