summaryrefslogtreecommitdiff
path: root/jstests/sharding/arbiters_do_not_use_cluster_time.js
blob: 70f3469679f3c597492fcc8d52d4312699f44629 (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
32
33
34
35
36
37
38
39
40
41
42
/**
 * 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},
                {arbiter: false},
                {arbiter: false}
            ]
        }
    }
});

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