-
Notifications
You must be signed in to change notification settings - Fork 299
Fix canceling external workflows that are children in testsuite #1968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
962d792
572386f
ae6d39a
1edd76a
2e3369d
f671116
174aa7e
5bdaf2b
a0f97f7
c22aeb4
9a72279
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1234,6 +1234,40 @@ func TestDynamicWorkflows(t *testing.T) { | |
| require.Equal(t, "dynamic-activity - grape - cherry", result) | ||
| } | ||
|
|
||
| func SleepHour(ctx Context) error { | ||
| return Sleep(ctx, time.Hour) | ||
| } | ||
|
|
||
| func SleepThenCancel(ctx Context) error { | ||
| cwf := ExecuteChildWorkflow( | ||
| ctx, | ||
| SleepHour, | ||
| ) | ||
| var res WorkflowExecution | ||
| if err := cwf.GetChildWorkflowExecution().Get(ctx, &res); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Canceling an external workflow that causes a timer to cancel used to fail due to | ||
| // "illegal access from outside of workflow context" | ||
| err := RequestCancelExternalWorkflow(ctx, res.ID, res.RunID).Get(ctx, nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| // Give the workflow time to finish canceling the child workflow | ||
| return Sleep(ctx, 1*time.Second) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we poll the other workflow until it gets cancelled if we really need to give time for it to cancel? Maybe poll a generous overall time (5 seconds) and then either return on intentionally fail the test?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My comment was wrong, this is actually important part of the test that uses |
||
| } | ||
|
|
||
| func TestRequestCancelExternalWorkflowInSelector(t *testing.T) { | ||
| testSuite := &WorkflowTestSuite{} | ||
| env := testSuite.NewTestWorkflowEnvironment() | ||
| env.RegisterWorkflow(SleepHour) | ||
| env.ExecuteWorkflow(SleepThenCancel) | ||
| require.NoError(t, env.GetWorkflowError()) | ||
| env.IsWorkflowCompleted() | ||
| } | ||
|
yuandrew marked this conversation as resolved.
|
||
|
|
||
| func checkActivityInfo(ctx context.Context, isWorkflowActivity bool) error { | ||
| info := GetActivityInfo(ctx) | ||
| if isWorkflowActivity { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.