fix: preserve behavex absolute timestamps when replaying JSON#494
Merged
Conversation
When QaseFormatter.launch_json_formatter consumed the consolidated
BehaveX JSON report, parse_scenario_from_json and parse_step_from_json
synthesised timestamps from the recorded duration and the current
time: every scenario ended at now() and started at now() - duration.
Scenarios that BehaveX actually executed 200 ms apart all collapsed
onto the same moment in the TestOps timeline, with timeline ordering
matching parser iteration rather than real execution order.
BehaveX records absolute ``start`` / ``stop`` milliseconds on every
scenario and step. Use them: compute a single time_offset such that
the earliest BehaveX scenario lands at the moment we begin replay
(get_real_time()), and shift every scenario/step by that constant.
The whole timeline ends up inside the run window the API accepts,
worker parallelism survives, and the gaps between scenarios match
the gaps BehaveX recorded.
Fall back to the legacy "now - duration" path only when ``start`` /
``stop`` are missing.
Drive-by: ``scenario_dict.get('background', {})`` returned ``None``
when the key existed with a null value (which is exactly what
BehaveX writes for scenarios without a background), and the next
``.get('steps')`` raised AttributeError. Use ``or {}`` so a null
background is treated as empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
QaseFormatter.launch_json_formatterconsumes the consolidated BehaveX JSON report and currently synthesises timestamps fromdurationandnow()— every scenario ends at the moment of replay and starts atnow() - duration. Scenarios that BehaveX actually executed 200 ms apart collapse onto the same instant in the TestOps timeline, and the order on the timeline matches parser iteration rather than real execution.start/stop(Unix ms) on every scenario and step. Use them: compute onetime_offsetso the earliest BehaveX scenario lands at the replay moment, then shift every scenario/step by that constant. The whole timeline ends up inside the run window the API accepts, worker parallelism survives, gaps between stages match the gaps BehaveX recorded.start/stopare missing.scenario_dict.get('background', {})returnedNonewhen the key existed with a null value (exactly what BehaveX writes for scenarios without a background), and the following.get('steps')raisedAttributeError. Useor {}so a null background is treated as empty.qase-behaveto3.2.1.Test plan
TestBehavexAbsoluteTimestampsintest_utils.py(4 cases): scenario uses real start/stop+offset; scenario without start/stop falls back to now; step uses real start/stop+offset; three scenarios spaced 200 ms apart preserve the gaps after offsetting.TestComputeTimeOffsetintest_formatter.py(3 cases): empty features → 0.0; scenarios withoutstart→ 0.0; offset lands the earliest scenario nearnow().test_launch_json_formatter_survives_null_backgroundcovering the drive-by NPE.pytest qase-behave/tests/ -v→ 80 passed locally (Python 3.12).18:01:52.18:23:05,18:23:05,18:23:06— real ordering and gaps preserved.