summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/member_id_too_large.js
blob: 9e514d49a8e90bc2ad923f912001e70e6b7d4b30 (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
// 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();
})();