Skip to content

Take activity tests off one-second clocks - #1842

Draft
DABH wants to merge 4 commits into
mainfrom
flake/cancel-activity-test-timeouts
Draft

Take activity tests off one-second clocks#1842
DABH wants to merge 4 commits into
mainfrom
flake/cancel-activity-test-timeouts

Conversation

@DABH

@DABH DABH commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What was changed

test_workflow_cancel_activity: task timeout 1s to 5s (Core completes the task holding a local activity at 80% of it), local activity schedule-to-close 5s to 1 minute, heartbeat timeout 1s to 5s with a 300ms throttle, and one bounded wait_cancel_complete() helper per phase. tests/test_activity.py: the four manual activity tests use a 1-minute start-to-close timeout instead of 5s.

Why

Nothing in these tests depends on the short bounds firing, and loaded runners regularly miss them. The 1s task timeout produced the Error reporting WFT to server evictions behind the most frequent macOS failure of the last two weeks, including the shutdown hang fixed in #1837. The manual tests' 5s bound closed the attempt before the start handshake finished.

Testing

Cancel test 40/40 per parameter under load, 15/15 after the helper; manual tests 40/40 each. Lint clean.

The test ran its three cancellation phases with a 1s workflow task timeout,
a 1s heartbeat timeout on the regular activity and a 5s schedule-to-close
on the local activity. Core only completes the workflow task holding a
local activity at 80% of the task timeout, so the completion had 200ms of
slack; every failing CI log starts with "Error reporting WFT to server"
evictions from missing that. The eviction then either orphaned the local
activity (shutdown hang, fixed separately), replayed the task into a stale
local activity resolution (Core nondeterminism, queries rejected with
"Workflow Task in failed state"), or simply left the phase without its
expected query result for 10s.

Widen the task timeout to 5s, give the local activity a timeout it never
needs to hit, keep cancel delivery fast for the regular activity through the
worker heartbeat throttle instead of a 1s heartbeat timeout, and make the
shared completion event checks depend only on this phase's activity, with
bounded waits so a missing completion fails instead of hanging.
test_manual_heartbeat and its siblings start a standalone activity with a
5s start-to-close timeout, then wait for the activity to report that it
started through an EventWorkflow before completing, cancelling, failing or
heartbeating it by ID. That handshake includes the first workflow task of a
cold worker, which on a loaded macOS runner took over 5s; the attempt timed
out and the heartbeat failed with RPCError NOT_FOUND ("activity not found
for ID"). Nothing in these tests depends on the attempt timing out, so give
the attempt a minute.
@DABH DABH changed the title Take test_workflow_cancel_activity off one-second clocks Take activity tests off one-second clocks Sep 10, 2026
@DABH DABH added the skip-changelog PR changes do not require changelog updates label Sep 10, 2026
@DABH
DABH requested a balanced review from Copilot September 10, 2026 06:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused test-only changes consistently address the documented timing failures without introducing correctness issues.

Pull request overview

Improves activity-test reliability by replacing timing-sensitive short deadlines with safer bounds.

Changes:

  • Extends workflow, activity, and heartbeat timeouts.
  • Adds bounded cancellation waits and faster heartbeat delivery.
File summaries
File Description
tests/worker/test_workflow.py Stabilizes activity-cancellation timing and waits.
tests/test_activity.py Extends four manual activity deadlines.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog PR changes do not require changelog updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants