Skip to content

Test result duration is not reset by test restarts or guest reboots#4928

Open
happz wants to merge 3 commits into
mainfrom
stopwatch-duration-across-restarts
Open

Test result duration is not reset by test restarts or guest reboots#4928
happz wants to merge 3 commits into
mainfrom
stopwatch-duration-across-restarts

Conversation

@happz
Copy link
Copy Markdown
Contributor

@happz happz commented May 27, 2026

Every test start got new Stopwatch instances, new measurement, and only the last one was stored in the corresponding result. The patch does the following:

  • Stopwatch.measure() is no longer a classmethod. To be restartable, and retain its original starting point, an instance is needed, and it is really, really hard to make a method both instance and classmethod.
  • Stopwatch.measure() does not reset its startign poitn when it's already set. This allows stopwatch to be restartable, continuing the measurement.
  • Instead of a fresh one Stopwatch every time a test is started, Stopwatch instance is attached to TestInvocation instance owning the test. execute/tmt then calls this instance's measure()method every time the test is started - thanks to its starting point not beign reset every time,TestInvocation.stopwatch` now records the duration across all reboots and restarts.
  • And instead of calling format_duration(), Result construction accessess properties of the aforementioned Stopwatch instance, getting the right strings every time.

Pull Request Checklist

  • implement the feature
  • include a release note

@happz happz added the step | execute Stuff related to the execute step label May 27, 2026
@happz happz added this to planning May 27, 2026
@happz happz added area | results Related to how tmt stores and shares results ci | full test Pull request is ready for the full test execution labels May 27, 2026
@github-project-automation github-project-automation Bot moved this to backlog in planning May 27, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors execution timing by replacing class-level stopwatch measurements with instance-level tracking. It introduces a stopwatch instance field on TestInvocation to replace individual start_time, end_time, and real_duration fields, and updates the Stopwatch class to support instance-based measurement with a new started property. I have no feedback to provide as there are no review comments.

happz added 3 commits June 5, 2026 15:13
Every test start got new `Stopwatch` instances, new measurement, and
only the last one was stored in the corresponding result. The patch does
the following:

* `Stopwatch.measure()` is no longer a classmethod. To be restartable,
  and retain its original starting point, an instance is needed, and it
  is really, *really* hard to make a method both instance and
  classmethod.
* `Stopwatch.measure()` does not reset its startign poitn when it's
  already set. This allows stopwatch to be restartable, continuing the
  measurement.
* Instead of a fresh one `Stopwatch` every time a test is started,
  `Stopwatch` instance is attached to `TestInvocation` instance owning
  the test. `execute/tmt` then calls `this instance's `measure()` method
  every time the test is started - thanks to its starting point not
  beign reset every time, `TestInvocation.stopwatch` now records the
  duration across all reboots and restarts.
* And instead of calling `format_duration()`, `Result` construction
  accessess properties of the aforementioned `Stopwatch` instance,
  getting the right strings every time.
@happz happz force-pushed the stopwatch-duration-across-restarts branch from 32fb248 to 2ebac01 Compare June 5, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area | results Related to how tmt stores and shares results ci | full test Pull request is ready for the full test execution step | execute Stuff related to the execute step

Projects

Status: backlog

Development

Successfully merging this pull request may close these issues.

start_time/end_time reflects only the last execution segment for tests with reboots

1 participant