Repository navigation
fix(testsuite): honor WaitForCancellation when canceling activities - #1545
Thanatos9404 wants to merge 2 commits into
Conversation
The workflow test environment resolved every activity cancellation at once, so the WaitForCancellation activity option had no effect and a running activity never saw that it was canceled. When the option is set, the test environment now keeps waiting for the activity, reports the cancellation on its heartbeats and delivers whatever the activity returns, like a real worker. As on the server, an activity scheduled in the same decision task or waiting for a retry is still canceled at once, and an activity is not retried after its cancellation was requested. Each workflow now keeps its own mocked service, so heartbeats from activities in child workflows are matched too. Fixes cadence-workflow#1368 Signed-off-by: Yashvardhan Thanvi <[email protected]>
…t activities Tests that mock an activity which blocks without heartbeating are now waited for after a cancel, so say how such a mock can return once it is canceled, and that heartbeats are throttled to 80% of HeartbeatTimeout. Signed-off-by: Yashvardhan Thanvi <[email protected]>
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · Changing testsuite cancellation handling to wait for activity completion may cause existing mocks without cancellation handling to hang until test timeout. Honors ✅ 1 closed✅ Cross-Repo: cadence server's BatchWorkflowV2 tune-signal test will hang on SDK bump
Verification Objectives 3/3 Repos 2 inspected · PRs 1 inspectedFunctional validation 3 covered / 3 objectives#1368 3 covered / 3 objectives
Rules No rules evaluated Broader impact Repos 2 inspected PRs 1 inspectedCross-repo 2 repositories inspected 0 open impacts
Cross-PR 1 PR inspected 0 open impactsFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
What changed?
With
WaitForCancellationset, the test environment now waits for a canceled activity to complete, fail or accept the cancellation, and its heartbeats report the cancellation. As on the server, an activity scheduled in the same decision task or waiting for a retry is still canceled at once, and it is not retried once cancellation is requested. Each workflow now keeps its own mocked service, so this also works in child workflows.Why?
Fixes #1368. The test environment ignored the option and canceled every activity immediately, unlike a real worker.
How did you test it?
Added unit tests next to
Test_ChildWorkflowCancel; the cases that wait for the activity fail without this change. Ran theinternaltests, gofmt, go vet and revive.Potential risks
Tests that set
WaitForCancellationand relied on the immediate cancel now wait for the activity, as with a real worker. Heartbeats are throttled to 80% ofHeartbeatTimeout, so such tests may need a shorterHeartbeatTimeout.