summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/member_id_too_large.js
blob: d4aad092cbaec8c70f00d589b2c27705383a0f89 (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
// Tests replSetInitiate and replSetReconfig with member _id values greater than the number of
// members in the set, followed by waiting for writeConcern with "w" values equal to size of set.
// @tags: [
//   requires_replication,
// ]
(function() {
"use strict";

const rst = new ReplSetTest({nodes: 2});
rst.startSet();

jsTestLog("replSetInitiate with member _id greater than number of members");

let conf = rst.getReplSetConfig();
conf.members[1]._id = 2;

rst.initiate(conf);

const dbName = "test";
const collName = "test";
const primary = rst.getPrimary();
const testColl = primary.getDB(dbName).getCollection(collName);
const doc = {
    a: 1
};

assert.commandWorked(testColl.insert(doc, {writeConcern: {w: 2}}));

jsTestLog("replSetReconfig with member _id greater than number of members");

let secondary2 = MongoRunner.runMongod({replSet: rst.name});
conf = rst.getReplSetConfigFromNode();
conf.version++;
conf.members.push({_id: 5, host: secondary2.host});
assert.commandWorked(primary.getDB("admin").runCommand({replSetReconfig: conf}));
assert.commandWorked(testColl.insert(doc, {writeConcern: {w: 2}}));
assert.commandWorked(testColl.insert(doc, {writeConcern: {w: 3}}));

MongoRunner.stopMongod(secondary2);
rst.stopSet();
})();