Skip to content

fix(update): pin the clock in the cold-install budget test - #1826

Open
fengyue-xve wants to merge 1 commit into
TencentCloud:developfrom
fengyue-xve:fix/cold-budget-test-clock
Open

fengyue-xve wants to merge 1 commit into
TencentCloud:developfrom
fengyue-xve:fix/cold-budget-test-clock

Conversation

@fengyue-xve

Copy link
Copy Markdown

Summary

test_cold_target_install_budget_preserves_regular_timeout reads the real clock while self_update computes the cold-install budget as fallback_deadline - now, with the deadline derived from the same now. That subtraction is 900 +/- 1 ulp depending on the current time.monotonic() value — CI has produced both 899.9999999999999 (Linux) and 900.0000000000002 (Windows) — so the exact budgets == [90, 900] assertion fails on unlucky runners and passes on others without any code change.

The sibling window tests already pin time.monotonic; do the same here so the budgets are deterministic:

monkeypatch.setattr(self_update.time, "monotonic", lambda: 0.0)

Reproduced the mechanism directly: (7777.7777 + 900) - 7777.7777 == 899.9999999999991.

Target branch

  • Base is develop (feature / fix — default)

Type of change

  • Bug fix (flaky test)

Test plan

  • pytest tests/unit/infra/setup/test_self_update.py — 135 passed

  • ruff check / ruff format --check on the file — clean

  • Added/updated tests (the flaky test itself is now clock-independent)

  • make all passes locally (not run end-to-end — the change is confined to one unit test file)

The test reads the real clock, and the cold-install budget is computed as
``fallback_deadline - now`` from a deadline derived from the same ``now``.
That subtraction is ``900 +/- 1 ulp`` depending on the current
``time.monotonic()`` value (CI has produced both 899.9999999999999 on Linux
and 900.0000000000002 on Windows), so the exact ``[90, 900]`` budget
assertion fails on unlucky runners. The sibling window tests already pin
``time.monotonic``; do the same here so the budgets are deterministic.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant