summaryrefslogtreecommitdiff
path: root/jstests/sharding/mongos_helloOk_protocol.js
blob: 18f102cba30c0b5efba2dd22f0b760b301a83817 (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
/*
 * Tests that when a client sends "helloOk: true" as a part of their isMaster request, mongos
 * will respond with helloOk: true. This ensures that the client knows it can send the hello
 * command.
 *
 * In practice, drivers will send "helloOk: true" in the initial handshake when
 * opening a connection to the database.
 */
(function() {
"use strict";
const st = new ShardingTest({shards: 1, mongos: 1});
const mongos = st.s;

// Simulate an initial handshake request without "helloOk: true". Mongos should not return
// "helloOk: true" in its response.
let res = assert.commandWorked(mongos.adminCommand({isMaster: 1}));
assert.eq(res.helloOk, undefined);

// Simulate an initial handshake request with "helloOk: true". Mongos should now return
// "helloOk: true" in its response.
res = assert.commandWorked(mongos.adminCommand({isMaster: 1, helloOk: true}));
assert.eq("boolean", typeof res.helloOk, "helloOk field is not a boolean" + tojson(res));
assert.eq(res.helloOk, true);

st.stop();
})();