summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/ftdc_connection_reuse.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthrough/ftdc_connection_reuse.js')
-rw-r--r--jstests/noPassthrough/ftdc_connection_reuse.js38
1 files changed, 25 insertions, 13 deletions
diff --git a/jstests/noPassthrough/ftdc_connection_reuse.js b/jstests/noPassthrough/ftdc_connection_reuse.js
index 4d490870d67..f5e34b06af0 100644
--- a/jstests/noPassthrough/ftdc_connection_reuse.js
+++ b/jstests/noPassthrough/ftdc_connection_reuse.js
@@ -26,12 +26,24 @@ const kOperations = 5;
const testDB = st.s.getDB(kDbName);
const coll = testDB.getCollection(kCollName);
-function getDiagnosticData() {
+function getDiagnosticData(mustHavePool) {
let stats;
- assert.soon(() => {
- stats = verifyGetDiagnosticData(st.s.getDB("admin")).connPoolStats;
- return stats["pools"].hasOwnProperty('NetworkInterfaceTL-TaskExecutorPool-0');
- }, "Failed to load NetworkInterfaceTL-TaskExecutorPool-0 in FTDC within time limit");
+ try {
+ assert.soon(
+ () => {
+ stats = verifyGetDiagnosticData(st.s.getDB("admin")).connPoolStats;
+ return stats["pools"].hasOwnProperty('NetworkInterfaceTL-TaskExecutorPool-0');
+ },
+ "Failed to load NetworkInterfaceTL-TaskExecutorPool-0 in FTDC within time limit",
+ 5000,
+ undefined,
+ {runHangAnalyzer: mustHavePool});
+ } catch (e) {
+ // If the above assert.soon fails, and we must have a pool, fail out. Otherwise return empty
+ // stats.
+ assert(!mustHavePool, e);
+ return null;
+ }
assert(stats.hasOwnProperty('totalWasUsedOnce'));
assert(stats.hasOwnProperty('totalConnUsageTimeMillis'));
return stats["pools"]["NetworkInterfaceTL-TaskExecutorPool-0"];
@@ -78,9 +90,9 @@ function resetPools() {
// FTDC data is collected periodically. Check that the data returned reflects that the pools
// have been dropped before resuming testing.
assert.soon(() => {
- const stats = getDiagnosticData();
+ const stats = getDiagnosticData(false /* mustHavePool */);
// The shard has a single node in its replica set.
- return !stats.hasOwnProperty(allHosts[0]);
+ return !stats || !stats.hasOwnProperty(allHosts[0]);
}, "Failed to wait for pool stats to reflect dropped pools");
}
@@ -89,19 +101,19 @@ st.rs0.awaitReplication();
// Check that the amount of time connections from the pool are in-use monotonically increases with
// each operation that is run.
-let previous = getDiagnosticData()["poolConnUsageTimeMillis"];
+let previous = getDiagnosticData(true /* mustHavePool */)["poolConnUsageTimeMillis"];
let initialVal = previous;
for (let i = 0; i < kOperations; i++) {
jsTestLog("Issuing find #" + i);
assert.commandWorked(testDB.runCommand({"find": kCollName}));
assert.soon(() => {
- let poolStats = getDiagnosticData();
+ let poolStats = getDiagnosticData(true /* mustHavePool */);
return poolStats["poolConnUsageTimeMillis"] >= previous;
}, "poolConnUsageTime failed to update within time limit", 10 * 1000);
- let res = getDiagnosticData()["poolConnUsageTimeMillis"];
+ let res = getDiagnosticData(true /* mustHavePool */)["poolConnUsageTimeMillis"];
previous = res;
}
-assert.gte(getDiagnosticData()["poolConnUsageTimeMillis"],
+assert.gte(getDiagnosticData(true /* mustHavePool */)["poolConnUsageTimeMillis"],
initialVal,
"poolConnUsageTimeMillis failed to increase after issuing find operations");
@@ -118,7 +130,7 @@ jsTestLog("Launching blocked finds");
configureReplSetFailpoint("waitInFindBeforeMakingBatch", "alwaysOn");
launchFinds({times: 3, readPref: "primary"});
assert.soon(() => {
- let poolStats = getDiagnosticData();
+ let poolStats = getDiagnosticData(true /* mustHavePool */);
return poolStats["poolInUse"] == 3;
}, "Launched finds failed to be marked as inUse within time limit", 10 * 1000);
@@ -129,7 +141,7 @@ configureReplSetFailpoint("waitInFindBeforeMakingBatch", "off");
assert.commandWorked(st.s.adminCommand(
{"setParameter": 1, ShardingTaskExecutorPoolMinSize: 1, ShardingTaskExecutorPoolMaxSize: 1}));
assert.soon(() => {
- let poolStats = getDiagnosticData();
+ let poolStats = getDiagnosticData(true /* mustHavePool */);
return poolStats["poolInUse"] == 0 && poolStats["poolWasUsedOnce"] == 2;
}, "Dropped connections failed to be marked as wasUsedOnce within time limit", 20 * 1000);