mongo/jstests/replsets/localhost1.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

16 lines
686 B
JavaScript

// Test ReplSet default initiate with localhost-only binding
// @tags: [multiversion_incompatible]
import {ReplSetTest} from "jstests/libs/replsettest.js";
// Select localhost when binding to localhost
const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
const primary = rt.startSet({bind_ip: "127.0.0.1"})[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) + " does not start with 127.0.0.1:");
// Wait for the primary to complete its election before shutting down the set.
assert.soon(() => db.runCommand({hello: 1}).isWritablePrimary);
rt.stopSet();