summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/ftdc_connection_pool.js
blob: 351713c5a8c3c3e388da5a8aa1f54dc345f41ace (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
/**
 * The FTDC connection pool stats from mongos are a different structure than the connPoolStats
 * command, verify its contents.
 *
 * @tags: [requires_sharding]
 */
load('jstests/libs/ftdc.js');

(function() {
    'use strict';
    const testPath = MongoRunner.toRealPath('ftdc_dir');
    const st = new ShardingTest({
        shards: 2,
        mongos: {
            s0: {setParameter: {diagnosticDataCollectionDirectoryPath: testPath}},
        }
    });

    const admin = st.s0.getDB('admin');
    const stats = verifyGetDiagnosticData(admin).connPoolStats;
    jsTestLog(`Diagnostic connection pool stats: ${tojson(stats)}`);

    assert(stats.hasOwnProperty('totalInUse'));
    assert(stats.hasOwnProperty('totalAvailable'));
    assert(stats.hasOwnProperty('totalCreated'));
    assert(stats.hasOwnProperty('totalRefreshing'));
    assert("getHostAndRefresh" in stats["replicaSetMonitor"]);
    const getHostStats = stats["replicaSetMonitor"]["getHostAndRefresh"];
    assert(getHostStats.hasOwnProperty('currentlyActive'));
    assert("hello" in stats["replicaSetMonitor"]);
    const helloStats = stats["replicaSetMonitor"]["hello"];
    assert(helloStats.hasOwnProperty('currentlyActive'));

    // The connPoolStats command reply has "hosts", but FTDC's stats do not.
    assert(!stats.hasOwnProperty('hosts'));

    // Check a few properties, without attempting to be thorough.
    assert(stats.connectionsInUsePerPool.hasOwnProperty('NetworkInterfaceTL-ShardRegistry'));
    assert(stats.replicaSetPingTimesMillis.hasOwnProperty(st.configRS.name));

    st.stop();
})();