Skip to content

Fix flaky TMPRL1104 duration-log assertions in test_extstore#1628

Open
DABH wants to merge 2 commits into
mainfrom
fix/tmprl1104-duration-log-test-flake
Open

Fix flaky TMPRL1104 duration-log assertions in test_extstore#1628
DABH wants to merge 2 commits into
mainfrom
fix/tmprl1104-duration-log-test-flake

Conversation

@DABH

@DABH DABH commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

The TMPRL1104 tests in tests/worker/test_extstore.py asserted that each duration log matched only the "Workflow task duration information" wording.

Why it's flaky

The worker emits TMPRL1104 with one of three wordings depending on wall-clock task duration (temporalio/worker/_workflow.py):

  • > 10sWorkflow task exceeded 10 seconds (...)
  • > 5sWorkflow task exceeded 5 seconds (...)
  • otherwise → Workflow task duration information (...)

The measured duration is wall-clock over the whole activation, so on a loaded CI host (the suite runs under pytest-xdist) even a trivial workflow task can occasionally cross the 5s threshold and emit the "exceeded" wording instead. When that happens the re.match returns None and the assertion fails with assert None. The len(records) == N check still passes because one record is still emitted per WFT, and the payload/duration fields the tests actually verify are attached identically regardless of which bucket fired.

Observed on a macos-arm job; unrelated to the PR it surfaced on.

Fix

Accept any duration-bucket wording via a single shared compiled pattern, which also collapses the 7 duplicated re.match blocks.

The worker logs TMPRL1104 with one of three wordings depending on
wall-clock task duration: "duration information" (<=5s), "exceeded 5
seconds" (>5s), or "exceeded 10 seconds" (>10s). The tests matched only
the "duration information" wording, but the duration is wall-clock time
over the whole activation, so on a loaded CI host (tests run under
pytest-xdist) a trivial task can occasionally cross 5s and emit the
"exceeded" wording instead, failing the re.match. The payload/duration
fields under test are attached identically in all three branches, so
the assertions now accept any duration-bucket wording.
@DABH DABH requested a review from a team as a code owner June 29, 2026 21:54
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