Skip to content

Fix activity pause test races - #1831

Draft
DABH wants to merge 2 commits into
mainfrom
flake/activity-pause-races
Draft

Fix activity pause test races#1831
DABH wants to merge 2 commits into
mainfrom
flake/activity-pause-races

Conversation

@DABH

@DABH DABH commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What was changed

unpause_and_assert accepts an activity that is no longer pending as unpaused; the pause tests drop their 1-2s heartbeat timeouts and set a 300ms heartbeat throttle; the cold-start bound for the first activity uses the suite's 10s default; the external cancellation test asserts the heartbeat raises instead of passing silently.

Why

After unpause the retried attempt can complete within a second, so a slow describe() found nothing pending. With a 1-2s heartbeat timeout and the default 80% throttle the server had 200-400ms of slack before timing the attempt out, after which pause by ID fails with Can't find pending activity. A cold worker's first task exceeded the 5s bound on CI.

Testing

Each mechanism reproduced by injecting describe or heartbeat latency: fails before, passes after. 120/120 flake-finder runs under load. Lint clean.

The pause tests raced their own activities:

- unpause_and_assert required the activity to still be pending after the
  unpause RPC, but the retried attempt sees heartbeat details and completes
  immediately, so a slow describe observed no pending activity.
- The pause workflows set heartbeat timeouts of 1-2s while relying on the
  default throttle (80% of the timeout), leaving a few hundred milliseconds
  before the server timed the attempt out and the pause RPC or the next
  describe found no pending activity. Pause is delivered through heartbeat
  responses whose cadence is the worker throttle interval, so drop the
  timeouts and set a 300ms throttle explicitly.
- assert_pending_activity_exists_eventually waited only 5s for the first
  workflow task to schedule the activity, which a cold worker on a loaded
  runner exceeds; use the 10s the other helpers use.

Also assert that the external heartbeat raises after the pause instead of
silently passing when it does not.
@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:56

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 changes consistently address the documented races without altering production behavior.

Pull request overview

Stabilizes activity pause tests by reducing timing races around heartbeats, retries, and cold starts.

Changes:

  • Uses fixed 300 ms heartbeat throttling without short heartbeat timeouts.
  • Accepts completed activities as successfully unpaused.
  • Strengthens cancellation assertions and extends pending-activity polling to 10 seconds.
File summaries
File Description
tests/worker/test_workflow.py Adjusts heartbeat timing and cancellation assertions.
tests/helpers/__init__.py Makes pending and unpause assertions race-resistant.
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