-
Notifications
You must be signed in to change notification settings - Fork 226
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
Fix child WF ID generation #1803
Open
gow
wants to merge
12
commits into
master
Choose a base branch
from
cg/reset_child_workflow_id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9520db2
Use OriginalRunID instead of RunID to generate child workflow IDs
gow ccb73b2
Use first execution run
gow f0eb17d
Unskip EVENT_TYPE_WORKFLOW_TASK_FAILED in internal_task_handlers.go
gow 7a812be
Remove log
gow 1e60a0e
Fix existing tests
gow 98f65da
Merge branch 'master' of github.com:temporalio/sdk-go into cg/reset_c…
gow 0354986
Merge branch 'master' of github.com:temporalio/sdk-go into cg/reset_c…
gow 3cbeb33
Use Original Execution Run ID
gow 13fdd9a
Added replay tests
gow cf0d13f
Capture events with a reset point before/after child
gow 985cba8
Add integration tests
gow a6e46a3
Remove print
gow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2040,6 +2040,101 @@ func (ts *IntegrationTestSuite) TestResetWorkflowExecution() { | |
ts.Equal(originalResult, newResult) | ||
} | ||
|
||
// TestResetWorkflowExecutionWithChildren tests the behavior of child workflow ID generation when a workflow with children is reset. | ||
// It repeatedly resets the workflow at different points in its execution and verifies that the child workflow IDs are generated correctly. | ||
func (ts *IntegrationTestSuite) TestResetWorkflowExecutionWithChildren() { | ||
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. This is a great test |
||
wfID := "reset-workflow-with-children" | ||
ctx, cancel := context.WithTimeout(context.Background(), ctxTimeout) | ||
defer cancel() | ||
|
||
// Start a workflow with 2 children. | ||
options := ts.startWorkflowOptions(wfID) | ||
run, err := ts.client.ExecuteWorkflow(ctx, options, ts.workflows.WorkflowWithChildren) | ||
ts.NoError(err) | ||
var originalResult string | ||
err = run.Get(ctx, &originalResult) | ||
ts.NoError(err) | ||
|
||
// save child init childIDs for later comparison. | ||
childIDs := ts.getChildInitEventsFromHistory(ctx, wfID, run.GetRunID()) | ||
ts.Len(childIDs, 2) | ||
child1IDBeforeReset := childIDs[0] | ||
child2IDBeforeReset := childIDs[1] | ||
|
||
resetRequest := &workflowservice.ResetWorkflowExecutionRequest{ | ||
Namespace: ts.config.Namespace, | ||
WorkflowExecution: &commonpb.WorkflowExecution{ | ||
WorkflowId: wfID, | ||
RunId: run.GetRunID(), | ||
}, | ||
Reason: "integration test", | ||
} | ||
// (reset #1) - resetting the workflow execution before both child workflows are started. | ||
resetRequest.RequestId = "reset-request-1" | ||
resetRequest.WorkflowTaskFinishEventId = 4 | ||
resp, err := ts.client.ResetWorkflowExecution(context.Background(), resetRequest) | ||
ts.NoError(err) | ||
// Wait for the new run to complete. | ||
var resultAfterReset1 string | ||
err = ts.client.GetWorkflow(context.Background(), wfID, resp.GetRunId()).Get(ctx, &resultAfterReset1) | ||
ts.NoError(err) | ||
ts.Equal(originalResult, resultAfterReset1) | ||
|
||
childIDs = ts.getChildInitEventsFromHistory(ctx, wfID, resp.GetRunId()) | ||
ts.Len(childIDs, 2) | ||
// both child workflow IDs should be different after reset. | ||
ts.NotEqual(child1IDBeforeReset, childIDs[0]) | ||
ts.NotEqual(child2IDBeforeReset, childIDs[1]) | ||
|
||
// (reset #2) - resetting the workflow execution after child-1 but before child-2 | ||
resetRequest.RequestId = "reset-request-2" | ||
resetRequest.WorkflowTaskFinishEventId = 13 | ||
resp, err = ts.client.ResetWorkflowExecution(context.Background(), resetRequest) | ||
ts.NoError(err) | ||
// Wait for the new run to complete. | ||
var resultAfterReset2 string | ||
err = ts.client.GetWorkflow(context.Background(), wfID, resp.GetRunId()).Get(ctx, &resultAfterReset2) | ||
ts.NoError(err) | ||
ts.Equal(originalResult, resultAfterReset2) | ||
|
||
childIDs = ts.getChildInitEventsFromHistory(ctx, wfID, resp.GetRunId()) | ||
ts.Len(childIDs, 2) | ||
ts.Equal(child1IDBeforeReset, childIDs[0]) // child-1 should be the same as before reset. | ||
ts.NotEqual(child2IDBeforeReset, childIDs[1]) // child-2 should be different after reset. | ||
|
||
// (reset #3) - resetting the workflow execution after child-1 but before child-2 | ||
resetRequest.RequestId = "reset-request-3" | ||
resetRequest.WorkflowTaskFinishEventId = 22 | ||
resp, err = ts.client.ResetWorkflowExecution(context.Background(), resetRequest) | ||
ts.NoError(err) | ||
// Wait for the new run to complete. | ||
var resultAfterReset3 string | ||
err = ts.client.GetWorkflow(context.Background(), wfID, resp.GetRunId()).Get(ctx, &resultAfterReset3) | ||
ts.NoError(err) | ||
ts.Equal(originalResult, resultAfterReset3) | ||
|
||
childIDs = ts.getChildInitEventsFromHistory(ctx, wfID, resp.GetRunId()) | ||
ts.Len(childIDs, 2) | ||
// both child workflow IDs should be the same as before reset. | ||
ts.Equal(child1IDBeforeReset, childIDs[0]) | ||
ts.Equal(child2IDBeforeReset, childIDs[1]) | ||
} | ||
|
||
func (ts *IntegrationTestSuite) getChildInitEventsFromHistory(ctx context.Context, wfID string, runID string) []string { | ||
iter := ts.client.GetWorkflowHistory(ctx, wfID, runID, false, enumspb.HISTORY_EVENT_FILTER_TYPE_ALL_EVENT) | ||
var childIDs []string | ||
for iter.HasNext() { | ||
event, err1 := iter.Next() | ||
if err1 != nil { | ||
break | ||
} | ||
if event.GetEventType() == enumspb.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED { | ||
childIDs = append(childIDs, event.GetStartChildWorkflowExecutionInitiatedEventAttributes().GetWorkflowId()) | ||
} | ||
} | ||
return childIDs | ||
} | ||
|
||
func (ts *IntegrationTestSuite) TestResetWorkflowExecutionWithUpdate() { | ||
ctx := context.Background() | ||
wfId := "reset-workflow-execution-with-update" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Quinn-With-Two-Ns - can you think of any ramifications for now putting workflow task failed events in
taskEvents.events
where we hadn't before?