summaryrefslogtreecommitdiff
path: root/jstests/sharding/conn_pool_stats.js
blob: 0476d3f75419a2bd8671a71b263a763d471dd0b0 (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
// Tests for the connPoolStats command.
(function() {
"use strict";
// Create a cluster with 2 shards.
var cluster = new ShardingTest({shards: 2});

// Needed because the command was expanded post 3.2
var version = cluster.s.getDB("admin").runCommand({buildinfo: 1}).versionArray;
var post32 = (version[0] > 4) || ((version[0] == 3) && (version[1] > 2));

// Run the connPoolStats command
var stats = cluster.s.getDB("admin").runCommand({connPoolStats: 1});

// Validate output
printjson(stats);
assert.commandWorked(stats);
assert("replicaSets" in stats);
assert("hosts" in stats);
assert("numClientConnections" in stats);
assert("numAScopedConnections" in stats);
assert("totalInUse" in stats);
assert("totalAvailable" in stats);
assert("totalCreated" in stats);
assert.lte(stats["totalInUse"] + stats["totalAvailable"], stats["totalCreated"], tojson(stats));
if (post32) {
    assert("pools" in stats);
    assert("totalRefreshing" in stats);
    assert.lte(stats["totalInUse"] + stats["totalAvailable"] + stats["totalRefreshing"],
               stats["totalCreated"],
               tojson(stats));
}
cluster.stop();
})();