Skip to content

cli/command: fix flaky TestInitializeFromClientHangs - #7134

Open
hirehamir wants to merge 1 commit into
docker:masterfrom
hirehamir:fix/flaky-client-hangs
Open

cli/command: fix flaky TestInitializeFromClientHangs#7134
hirehamir wants to merge 1 commit into
docker:masterfrom
hirehamir:fix/flaky-client-hangs

Conversation

@hirehamir

Copy link
Copy Markdown
Contributor

- What I did

Fixed #6003

- How I did it

The test set the client's init timeout to 1 millisecond, then asserted that a request actually reached the fake server.

Under CPU pressure the client goroutine can stall for tens of milliseconds, so the 1 millisecond deadline expires before the request is even written, and the handler never runs.

I raised that timeout to ~500 milliseconds, which is about ~5x the worst stall I measured (40 - 90 milliseconds).

The assertion isn't weakened: the fake server never responds, so the client returning at all still proves the deadline works.

The test's own waits now get a separate 10s backstop instead of sharing the client's 1s context.

Trade-off: the test now waits out the deadline it's testing, so it takes ~500 milliseconds instead of ~2 milliseconds, and cli/command goes from ~0.07s to ~0.57s.

- How to verify it

The flake needs CPU pressure to show up:

systemd-run --user --scope -p CPUQuota=10% \
  ./scripts/with-go-mod.sh go test ./cli/command/ \
  -run TestInitializeFromClientHangs -count=1000 -cpu=1

Signed-off-by: Hamir <hirehamir@gmail.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: TestInitializeFromClientHangs

3 participants