Skip to content

test(health): measure the health check timeout with time.monotonic() - #1328

Merged
CasperGN merged 1 commit into
dapr:mainfrom
nelson-parente:test/health-timeout-monotonic
Oct 21, 2026
Merged

CasperGN merged 1 commit into
dapr:mainfrom
nelson-parente:test/health-timeout-monotonic

Conversation

@nelson-parente

Copy link
Copy Markdown
Contributor

Description

test_wait_for_sidecar_timeout fails now and then on Windows with Python 3.10, for example on #1327 and #1323:

AssertionError: 2.4987475872039795 not greater than or equal to 2.5

DaprHealth.wait_until_ready() and wait_for_sidecar() compute their deadline with time.monotonic(). The tests measured the elapsed time with time.time(). On Windows the two clocks have different resolutions, so the wall-clock reading can be a few milliseconds shorter than the monotonic one. The >= 2.5 check then fails although the code waited the full timeout.

The tests now use time.monotonic(), the same clock as the code. The test takes its start time before the code does, and the code raises only when time.monotonic() passes the code's start plus the timeout. So the check holds on every platform. The upper-bound checks in the same two files also move to time.monotonic().

The same tests are on release-1.19, so this PR needs the backport release-1.19 label.

Issue reference

None.

Checklist

  • pytest tests/clients/test_healthcheck.py tests/clients/test_healthcheck_async.py: 10 passed
  • ruff check and ruff format --check pass

🤖 Generated with Claude Code

DaprHealth computes its deadline with time.monotonic(), but the tests
measured the elapsed time with time.time(). On Windows the two clocks
have different resolutions, so the >= 2.5 check failed now and then
(2.4987 s) although the code waited the full timeout. Use the same
clock in the tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.27%. Comparing base (f784843) to head (b7e2de3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1328   +/-   ##
=======================================
  Coverage   87.27%   87.27%           
=======================================
  Files         163      163           
  Lines       13069    13069           
=======================================
  Hits        11406    11406           
  Misses       1663     1663           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CasperGN
CasperGN added this pull request to the merge queue Oct 21, 2026
Merged via the queue into dapr:main with commit 02e3f00 Oct 21, 2026
30 of 32 checks passed
CasperGN pushed a commit that referenced this pull request Oct 21, 2026
…1328) (#1330)

DaprHealth computes its deadline with time.monotonic(), but the tests
measured the elapsed time with time.time(). On Windows the two clocks
have different resolutions, so the >= 2.5 check failed now and then
(2.4987 s) although the code waited the full timeout. Use the same
clock in the tests.



(cherry picked from commit 02e3f00)

Signed-off-by: Nelson Parente <nelson_parente@live.com.pt>
Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com>
Co-authored-by: Nelson Parente <nelson_parente@live.com.pt>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants