summaryrefslogtreecommitdiff
path: root/jstests/replsets/initiate_prohibits_w0.js
blob: 84500d064f9bbd9796c0ccedd55fe1b1a5f5f26a (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
/*
 * Test that replSetInitiate prohibits w:0 in getLastErrorDefaults,
 * SERVER-13055.
 * @tags: [multiversion_incompatible]
 */

var InvalidReplicaSetConfig = 93;

var replTest = new ReplSetTest({name: 'prohibit_w0', nodes: 1});
var nodes = replTest.nodeList();
var conns = replTest.startSet();
var admin = conns[0].getDB("admin");

function testInitiate(gleDefaults) {
    var conf = replTest.getReplSetConfig();
    jsTestLog('conf');
    printjson(conf);
    conf.settings = gleDefaults;

    var response = admin.runCommand({replSetInitiate: conf});
    assert.commandFailedWithCode(response, InvalidReplicaSetConfig);
}

/*
 * Try to initiate with w: 0 in getLastErrorDefaults.
 */
testInitiate({getLastErrorDefaults: {w: 0}});

/*
 * Try to initiate with w: 0 and other options in getLastErrorDefaults.
 */
testInitiate({getLastErrorDefaults: {w: 0, j: false, wtimeout: 100, fsync: true}});

replTest.stopSet();