mongo/jstests/replsets/test-egress.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

26 lines
763 B
JavaScript

// Use TestOnly command replSetTestEgress to connect to members.
// @tags: [
// ]
import {ReplSetTest} from "jstests/libs/replsettest.js";
const rst = new ReplSetTest({nodes: 3});
rst.startSet();
rst.initiate();
rst.awaitSecondaryNodes();
const admin = rst.getPrimary().getDB("admin");
jsTest.log("Connecting to any host");
const anyHost = assert.commandWorked(admin.runCommand({replSetTestEgress: 1}));
jsTest.log("Connected to " + anyHost.target);
rst.nodeList().forEach(function (host) {
jsTest.log("Connecting to specific host: " + host);
const node = assert.commandWorked(admin.runCommand({replSetTestEgress: 1, target: host}));
jsTest.log("Connected to specific host: " + node.target);
assert.eq(node.target, host);
});
rst.stopSet();