summaryrefslogtreecommitdiff
path: root/src/mongo/db/process_health/health_observer_test.cpp
diff options
context:
space:
mode:
authorKshitij Gupta <kshitij.gupta@mongodb.com>2021-12-14 09:50:49 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-16 22:58:18 +0000
commitfa202b3594be0389f1fcd7e93e8f6d11ccb6e933 (patch)
tree031cfe3076119827c9657c162c7e0742c2c46233 /src/mongo/db/process_health/health_observer_test.cpp
parent00b7518783c6a576c0996fc27f0bb85f13c78fc3 (diff)
downloadmongo-fa202b3594be0389f1fcd7e93e8f6d11ccb6e933.tar.gz
SERVER-61930: Individual health observers should return an error if a
timeout period elapses when doing a single health check.
Diffstat (limited to 'src/mongo/db/process_health/health_observer_test.cpp')
-rw-r--r--src/mongo/db/process_health/health_observer_test.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/mongo/db/process_health/health_observer_test.cpp b/src/mongo/db/process_health/health_observer_test.cpp
index 55a9fa2c85e..b8dce4fb768 100644
--- a/src/mongo/db/process_health/health_observer_test.cpp
+++ b/src/mongo/db/process_health/health_observer_test.cpp
@@ -106,7 +106,7 @@ TEST_F(FaultManagerTest, Stats) {
TEST_F(FaultManagerTest, ProgressMonitorCheck) {
AtomicWord<bool> shouldBlock{true};
- registerMockHealthObserver(FaultFacetType::kMock1, [this, &shouldBlock] {
+ registerMockHealthObserver(FaultFacetType::kMock1, [&shouldBlock] {
while (shouldBlock.load()) {
sleepFor(Milliseconds(1));
}
@@ -170,6 +170,37 @@ TEST_F(FaultManagerTest, PeriodicHealthCheckOnErrorMakesBadHealthStatus) {
});
}
+TEST_F(FaultManagerTest,
+ DeadlineFutureCausesTransientFaultWhenObserverBlocksAndGetsResolvedWhenObserverUnblocked) {
+ resetManager(std::make_unique<FaultManagerConfig>());
+ RAIIServerParameterControllerForTest _flagController{"featureFlagHealthMonitoring", true};
+ RAIIServerParameterControllerForTest _serverParamController{"activeFaultDurationSecs", 5};
+
+ AtomicWord<bool> shouldBlock{true};
+ registerMockHealthObserver(FaultFacetType::kMock1,
+ [&shouldBlock] {
+ while (shouldBlock.load()) {
+ sleepFor(Milliseconds(1));
+ }
+ return 0.0;
+ },
+ Milliseconds(100));
+
+ ASSERT_TRUE(manager().getFaultState() == FaultState::kStartupCheck);
+
+ auto initialHealthCheckFuture = manager().startPeriodicHealthChecks();
+
+ assertSoon([this] {
+ return manager().currentFault() && manager().getFaultState() == FaultState::kStartupCheck;
+ });
+
+ shouldBlock.store(false);
+
+ assertSoon([this] { return manager().getFaultState() == FaultState::kOk; });
+
+ resetManager(); // Before fields above go out of scope.
+}
+
} // namespace
} // namespace process_health
} // namespace mongo