2017-11-16 16:58:24 -05:00
|
|
|
// Test ReplSet default initiate with localhost-only binding
|
2019-11-07 22:37:42 +00:00
|
|
|
// @tags: [multiversion_incompatible]
|
2017-11-16 16:58:24 -05:00
|
|
|
|
2024-08-20 17:54:15 -04:00
|
|
|
import {ReplSetTest} from "jstests/libs/replsettest.js";
|
|
|
|
|
|
2017-11-16 16:58:24 -05:00
|
|
|
// Select localhost when binding to localhost
|
2019-07-17 10:13:47 -04:00
|
|
|
const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
|
2017-11-16 16:58:24 -05:00
|
|
|
const primary = rt.startSet({bind_ip: undefined})[0];
|
2025-08-21 10:17:44 -07:00
|
|
|
const db = primary.getDB("admin");
|
2017-11-16 16:58:24 -05:00
|
|
|
const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
|
2025-08-21 10:17:44 -07:00
|
|
|
assert(resp.me.startsWith("localhost:"), tojson(resp.me) + " should 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();
|