summaryrefslogtreecommitdiff
path: root/jstests/sharding/arbiters_do_not_use_cluster_time.js
blob: 92ca09b29eb70c0a0f554c7ddb137f1483030631 (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
28
29
30
31
/**
 * Tests that arbiters do not gossip clusterTime or operationTime.
 */

(function() {
"use strict";
let st = new ShardingTest(
    {shards: {rs0: {nodes: [{arbiter: false}, {arbiter: false}, {arbiter: true}]}}});

jsTestLog("Started ShardingTest");

let secondaries = st.rs0.getSecondaries();

let foundArbiter = false;
for (let i = 0; i < secondaries.length; i++) {
    let conn = secondaries[i].getDB("admin");
    const res = conn.runCommand({hello: 1});
    if (res["arbiterOnly"]) {
        assert(!foundArbiter);
        foundArbiter = true;
        // nodes with disabled clocks do not gossip clusterTime and operationTime.
        assert.eq(res.hasOwnProperty("$clusterTime"), false);
        assert.eq(res.hasOwnProperty("operationTime"), false);
    } else {
        assert.eq(res.hasOwnProperty("$clusterTime"), true);
        assert.eq(res.hasOwnProperty("operationTime"), true);
    }
}
assert.eq(foundArbiter, true);
st.stop();
})();