summaryrefslogtreecommitdiff
path: root/jstests/replsets/test-egress.js
blob: fad2e4d62f8e3365ac091e12c07f99a62f2a72fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Use TestOnly command replSetTestEgress to connect to members.
// @tags: [
// ]

(function() {
'use strict';

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();
}());