Skip to content

fix: add more mock time values in test_prime_offload_tester to handle (Bugfix)#2166

Merged
Hook25 merged 1 commit intocanonical:mainfrom
seankingyang:fix_test_prime_offload_test
Oct 30, 2025
Merged

fix: add more mock time values in test_prime_offload_tester to handle (Bugfix)#2166
Hook25 merged 1 commit intocanonical:mainfrom
seankingyang:fix_test_prime_offload_test

Conversation

@seankingyang
Copy link
Contributor

@seankingyang seankingyang commented Oct 20, 2025

Description

add more mock time values in test_prime_offload_tester to handle

The check_offload() method makes 5 time.time() calls in the failure scenario:
Call #1: deadline = time.time() + timeout → returns 0, sets deadline to 1
Call #2: while time.time() < deadline: → returns 0, check 0 < 1 = True, enters loop
Call #3: while time.time() < deadline: → returns 1, check 1 < 1 = False, exits loop
Call #4: self.logger.info("Checking fail:") → LogRecord creation calls time.time() → returns 2 (ref: https://docs.python.org/3/library/logging.html#logrecord-attributes)
Call #5: self.logger.info(" Couldn't find process") → LogRecord creation calls time.time() → returns 3

ref: python3 -c "import logging, inspect; print(inspect.getsource(logging.LogRecord.__init__))" , https://github.com/python/cpython/blob/main/Lib/logging/__init__.py#L283

Resolved issues

PR #2162
https://github.com/canonical/checkbox/actions/runs/18641071113/job/53139932346?pr=2162

Documentation

Tests

cherry pick this commit
https://github.com/canonical/checkbox/actions/runs/18641579136/job/53141487716?pr=2162

@seankingyang seankingyang changed the title fix: add more mock time values in test_prime_offload_tester to handle fix: add more mock time values in test_prime_offload_tester to handle (Bugfix) Oct 20, 2025
@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.86%. Comparing base (1ad5e7a) to head (953f39a).
⚠️ Report is 102 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2166   +/-   ##
=======================================
  Coverage   52.86%   52.86%           
=======================================
  Files         395      395           
  Lines       42636    42636           
  Branches     7906     7906           
=======================================
  Hits        22538    22538           
  Misses      19295    19295           
  Partials      803      803           
Flag Coverage Δ
provider-base 29.33% <ø> (ø)

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.

@seankingyang seankingyang marked this pull request as draft October 20, 2025 03:44
@seankingyang seankingyang marked this pull request as ready for review October 20, 2025 04:11
@seankingyang seankingyang requested a review from hanhsuan October 20, 2025 04:11
Copy link
Contributor

@hanhsuan hanhsuan left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks for finding this bug in the unit test.

@Hook25 Hook25 merged commit 6e51617 into canonical:main Oct 30, 2025
40 of 41 checks passed
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.

3 participants