diff options
author | Jonathan Reams <jbreams@mongodb.com> | 2018-06-22 15:15:12 -0400 |
---|---|---|
committer | Jonathan Reams <jbreams@mongodb.com> | 2018-08-16 16:45:00 -0400 |
commit | 1a643ba65b070c167cdfdd5056c7d2ac79dd5371 (patch) | |
tree | b284d5df88bfa8cd5d499e83de319ddd7055f00a /jstests/noPassthrough/max_conns_override.js | |
parent | 611460d96bf33a7654581ca23c4daad974b0ce45 (diff) | |
download | mongo-1a643ba65b070c167cdfdd5056c7d2ac79dd5371.tar.gz |
SERVER-34986 Allow connections to override maxConns based on CIDR range
Diffstat (limited to 'jstests/noPassthrough/max_conns_override.js')
-rw-r--r-- | jstests/noPassthrough/max_conns_override.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/jstests/noPassthrough/max_conns_override.js b/jstests/noPassthrough/max_conns_override.js new file mode 100644 index 00000000000..8d280b3c7a4 --- /dev/null +++ b/jstests/noPassthrough/max_conns_override.js @@ -0,0 +1,44 @@ +(function() { + 'use strict'; + const configuredMaxConns = 5; + const configuredReadyAdminThreads = 3; + let conn = MongoRunner.runMongod({ + config: "jstests/noPassthrough/libs/max_conns_override_config.yaml", + // We check a specific field in this executor's serverStatus section + serviceExecutor: "synchronous", + }); + + // Use up all the maxConns with junk connections, all of these should succeed + let maxConns = []; + for (let i = 0; i < 5; i++) { + maxConns.push(new Mongo(`127.0.0.1:${conn.port}`)); + let tmpDb = maxConns[maxConns.length - 1].getDB("admin"); + assert.commandWorked(tmpDb.runCommand({isMaster: 1})); + } + + // Get serverStatus to check that we have the right number of threads in the right places + let status = conn.getDB("admin").runCommand({serverStatus: 1}); + const connectionsStatus = status["connections"]; + const reservedExecutorStatus = connectionsStatus["adminConnections"]; + const normalExecutorStatus = status["network"]["serviceExecutorTaskStats"]; + + // Log these serverStatus sections so we can debug this easily + print("connections status section: ", tojson(connectionsStatus)); + print("normal executor status section: ", tojson(normalExecutorStatus)); + + // The number of "available" connections should be less than zero, because we've used + // all of maxConns. We're over the limit! + assert.lt(connectionsStatus["available"], 0); + // The number of "current" connections should be greater than maxConns + assert.gt(connectionsStatus["current"], configuredMaxConns); + // The number of ready threads should be the number of readyThreads we configured, since + // every thread spawns a new thread on startup + assert.eq(reservedExecutorStatus["readyThreads"], configuredReadyAdminThreads); + // The number of running admin threads should be greater than the readyThreads, because + // one is being used right now + assert.gt(reservedExecutorStatus["threadsRunning"], reservedExecutorStatus["readyThreads"]); + // The normal serviceExecutor should only be running maxConns number of threads + assert.eq(normalExecutorStatus["threadsRunning"], configuredMaxConns); + + MongoRunner.stopMongod(conn); +})(); |