diff options
author | Davis Haupt <davis.haupt@mongodb.com> | 2021-12-15 21:26:52 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-12-28 23:18:25 +0000 |
commit | c53285719d4b039f0e973cb120c2e90874c303b8 (patch) | |
tree | 07f2b412edfaf068211e51307843e30818abe33b /jstests | |
parent | 86de78310d82cd0bafc6dbd5fcdbacfed6223c8d (diff) | |
download | mongo-c53285719d4b039f0e973cb120c2e90874c303b8.tar.gz |
SERVER-61220 Integration test for progress monitor
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/health_monitor/progress_monitor.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/jstests/sharding/health_monitor/progress_monitor.js b/jstests/sharding/health_monitor/progress_monitor.js new file mode 100644 index 00000000000..fc243da4401 --- /dev/null +++ b/jstests/sharding/health_monitor/progress_monitor.js @@ -0,0 +1,50 @@ +const PROGRESS_TIMEOUT_SECONDS = 5; +const CHECK_PING_SECONDS = 1; +(function() { +'use strict'; + +const params = { + setParameter: { + healthMonitoringIntensities: tojson({test: "non-critical", ldap: "off", dns: "off"}), + healthMonitoringIntervals: tojson({test: 500}), + progressMonitor: tojson({deadline: PROGRESS_TIMEOUT_SECONDS}), + featureFlagHealthMonitoring: true + } +}; +let st = new ShardingTest({ + mongos: [params, params], + shards: 1, +}); +// After cluster startup, make sure both mongos's are available. +assert.commandWorked(st.s0.adminCommand({"ping": 1})); +assert.commandWorked(st.s1.adminCommand({"ping": 1})); + +// Set the failpoint on one of the mongos's to pause its healthchecks. +assert.commandWorked( + st.s1.adminCommand({"configureFailPoint": 'hangTestHealthObserver', "mode": "alwaysOn"})); +sleep(CHECK_PING_SECONDS * 1000); +// Make sure the failpoint on its own doesn't bring down the server. +assert.commandWorked(st.s1.adminCommand({"ping": 1})); +// Wait for the progress monitor timeout to elapse. +sleep(PROGRESS_TIMEOUT_SECONDS * 1000); + +assert.soon(() => { + try { + assert.commandWorked(st.s0.adminCommand({"ping": 1})); // Ensure s0 is unaffected. + st.s1.adminCommand( + {"ping": 1}); // This should throw an error because s1 is no longer reachable. + assert(false, "ping command to s1 should fail."); + } catch (e) { + // This might seem brittle to rely on the string message for the error, but the same check + // appears in the implementation for runCommand(). + if (e.message.indexOf("network error") >= 0) { + return true; + } else { + throw (e); + } + } +}, "Pinging faulty mongos should fail with network error.", PROGRESS_TIMEOUT_SECONDS * 1000); +// Don't validate exit codes, since a mongos will exit on its own with a non-zero exit code. + +st.stop({skipValidatingExitCode: true}); +})(); |