Skip to content

Conversation

@ppinchuk
Copy link
Collaborator

A few of our tests kept failing on GHA (and presumably other machines) because they relied on precise timings. In this PR, we remove the dependency on machine timing by patching the time module and manually advancing the clock to make sure our code behaves as expected when the time changes.

@ppinchuk ppinchuk added this to the Finishing touches for OSS milestone Nov 18, 2025
@ppinchuk ppinchuk self-assigned this Nov 18, 2025
Copilot AI review requested due to automatic review settings November 18, 2025 18:05
@ppinchuk ppinchuk requested a review from castelao as a code owner November 18, 2025 18:05
@ppinchuk ppinchuk added bugfix Fixed a known bug p-medium Priority: medium topic-python-general Issues/pull requests related to python labels Nov 18, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.02%. Comparing base (fac586e) to head (c121ebf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #344   +/-   ##
=======================================
  Coverage   40.02%   40.02%           
=======================================
  Files          45       45           
  Lines        4240     4240           
  Branches      380      380           
=======================================
  Hits         1697     1697           
  Misses       2523     2523           
  Partials       20       20           
Flag Coverage Δ
unittests 40.02% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses flaky timing-dependent tests by replacing real time delays with a deterministic clock mechanism. Instead of relying on actual wall-clock time (which can vary across machines and CI environments), the tests now use a patched time.monotonic that can be manually advanced.

Key Changes

  • Added a patched_clock pytest fixture that provides a FakeClock class to replace time.monotonic with deterministic time control
  • Modified three test files to use the patched_clock fixture instead of time.sleep() for time advancement
  • Updated the README.rst Zenodo badge to use a DOI-specific URL

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/python/conftest.py Adds the patched_clock fixture with a FakeClock class that provides deterministic time control for tests
tests/python/unit/services/test_services_usage.py Removes time import and @flaky decorator; updates tests to use patched_clock.advance() instead of time.sleep()
tests/python/unit/services/test_services_base.py Removes time import and @flaky decorator; updates test to use patched_clock.advance() instead of time.sleep()
tests/python/integration/test_integrated.py Adds import for retry_module; creates fake_sleep to advance patched clock during async sleep; patches retry module's asyncio and random for deterministic behavior
README.rst Updates Zenodo badge URL to include specific DOI reference

@ppinchuk ppinchuk merged commit 47acad4 into main Nov 20, 2025
19 checks passed
@ppinchuk ppinchuk deleted the pp/fix_flaky_timed_tests branch November 20, 2025 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixed a known bug p-medium Priority: medium topic-python-general Issues/pull requests related to python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants