summaryrefslogtreecommitdiff
path: root/jstests/sharding/conn_pool_stats.js
blob: ef15f73bdab01a3299cee25a8f4f4ecef8c4dd59 (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
// Tests for the connPoolStats command.

// Create a cluster with 2 shards.
var cluster = new ShardingTest({shards: 2});

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

// Validate output
printjson(stats);
assert.commandWorked(stats);
assert("replicaSets" in stats);

assert("pools" in stats);
var pools = stats["pools"];

// Stats from dbclient pool
assert("DBClient (Global)" in pools);
var dbclient = pools["DBClient (Global)"];
assert("hosts" in dbclient);
assert("numClientConnection" in dbclient);
assert("numAScopedConnection" in dbclient);
assert("totalInUse" in dbclient);
assert("totalAvailable" in dbclient);
assert("totalCreated" in dbclient);
assert.lte(dbclient["totalInUse"] + dbclient["totalAvailable"], dbclient["totalCreated"], tojson(dbclient));

// Stats from ASIO pool
assert("NetworkInterfaceASIO (Sharding)" in pools);
var asio = pools["NetworkInterfaceASIO (Sharding)"];
assert("hosts" in asio);
assert("totalInUse" in asio);
assert("totalAvailable" in asio);
assert("totalCreated" in asio);
assert.lte(asio["totalInUse"] + asio["totalAvailable"], asio["totalCreated"], tojson(asio));