Skip to content

Commit

Permalink
Deflaked: Guarddog_impl_test (#14475)
Browse files Browse the repository at this point in the history
Deflaked guarddog_impl_test; on overloaded machines it would sometimes flake under the real time system with both threads to included in the miss / megamiss events when only one should be.

Tested via 2000 runs, of which it all passed. Prior it would flake a few (~1-5)/1000 on slower / overloaded machines.

Commit Message: Deflaked guarddog_impl_test under real time system.
Additional Description:
Risk Level: low
Testing: test change.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Kevin Baichoo <kbaichoo@google.com>
  • Loading branch information
KBaichoo authored Dec 22, 2020
1 parent e90d674 commit 484a10d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/server/guarddog_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));
Expand Down

0 comments on commit 484a10d

Please sign in to comment.