summaryrefslogtreecommitdiff
path: root/src/mongo/db/process_health/fault_state_machine_test.cpp
diff options
context:
space:
mode:
authorKshitij Gupta <kshitij.gupta@mongodb.com>2022-01-17 19:35:13 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-03 06:34:22 +0000
commit1d8aaed7f9286ce90317d03fc1815bb58b43e31d (patch)
treec0ef354434941aa446bad53f9b9f10741c1c2fe3 /src/mongo/db/process_health/fault_state_machine_test.cpp
parent3b73633480220630507435a4edc3fb141739e93c (diff)
downloadmongo-1d8aaed7f9286ce90317d03fc1815bb58b43e31d.tar.gz
SERVER-59384: Should provide ability to perform periodic DNS health checks
Diffstat (limited to 'src/mongo/db/process_health/fault_state_machine_test.cpp')
-rw-r--r--src/mongo/db/process_health/fault_state_machine_test.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mongo/db/process_health/fault_state_machine_test.cpp b/src/mongo/db/process_health/fault_state_machine_test.cpp
index 111d62cb5d6..0a08b20cb8d 100644
--- a/src/mongo/db/process_health/fault_state_machine_test.cpp
+++ b/src/mongo/db/process_health/fault_state_machine_test.cpp
@@ -29,6 +29,7 @@
#include "mongo/db/process_health/fault_manager.h"
+#include "mongo/db/process_health/dns_health_observer.h"
#include "mongo/db/process_health/fault_manager_test_suite.h"
#include "mongo/db/process_health/health_check_status.h"
#include "mongo/executor/thread_pool_task_executor_test_fixture.h"
@@ -359,6 +360,52 @@ TEST_F(FaultManagerTest, HealthCheckWithOffFacetCreatesNoFaultInOk) {
ASSERT_EQ(manager().getFaultState(), FaultState::kOk);
}
+TEST_F(FaultManagerTest, DNSHealthCheckWithBadHostNameFailsAndGoodHostNameSuccess) {
+ RAIIServerParameterControllerForTest _controller{"featureFlagHealthMonitoring", true};
+ const auto faultFacetType = FaultFacetType::kDns;
+ auto config = std::make_unique<FaultManagerConfig>();
+ config->setIntensityForType(faultFacetType, HealthObserverIntensityEnum::kCritical);
+ resetManager(std::move(config));
+
+ auto serverParam =
+ ServerParameterSet::getNodeParameterSet()->get<PeriodicHealthCheckIntervalsServerParameter>(
+ "healthMonitoringIntervals");
+ auto bsonOBj = BSON("values" << BSON_ARRAY(BSON("type"
+ << "dns"
+ << "interval" << 1000)));
+ const BSONObj newParameterObj = BSON("key" << bsonOBj);
+ auto element = newParameterObj.getField("key");
+ uassertStatusOK(serverParam->set(element));
+
+ registerHealthObserver<DnsHealthObserver>();
+ globalFailPointRegistry()
+ .find("dnsHealthObserverFp")
+ ->setMode(FailPoint::alwaysOn,
+ 0,
+ BSON("hostname"
+ << "yahoo.com"));
+
+ auto initialHealthCheckFuture = manager().startPeriodicHealthChecks();
+ assertSoon([this]() { return manager().getFaultState() == FaultState::kOk; });
+
+ globalFailPointRegistry()
+ .find("dnsHealthObserverFp")
+ ->setMode(FailPoint::alwaysOn,
+ 0,
+ BSON("hostname"
+ << "badhostname.invalid"));
+ sleepFor(Seconds(1));
+ assertSoon([this]() { return manager().getFaultState() == FaultState::kTransientFault; });
+
+ globalFailPointRegistry()
+ .find("dnsHealthObserverFp")
+ ->setMode(FailPoint::alwaysOn,
+ 0,
+ BSON("hostname"
+ << "yahoo.com"));
+ assertSoon([this]() { return manager().getFaultState() == FaultState::kOk; });
+}
+
} // namespace
} // namespace process_health
} // namespace mongo