0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00
mongodb/jstests/replsets/localhost3.js

18 lines
654 B
JavaScript

// Test ReplSet default initiate with localhost-only binding
// @tags: [multiversion_incompatible]
(function() {
'use strict';
// Select localhost when binding to localhost
const rt = new ReplSetTest({name: "rsLocal", nodes: 1});
const primary = rt.startSet({bind_ip: undefined})[0];
const db = primary.getDB('admin');
const resp = assert.commandWorked(db.adminCommand({replSetInitiate: undefined}));
assert(resp.me.startsWith('localhost:'), tojson(resp.me) + " should 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();
})();