summaryrefslogtreecommitdiff
path: root/jstests/replsets/localhost2.js
blob: aa3655dd1a2f1c18ad3be47d2359eeb315825621 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Test ReplSet default initiate with 0.0.0.0 binding

(function() {
    'use strict';

    // Select localhost when binding to localhost
    const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
    const primary = rt.startSet({bind_ip: "0.0.0.0"})[0];
    const db = primary.getDB('admin');
    const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
    assert(!resp.me.startsWith('127.0.0.1:'),
           tojson(resp.me) + " should not start with 127.0.0.1:");
    assert(!resp.me.startsWith('0.0.0.0:'), tojson(resp.me) + " should not start with 0.0.0.0:");
    assert(!resp.me.startsWith('localhost:'),
           tojson(resp.me) + " should not start with localhost:");

    // Wait for the primary to complete its election before shutting down the set.
    assert.soon(() => db.runCommand({ismaster: 1}).ismaster);
    rt.stopSet();
})();