[CI] fix: health_check_test flaky due to fixed sleep, use polling for master down detection#1868
Merged
ykwd merged 1 commit intokvcache-ai:mainfrom Apr 16, 2026
Merged
Conversation
… master down detection
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a WaitForHealthCode helper function in health_check_test.cpp to replace fixed sleep intervals with a polling mechanism. This change is applied to the ReturnsTwoWhenMasterDown and HttpReturns503WhenMasterDown test cases to improve execution efficiency and reduce flakiness. I have no feedback to provide.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
00fish0
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
See #1858
Problem:
The health check tests (
ReturnsTwoWhenMasterDownandHttpReturns503WhenMasterDown) inhealth_check_test.cppwere flaky in the CI environment. The failure was caused by a hardcodedstd::this_thread::sleep_for(std::chrono::seconds(3))that did not reliably wait for the asynchronous master disconnection state to propagate, leading to race conditions and test assertions failing.Solution:
Replaced the hardcoded
sleep_forwith a robust polling mechanism (WaitForHealthCode). The test now polls the health state every 100ms with a 10-second timeout. This change:Module
mooncake-transfer-engine)mooncake-store)mooncake-ep)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-pg)mooncake-rl)Type of Change
How Has This Been Tested?
ReturnsTwoWhenMasterDownandHttpReturns503WhenMasterDown) using--gtest_repeat=100to ensure stability and zero flakiness.Checklist
./scripts/code_format.shbefore submitting.