diff --git a/test/server/guarddog_impl_test.cc b/test/server/guarddog_impl_test.cc index 9641c5afc2a48..d5ff1f4698b4c 100644 --- a/test/server/guarddog_impl_test.cc +++ b/test/server/guarddog_impl_test.cc @@ -625,7 +625,19 @@ TEST_P(GuardDogActionsTest, MissShouldOnlyReportRelevantThreads) { // synchronize with the guard dog. guard_dog_->forceCheckForTest(); + if (GetParam() == TimeSystemType::Real) { + // Touch the second_dog in case we overslept in the real time system + // and the guard dog timer goes off. + second_dog_->touch(); + } + time_system_->advanceTimeWait(std::chrono::milliseconds(51)); + + if (GetParam() == TimeSystemType::Real) { + // Touch the second_dog in case we overslept in the real time system + // and the prior "touch" was consumed. + second_dog_->touch(); + } guard_dog_->forceCheckForTest(); EXPECT_THAT(events_, ElementsAre("MISS : 10")); @@ -687,7 +699,19 @@ TEST_P(GuardDogActionsTest, MegaMissShouldOnlyReportRelevantThreads) { // synchronize with the guard dog. guard_dog_->forceCheckForTest(); + if (GetParam() == TimeSystemType::Real) { + // Touch the second_dog in case we overslept in the real time system + // and the guard dog timer goes off. + second_dog_->touch(); + } + time_system_->advanceTimeWait(std::chrono::milliseconds(51)); + + if (GetParam() == TimeSystemType::Real) { + // Touch the second_dog in case we overslept in the real time system + // and the prior "touch" was consumed. + second_dog_->touch(); + } guard_dog_->forceCheckForTest(); EXPECT_THAT(events_, ElementsAre("MEGAMISS : 10"));