0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 20:49:10 +01:00
mongodb/jstests/replsets/reconfig_prohibits_w0.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

37 lines
1.0 KiB
JavaScript

/*
* Test that replSetReconfig prohibits w:0 in getLastErrorDefaults,
* SERVER-13055.
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
var replTest = new ReplSetTest({name: 'prohibit_w0', nodes: 1});
var nodes = replTest.nodeList();
var conns = replTest.startSet();
var admin = conns[0].getDB("admin");
replTest.initiate({_id: 'prohibit_w0', members: [{_id: 0, host: nodes[0]}]});
function testReconfig(gleDefaults) {
var conf = admin.runCommand({replSetGetConfig: 1}).config;
jsTestLog('conf');
printjson(conf);
conf.settings = gleDefaults;
conf.version++;
var response = admin.runCommand({replSetReconfig: conf});
assert.commandFailedWithCode(response, ErrorCodes.InvalidReplicaSetConfig);
}
/*
* Try to reconfig with w: 0 in getLastErrorDefaults.
*/
testReconfig({getLastErrorDefaults: {w: 0}});
/*
* Try to reconfig with w: 0 and other options in getLastErrorDefaults.
*/
testReconfig({getLastErrorDefaults: {w: 0, j: false, wtimeout: 100, fsync: true}});
replTest.stopSet();