2017-10-10 14:20:31 -04:00
|
|
|
// Test ReplSet default initiate with 0.0.0.0 binding
|
2019-11-07 22:37:42 +00:00
|
|
|
// @tags: [multiversion_incompatible]
|
2017-10-10 14:20:31 -04:00
|
|
|
|
2024-08-20 17:54:15 -04:00
|
|
|
import {ReplSetTest} from "jstests/libs/replsettest.js";
|
|
|
|
|
|
2017-10-10 14:20:31 -04:00
|
|
|
// Select localhost when binding to localhost
|
2019-07-17 10:13:47 -04:00
|
|
|
const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
|
2017-10-10 14:20:31 -04:00
|
|
|
const primary = rt.startSet({bind_ip: "0.0.0.0"})[0];
|
2025-08-21 10:17:44 -07:00
|
|
|
const db = primary.getDB("admin");
|
2017-10-10 14:20:31 -04:00
|
|
|
const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
|
2025-08-21 10:17:44 -07:00
|
|
|
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:");
|
2019-07-17 10:13:47 -04:00
|
|
|
|
|
|
|
|
// Wait for the primary to complete its election before shutting down the set.
|
2020-09-16 19:33:30 +00:00
|
|
|
assert.soon(() => db.runCommand({hello: 1}).isWritablePrimary);
|
2025-08-21 10:17:44 -07:00
|
|
|
rt.stopSet();
|