From 9520db2a9d49b071340304e20db3a6e6e0e329de Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Tue, 4 Feb 2025 22:37:33 -0800 Subject: [PATCH 01/10] Use OriginalRunID instead of RunID to generate child workflow IDs --- internal/internal_event_handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index c2d89ef58..42c2cff16 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -561,7 +561,7 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow( params ExecuteWorkflowParams, callback ResultHandler, startedHandler func(r WorkflowExecution, e error), ) { if params.WorkflowID == "" { - params.WorkflowID = wc.workflowInfo.WorkflowExecution.RunID + "_" + wc.GenerateSequenceID() + params.WorkflowID = wc.workflowInfo.OriginalRunID + "_" + wc.GenerateSequenceID() } memo, err := getWorkflowMemo(params.Memo, wc.dataConverter) if err != nil { From ccb73b20c2561ca52e71fc0c21071f16ec4186f5 Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Tue, 11 Feb 2025 22:31:05 -0800 Subject: [PATCH 02/10] Use first execution run --- internal/internal_event_handlers.go | 14 +++++++++++++- internal/workflow.go | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index 42c2cff16..992e410da 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -561,7 +561,7 @@ func (wc *workflowEnvironmentImpl) ExecuteChildWorkflow( params ExecuteWorkflowParams, callback ResultHandler, startedHandler func(r WorkflowExecution, e error), ) { if params.WorkflowID == "" { - params.WorkflowID = wc.workflowInfo.OriginalRunID + "_" + wc.GenerateSequenceID() + params.WorkflowID = wc.workflowInfo.childWorkflowIDSeed + "_" + wc.GenerateSequenceID() } memo, err := getWorkflowMemo(params.Memo, wc.dataConverter) if err != nil { @@ -1194,8 +1194,10 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( tagEventType, event.GetEventType().String()) }) + weh.logger.Info(fmt.Sprintf("HistoryEvent: %v", event.GetEventType())) switch event.GetEventType() { case enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED: + weh.logger.Info(fmt.Sprintf("WorkflowExecutionStartedEventAttributes: %v", event.GetWorkflowExecutionStartedEventAttributes())) err = weh.handleWorkflowExecutionStarted(event.GetWorkflowExecutionStartedEventAttributes()) case enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED: @@ -1220,6 +1222,11 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( case enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT: // No Operation case enumspb.EVENT_TYPE_WORKFLOW_TASK_FAILED: + weh.logger.Info(fmt.Sprintf("WorkflowTaskFailedEventAttributes: %v", event.GetWorkflowTaskFailedEventAttributes())) + attr := event.GetWorkflowTaskFailedEventAttributes() + if attr.GetCause() == enumspb.WORKFLOW_TASK_FAILED_CAUSE_RESET_WORKFLOW { + weh.workflowInfo.childWorkflowIDSeed = attr.GetNewRunId() + } // No Operation case enumspb.EVENT_TYPE_WORKFLOW_TASK_COMPLETED: // No Operation @@ -1457,6 +1464,11 @@ func (weh *workflowExecutionEventHandlerImpl) handleWorkflowExecutionStarted( // as the value varies by WFT) weh.sdkFlags.tryUse(SDKFlagProtocolMessageCommand, !weh.isReplay) + // Use the first execution run ID from the start event as the initial seed. + // First execution run ID stays the same for the entire chain of workflow resets. + // This helps us keep child workflow IDs consistent up until the next reset point. + weh.workflowInfo.childWorkflowIDSeed = attributes.GetFirstExecutionRunId() + // Invoke the workflow. weh.workflowDefinition.Execute(weh, attributes.Header, attributes.Input) return nil diff --git a/internal/workflow.go b/internal/workflow.go index 9d0c3e961..f0d9c0dd2 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -1281,6 +1281,8 @@ type WorkflowInfo struct { continueAsNewSuggested bool currentHistorySize int currentHistoryLength int + // TODO: add currentRunID string + childWorkflowIDSeed string } // UpdateInfo information about a currently running update From f0eb17d47b1cdb6728292f0166a5775700f69e00 Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Wed, 12 Feb 2025 15:44:40 -0800 Subject: [PATCH 03/10] Unskip EVENT_TYPE_WORKFLOW_TASK_FAILED in internal_task_handlers.go --- internal/internal_event_handlers.go | 3 +-- internal/internal_task_handlers.go | 3 +-- internal/workflow.go | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index 992e410da..600fd6191 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -1197,7 +1197,6 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( weh.logger.Info(fmt.Sprintf("HistoryEvent: %v", event.GetEventType())) switch event.GetEventType() { case enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED: - weh.logger.Info(fmt.Sprintf("WorkflowExecutionStartedEventAttributes: %v", event.GetWorkflowExecutionStartedEventAttributes())) err = weh.handleWorkflowExecutionStarted(event.GetWorkflowExecutionStartedEventAttributes()) case enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED: @@ -1222,7 +1221,7 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( case enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT: // No Operation case enumspb.EVENT_TYPE_WORKFLOW_TASK_FAILED: - weh.logger.Info(fmt.Sprintf("WorkflowTaskFailedEventAttributes: %v", event.GetWorkflowTaskFailedEventAttributes())) + // update the childWorkflowIDSeed if the workflow was reset at this point. attr := event.GetWorkflowTaskFailedEventAttributes() if attr.GetCause() == enumspb.WORKFLOW_TASK_FAILED_CAUSE_RESET_WORKFLOW { weh.workflowInfo.childWorkflowIDSeed = attr.GetNewRunId() diff --git a/internal/internal_task_handlers.go b/internal/internal_task_handlers.go index 8bdd78e23..34666f406 100644 --- a/internal/internal_task_handlers.go +++ b/internal/internal_task_handlers.go @@ -492,8 +492,7 @@ OrderEvents: break OrderEvents } case enumspb.EVENT_TYPE_WORKFLOW_TASK_SCHEDULED, - enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT, - enumspb.EVENT_TYPE_WORKFLOW_TASK_FAILED: + enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT: // Skip default: if event.GetEventType() == enumspb.EVENT_TYPE_WORKFLOW_TASK_COMPLETED { diff --git a/internal/workflow.go b/internal/workflow.go index f0d9c0dd2..5749cbe8f 100644 --- a/internal/workflow.go +++ b/internal/workflow.go @@ -1281,7 +1281,7 @@ type WorkflowInfo struct { continueAsNewSuggested bool currentHistorySize int currentHistoryLength int - // TODO: add currentRunID string + // childWorkflowIDSeed is used to generate unique child workflow IDs childWorkflowIDSeed string } From 7a812be579af4f37c58fe7866ed10d699250735a Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Wed, 12 Feb 2025 15:57:04 -0800 Subject: [PATCH 04/10] Remove log --- internal/internal_event_handlers.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index 600fd6191..8b05ad453 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -1194,7 +1194,6 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( tagEventType, event.GetEventType().String()) }) - weh.logger.Info(fmt.Sprintf("HistoryEvent: %v", event.GetEventType())) switch event.GetEventType() { case enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_STARTED: err = weh.handleWorkflowExecutionStarted(event.GetWorkflowExecutionStartedEventAttributes()) From 1e60a0ea01690652412d29b522f14ae39292eb37 Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Wed, 12 Feb 2025 17:18:23 -0800 Subject: [PATCH 05/10] Fix existing tests --- internal/internal_task_handlers_interfaces_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/internal_task_handlers_interfaces_test.go b/internal/internal_task_handlers_interfaces_test.go index e24709026..6fae2b4e1 100644 --- a/internal/internal_task_handlers_interfaces_test.go +++ b/internal/internal_task_handlers_interfaces_test.go @@ -176,7 +176,7 @@ func (s *PollLayerInterfacesTestSuite) TestGetNextCommands() { createTestEventWorkflowTaskStarted(3), { EventId: 4, - EventType: enumspb.EVENT_TYPE_WORKFLOW_TASK_FAILED, + EventType: enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT, }, { EventId: 5, @@ -278,7 +278,7 @@ func (s *PollLayerInterfacesTestSuite) TestMessageCommands() { createTestEventWorkflowTaskStarted(3), { EventId: 4, - EventType: enumspb.EVENT_TYPE_WORKFLOW_TASK_FAILED, + EventType: enumspb.EVENT_TYPE_WORKFLOW_TASK_TIMED_OUT, }, createTestEventWorkflowTaskScheduled(5, &historypb.WorkflowTaskScheduledEventAttributes{TaskQueue: &taskqueuepb.TaskQueue{Name: taskQueue}}), createTestEventWorkflowTaskStarted(6), From 3cbeb3354c9ea874ce8a151d04b51e6b9361e5b0 Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Thu, 13 Feb 2025 09:26:27 -0800 Subject: [PATCH 06/10] Use Original Execution Run ID --- internal/internal_event_handlers.go | 6 ------ internal/internal_task_handlers.go | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/internal_event_handlers.go b/internal/internal_event_handlers.go index 8b05ad453..96d312ef4 100644 --- a/internal/internal_event_handlers.go +++ b/internal/internal_event_handlers.go @@ -1225,7 +1225,6 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent( if attr.GetCause() == enumspb.WORKFLOW_TASK_FAILED_CAUSE_RESET_WORKFLOW { weh.workflowInfo.childWorkflowIDSeed = attr.GetNewRunId() } - // No Operation case enumspb.EVENT_TYPE_WORKFLOW_TASK_COMPLETED: // No Operation case enumspb.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED: @@ -1462,11 +1461,6 @@ func (weh *workflowExecutionEventHandlerImpl) handleWorkflowExecutionStarted( // as the value varies by WFT) weh.sdkFlags.tryUse(SDKFlagProtocolMessageCommand, !weh.isReplay) - // Use the first execution run ID from the start event as the initial seed. - // First execution run ID stays the same for the entire chain of workflow resets. - // This helps us keep child workflow IDs consistent up until the next reset point. - weh.workflowInfo.childWorkflowIDSeed = attributes.GetFirstExecutionRunId() - // Invoke the workflow. weh.workflowDefinition.Execute(weh, attributes.Header, attributes.Input) return nil diff --git a/internal/internal_task_handlers.go b/internal/internal_task_handlers.go index 34666f406..7c5d316e8 100644 --- a/internal/internal_task_handlers.go +++ b/internal/internal_task_handlers.go @@ -743,6 +743,10 @@ func (wth *workflowTaskHandlerImpl) createWorkflowContext(task *workflowservice. Memo: attributes.Memo, SearchAttributes: attributes.SearchAttributes, RetryPolicy: convertFromPBRetryPolicy(attributes.RetryPolicy), + // Use the original execution run ID from the start event as the initial seed. + // Original execution run ID stays the same for the entire chain of workflow resets. + // This helps us keep child workflow IDs consistent up until a reset-point is encountered. + childWorkflowIDSeed: attributes.GetOriginalExecutionRunId(), } return newWorkflowExecutionContext(workflowInfo, wth), nil From 13fdd9af890bc1cd55ccefffc3fbcc8b9e023c7d Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Thu, 13 Feb 2025 12:24:41 -0800 Subject: [PATCH 07/10] Added replay tests --- test/replaytests/replay_test.go | 18 ++ .../reset-workflow-with-child-failed.json | 275 ++++++++++++++++++ .../reset-workflow-with-child-success.json | 266 +++++++++++++++++ test/replaytests/workflows.go | 22 ++ 4 files changed, 581 insertions(+) create mode 100644 test/replaytests/reset-workflow-with-child-failed.json create mode 100644 test/replaytests/reset-workflow-with-child-success.json diff --git a/test/replaytests/replay_test.go b/test/replaytests/replay_test.go index 87240bab4..b568302cf 100644 --- a/test/replaytests/replay_test.go +++ b/test/replaytests/replay_test.go @@ -493,6 +493,24 @@ func (s *replayTestSuite) TestPartialReplayNonCommandEvent() { require.NoError(s.T(), err) } +func (s *replayTestSuite) TestResetWorkflowWithChildSuccess() { + replayer := worker.NewWorkflowReplayer() + replayer.RegisterWorkflow(ResetWorkflowWithChild) + // Verify we can replay workflow history containing StartChildWorkflowExecutionInitiated & ChildWorkflowExecutionCompleted events. + err := replayer.ReplayWorkflowHistoryFromJSONFile(ilog.NewDefaultLogger(), "reset-workflow-with-child-success.json") + s.NoError(err) + require.NoError(s.T(), err) +} + +func (s *replayTestSuite) TestResetWorkflowWithChildFailed() { + replayer := worker.NewWorkflowReplayer() + replayer.RegisterWorkflow(ResetWorkflowWithChild) + // Verify we can replay workflow history containing ChildWorkflowExecutionFailed event + err := replayer.ReplayWorkflowHistoryFromJSONFile(ilog.NewDefaultLogger(), "reset-workflow-with-child-failed.json") + s.NoError(err) + require.NoError(s.T(), err) +} + type captureConverter struct { converter.DataConverter toPayloads []interface{} diff --git a/test/replaytests/reset-workflow-with-child-failed.json b/test/replaytests/reset-workflow-with-child-failed.json new file mode 100644 index 000000000..e666291b9 --- /dev/null +++ b/test/replaytests/reset-workflow-with-child-failed.json @@ -0,0 +1,275 @@ +{ + "events": [ + { + "eventId": "1", + "eventTime": "2025-02-13T20:14:02.650135Z", + "eventType": "WorkflowExecutionStarted", + "taskId": "1048618", + "workflowExecutionStartedEventAttributes": { + "workflowType": { + "name": "ResetWorkflowWithChild" + }, + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "workflowExecutionTimeout": "0s", + "workflowRunTimeout": "0s", + "workflowTaskTimeout": "10s", + "originalExecutionRunId": "019500f2-6d9a-7207-8c9f-69cb0647bbae", + "identity": "23299@Chetans-MacBook-Pro.local@", + "firstExecutionRunId": "019500f2-6d9a-7207-8c9f-69cb0647bbae", + "attempt": 1, + "firstWorkflowTaskBackoff": "0s", + "header": {}, + "workflowId": "parent-workflow-id" + } + }, + { + "eventId": "2", + "eventTime": "2025-02-13T20:14:02.650219Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048619", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "3", + "eventTime": "2025-02-13T20:14:02.704393Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048626", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "2", + "identity": "23259@Chetans-MacBook-Pro.local@", + "requestId": "323d0cf7-54d1-4604-9256-d5c90937403c", + "historySizeBytes": "594" + } + }, + { + "eventId": "4", + "eventTime": "2025-02-13T20:14:02.728590Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048630", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "2", + "startedEventId": "3", + "identity": "23259@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "fb33118f3ecb446bcfc5091fbba8aa33" + }, + "sdkMetadata": { + "langUsedFlags": [ + 3 + ], + "sdkName": "temporal-go", + "sdkVersion": "1.32.1" + }, + "meteringMetadata": {} + } + }, + { + "eventId": "5", + "eventTime": "2025-02-13T20:14:02.728670Z", + "eventType": "StartChildWorkflowExecutionInitiated", + "taskId": "1048631", + "startChildWorkflowExecutionInitiatedEventAttributes": { + "namespace": "default", + "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", + "workflowType": { + "name": "TestChildWorkflow" + }, + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "input": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkNISUxEIElOUFVUIg==" + } + ] + }, + "workflowExecutionTimeout": "0s", + "workflowRunTimeout": "0s", + "workflowTaskTimeout": "10s", + "parentClosePolicy": "Terminate", + "workflowTaskCompletedEventId": "4", + "workflowIdReusePolicy": "AllowDuplicate", + "header": {}, + "useCompatibleVersion": true + } + }, + { + "eventId": "6", + "eventTime": "2025-02-13T20:14:02.753687Z", + "eventType": "ChildWorkflowExecutionStarted", + "taskId": "1048635", + "childWorkflowExecutionStartedEventAttributes": { + "namespace": "default", + "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "initiatedEventId": "5", + "workflowExecution": { + "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", + "runId": "019500f2-6df8-7320-8517-ccbd0eaaf3c7" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "header": {} + } + }, + { + "eventId": "7", + "eventTime": "2025-02-13T20:14:02.753698Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048636", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "Chetans-MacBook-Pro.local:19ef4a77-99af-42ec-ae24-d5d1488aa955", + "kind": "Sticky", + "normalName": "child-workflow-test-queue" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "8", + "eventTime": "2025-02-13T20:14:02.770381Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048641", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "7", + "identity": "23259@Chetans-MacBook-Pro.local@", + "requestId": "934c75ea-43bb-4673-b651-5ca0338acfc3", + "historySizeBytes": "1401" + } + }, + { + "eventId": "9", + "eventTime": "2025-02-13T20:14:02.785845Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048645", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "7", + "startedEventId": "8", + "identity": "23259@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "fb33118f3ecb446bcfc5091fbba8aa33" + }, + "sdkMetadata": {}, + "meteringMetadata": {} + } + }, + { + "eventId": "10", + "eventTime": "2025-02-13T20:14:02.803076Z", + "eventType": "ChildWorkflowExecutionFailed", + "taskId": "1048647", + "childWorkflowExecutionFailedEventAttributes": { + "failure": { + "message": "Child workflow execution failed", + "source": "GoSDK", + "applicationFailureInfo": {} + }, + "namespace": "default", + "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "workflowExecution": { + "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", + "runId": "019500f2-6df8-7320-8517-ccbd0eaaf3c7" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "initiatedEventId": "5", + "startedEventId": "6", + "retryState": "RetryPolicyNotSet" + } + }, + { + "eventId": "11", + "eventTime": "2025-02-13T20:14:02.803084Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048648", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "Chetans-MacBook-Pro.local:19ef4a77-99af-42ec-ae24-d5d1488aa955", + "kind": "Sticky", + "normalName": "child-workflow-test-queue" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "12", + "eventTime": "2025-02-13T20:14:02.842854Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048652", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "11", + "identity": "23259@Chetans-MacBook-Pro.local@", + "requestId": "6c3d79eb-1eef-4e5d-aa19-53fca86d8fe4", + "historySizeBytes": "1999" + } + }, + { + "eventId": "13", + "eventTime": "2025-02-13T20:14:02.854644Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048656", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "11", + "startedEventId": "12", + "identity": "23259@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "fb33118f3ecb446bcfc5091fbba8aa33" + }, + "sdkMetadata": {}, + "meteringMetadata": {} + } + }, + { + "eventId": "14", + "eventTime": "2025-02-13T20:14:02.854672Z", + "eventType": "WorkflowExecutionFailed", + "taskId": "1048657", + "workflowExecutionFailedEventAttributes": { + "failure": { + "message": "child workflow execution error", + "source": "GoSDK", + "cause": { + "message": "Child workflow execution failed", + "source": "GoSDK", + "applicationFailureInfo": {} + }, + "childWorkflowExecutionFailureInfo": { + "namespace": "default", + "workflowExecution": { + "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", + "runId": "019500f2-6df8-7320-8517-ccbd0eaaf3c7" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "initiatedEventId": "5", + "startedEventId": "6", + "retryState": "RetryPolicyNotSet" + } + }, + "retryState": "RetryPolicyNotSet", + "workflowTaskCompletedEventId": "13" + } + } + ] +} diff --git a/test/replaytests/reset-workflow-with-child-success.json b/test/replaytests/reset-workflow-with-child-success.json new file mode 100644 index 000000000..56f294de3 --- /dev/null +++ b/test/replaytests/reset-workflow-with-child-success.json @@ -0,0 +1,266 @@ +{ + "events": [ + { + "eventId": "1", + "eventTime": "2025-02-13T20:04:01.908564Z", + "eventType": "WorkflowExecutionStarted", + "taskId": "1048576", + "workflowExecutionStartedEventAttributes": { + "workflowType": { + "name": "ResetWorkflowWithChild" + }, + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "workflowExecutionTimeout": "0s", + "workflowRunTimeout": "0s", + "workflowTaskTimeout": "10s", + "originalExecutionRunId": "019500e9-42f4-7897-b0d3-726eac6ff3c6", + "identity": "18781@Chetans-MacBook-Pro.local@", + "firstExecutionRunId": "019500e9-42f4-7897-b0d3-726eac6ff3c6", + "attempt": 1, + "firstWorkflowTaskBackoff": "0s", + "header": {}, + "workflowId": "parent-workflow-id" + } + }, + { + "eventId": "2", + "eventTime": "2025-02-13T20:04:01.908657Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048577", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "3", + "eventTime": "2025-02-13T20:04:01.930346Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048582", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "2", + "identity": "18680@Chetans-MacBook-Pro.local@", + "requestId": "893216a6-6421-470b-8267-451d2116ee5c", + "historySizeBytes": "297" + } + }, + { + "eventId": "4", + "eventTime": "2025-02-13T20:04:01.963131Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048586", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "2", + "startedEventId": "3", + "identity": "18680@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "6213b43af5b83a4356641f12cd89b58e" + }, + "sdkMetadata": { + "langUsedFlags": [ + 3 + ], + "sdkName": "temporal-go", + "sdkVersion": "1.32.1" + }, + "meteringMetadata": {} + } + }, + { + "eventId": "5", + "eventTime": "2025-02-13T20:04:01.963282Z", + "eventType": "StartChildWorkflowExecutionInitiated", + "taskId": "1048587", + "startChildWorkflowExecutionInitiatedEventAttributes": { + "namespace": "default", + "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "workflowId": "019500e9-42f4-7897-b0d3-726eac6ff3c6_5", + "workflowType": { + "name": "TestChildWorkflow" + }, + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "input": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkNISUxEIElOUFVUIg==" + } + ] + }, + "workflowExecutionTimeout": "0s", + "workflowRunTimeout": "0s", + "workflowTaskTimeout": "10s", + "parentClosePolicy": "Terminate", + "workflowTaskCompletedEventId": "4", + "workflowIdReusePolicy": "AllowDuplicate", + "header": {}, + "useCompatibleVersion": true + } + }, + { + "eventId": "6", + "eventTime": "2025-02-13T20:04:01.998775Z", + "eventType": "ChildWorkflowExecutionStarted", + "taskId": "1048591", + "childWorkflowExecutionStartedEventAttributes": { + "namespace": "default", + "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "initiatedEventId": "5", + "workflowExecution": { + "workflowId": "019500e9-42f4-7897-b0d3-726eac6ff3c6_5", + "runId": "019500e9-4340-7b1f-bd78-c4e790f6ee75" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "header": {} + } + }, + { + "eventId": "7", + "eventTime": "2025-02-13T20:04:01.998785Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048592", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "Chetans-MacBook-Pro.local:9000c21f-2b60-4db6-ba6b-0fca943abea7", + "kind": "Sticky", + "normalName": "child-workflow-test-queue" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "8", + "eventTime": "2025-02-13T20:04:02.008738Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048597", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "7", + "identity": "18680@Chetans-MacBook-Pro.local@", + "requestId": "713e4b74-e3f6-4a24-bca6-543b7a83550a", + "historySizeBytes": "1104" + } + }, + { + "eventId": "9", + "eventTime": "2025-02-13T20:04:02.022741Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048601", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "7", + "startedEventId": "8", + "identity": "18680@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "6213b43af5b83a4356641f12cd89b58e" + }, + "sdkMetadata": {}, + "meteringMetadata": {} + } + }, + { + "eventId": "10", + "eventTime": "2025-02-13T20:04:04.106279Z", + "eventType": "ChildWorkflowExecutionCompleted", + "taskId": "1048603", + "childWorkflowExecutionCompletedEventAttributes": { + "result": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkhlbGxvIENISUxEIElOUFVUISI=" + } + ] + }, + "namespace": "default", + "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "workflowExecution": { + "workflowId": "019500e9-42f4-7897-b0d3-726eac6ff3c6_5", + "runId": "019500e9-4340-7b1f-bd78-c4e790f6ee75" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "initiatedEventId": "5", + "startedEventId": "6" + } + }, + { + "eventId": "11", + "eventTime": "2025-02-13T20:04:04.106293Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048604", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "Chetans-MacBook-Pro.local:9000c21f-2b60-4db6-ba6b-0fca943abea7", + "kind": "Sticky", + "normalName": "child-workflow-test-queue" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "12", + "eventTime": "2025-02-13T20:04:04.125989Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048608", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "11", + "identity": "18680@Chetans-MacBook-Pro.local@", + "requestId": "d481f043-cae6-422a-a4a6-e4dec5881cab", + "historySizeBytes": "1702" + } + }, + { + "eventId": "13", + "eventTime": "2025-02-13T20:04:04.143914Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048612", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "11", + "startedEventId": "12", + "identity": "18680@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "6213b43af5b83a4356641f12cd89b58e" + }, + "sdkMetadata": {}, + "meteringMetadata": {} + } + }, + { + "eventId": "14", + "eventTime": "2025-02-13T20:04:04.143951Z", + "eventType": "WorkflowExecutionCompleted", + "taskId": "1048613", + "workflowExecutionCompletedEventAttributes": { + "result": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkhlbGxvIENISUxEIElOUFVUISI=" + } + ] + }, + "workflowTaskCompletedEventId": "13" + } + } + ] +} diff --git a/test/replaytests/workflows.go b/test/replaytests/workflows.go index ea08bfbf5..339cccd02 100644 --- a/test/replaytests/workflows.go +++ b/test/replaytests/workflows.go @@ -676,3 +676,25 @@ func TripWorkflow(ctx workflow.Context, tripCounter int) error { logger.Info("Starting a new run.", "TripCounter", tripCounter) return workflow.NewContinueAsNewError(ctx, "TripWorkflow", tripCounter) } + +// TestWorkflowWithChild is a test workflow that executes a child workflow and returns the result from it. +func ResetWorkflowWithChild(ctx workflow.Context) (string, error) { + logger := workflow.GetLogger(ctx) + + logger.Info("Starting workflow with child...") + cwo := workflow.ChildWorkflowOptions{ + ParentClosePolicy: enums.PARENT_CLOSE_POLICY_TERMINATE, + WorkflowIDReusePolicy: enums.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE, + } + ctx = workflow.WithChildOptions(ctx, cwo) + child := workflow.ExecuteChildWorkflow(ctx, "TestChildWorkflow", "CHILD INPUT") + + var result string + if err := child.Get(ctx, &result); err != nil { + logger.Error("Child execution failed: " + err.Error()) + return "", err + } + + logger.Info("Child execution completed with result: " + result) + return result, nil +} From cf0d13fe928ccae294f6e79cfd60ab39d383733e Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Thu, 13 Feb 2025 14:16:56 -0800 Subject: [PATCH 08/10] Capture events with a reset point before/after child --- test/replaytests/replay_test.go | 12 +- ... reset-workflow-after-child-complete.json} | 145 +++++--- .../reset-workflow-before-child-init.json | 310 ++++++++++++++++++ .../reset-workflow-with-child-failed.json | 275 ---------------- 4 files changed, 412 insertions(+), 330 deletions(-) rename test/replaytests/{reset-workflow-with-child-success.json => reset-workflow-after-child-complete.json} (61%) create mode 100644 test/replaytests/reset-workflow-before-child-init.json delete mode 100644 test/replaytests/reset-workflow-with-child-failed.json diff --git a/test/replaytests/replay_test.go b/test/replaytests/replay_test.go index b568302cf..36407af2c 100644 --- a/test/replaytests/replay_test.go +++ b/test/replaytests/replay_test.go @@ -493,20 +493,20 @@ func (s *replayTestSuite) TestPartialReplayNonCommandEvent() { require.NoError(s.T(), err) } -func (s *replayTestSuite) TestResetWorkflowWithChildSuccess() { +func (s *replayTestSuite) TestResetWorkflowBeforeChildInit() { replayer := worker.NewWorkflowReplayer() replayer.RegisterWorkflow(ResetWorkflowWithChild) - // Verify we can replay workflow history containing StartChildWorkflowExecutionInitiated & ChildWorkflowExecutionCompleted events. - err := replayer.ReplayWorkflowHistoryFromJSONFile(ilog.NewDefaultLogger(), "reset-workflow-with-child-success.json") + // Verify we can replay workflow history containing a reset before StartChildWorkflowExecutionInitiated & ChildWorkflowExecutionCompleted events. + err := replayer.ReplayWorkflowHistoryFromJSONFile(ilog.NewDefaultLogger(), "reset-workflow-before-child-init.json") s.NoError(err) require.NoError(s.T(), err) } -func (s *replayTestSuite) TestResetWorkflowWithChildFailed() { +func (s *replayTestSuite) TestResetWorkflowAfterChildComplete() { replayer := worker.NewWorkflowReplayer() replayer.RegisterWorkflow(ResetWorkflowWithChild) - // Verify we can replay workflow history containing ChildWorkflowExecutionFailed event - err := replayer.ReplayWorkflowHistoryFromJSONFile(ilog.NewDefaultLogger(), "reset-workflow-with-child-failed.json") + // Verify we can replay workflow history containing a reset event after StartChildWorkflowExecutionInitiated & ChildWorkflowExecutionCompleted events. + err := replayer.ReplayWorkflowHistoryFromJSONFile(ilog.NewDefaultLogger(), "reset-workflow-after-child-complete.json") s.NoError(err) require.NoError(s.T(), err) } diff --git a/test/replaytests/reset-workflow-with-child-success.json b/test/replaytests/reset-workflow-after-child-complete.json similarity index 61% rename from test/replaytests/reset-workflow-with-child-success.json rename to test/replaytests/reset-workflow-after-child-complete.json index 56f294de3..e119a2cb8 100644 --- a/test/replaytests/reset-workflow-with-child-success.json +++ b/test/replaytests/reset-workflow-after-child-complete.json @@ -2,7 +2,7 @@ "events": [ { "eventId": "1", - "eventTime": "2025-02-13T20:04:01.908564Z", + "eventTime": "2025-02-13T22:13:53.113740Z", "eventType": "WorkflowExecutionStarted", "taskId": "1048576", "workflowExecutionStartedEventAttributes": { @@ -16,9 +16,9 @@ "workflowExecutionTimeout": "0s", "workflowRunTimeout": "0s", "workflowTaskTimeout": "10s", - "originalExecutionRunId": "019500e9-42f4-7897-b0d3-726eac6ff3c6", - "identity": "18781@Chetans-MacBook-Pro.local@", - "firstExecutionRunId": "019500e9-42f4-7897-b0d3-726eac6ff3c6", + "originalExecutionRunId": "01950160-2559-7b46-8447-568b05b19367", + "identity": "56153@Chetans-MacBook-Pro.local@", + "firstExecutionRunId": "01950160-2559-7b46-8447-568b05b19367", "attempt": 1, "firstWorkflowTaskBackoff": "0s", "header": {}, @@ -27,7 +27,7 @@ }, { "eventId": "2", - "eventTime": "2025-02-13T20:04:01.908657Z", + "eventTime": "2025-02-13T22:13:53.113796Z", "eventType": "WorkflowTaskScheduled", "taskId": "1048577", "workflowTaskScheduledEventAttributes": { @@ -41,27 +41,27 @@ }, { "eventId": "3", - "eventTime": "2025-02-13T20:04:01.930346Z", + "eventTime": "2025-02-13T22:13:53.136108Z", "eventType": "WorkflowTaskStarted", "taskId": "1048582", "workflowTaskStartedEventAttributes": { "scheduledEventId": "2", - "identity": "18680@Chetans-MacBook-Pro.local@", - "requestId": "893216a6-6421-470b-8267-451d2116ee5c", - "historySizeBytes": "297" + "identity": "56115@Chetans-MacBook-Pro.local@", + "requestId": "3aeec002-c3ba-45f2-bee9-e9af2b80e87f", + "historySizeBytes": "295" } }, { "eventId": "4", - "eventTime": "2025-02-13T20:04:01.963131Z", + "eventTime": "2025-02-13T22:13:53.166502Z", "eventType": "WorkflowTaskCompleted", "taskId": "1048586", "workflowTaskCompletedEventAttributes": { "scheduledEventId": "2", "startedEventId": "3", - "identity": "18680@Chetans-MacBook-Pro.local@", + "identity": "56115@Chetans-MacBook-Pro.local@", "workerVersion": { - "buildId": "6213b43af5b83a4356641f12cd89b58e" + "buildId": "a277330db220a2781727bb4745e33c3f" }, "sdkMetadata": { "langUsedFlags": [ @@ -75,13 +75,13 @@ }, { "eventId": "5", - "eventTime": "2025-02-13T20:04:01.963282Z", + "eventTime": "2025-02-13T22:13:53.166604Z", "eventType": "StartChildWorkflowExecutionInitiated", "taskId": "1048587", "startChildWorkflowExecutionInitiatedEventAttributes": { "namespace": "default", - "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", - "workflowId": "019500e9-42f4-7897-b0d3-726eac6ff3c6_5", + "namespaceId": "802222ac-c291-449e-a204-d658e5724955", + "workflowId": "01950160-2559-7b46-8447-568b05b19367_5", "workflowType": { "name": "TestChildWorkflow" }, @@ -111,16 +111,16 @@ }, { "eventId": "6", - "eventTime": "2025-02-13T20:04:01.998775Z", + "eventTime": "2025-02-13T22:13:53.195160Z", "eventType": "ChildWorkflowExecutionStarted", "taskId": "1048591", "childWorkflowExecutionStartedEventAttributes": { "namespace": "default", - "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "namespaceId": "802222ac-c291-449e-a204-d658e5724955", "initiatedEventId": "5", "workflowExecution": { - "workflowId": "019500e9-42f4-7897-b0d3-726eac6ff3c6_5", - "runId": "019500e9-4340-7b1f-bd78-c4e790f6ee75" + "workflowId": "01950160-2559-7b46-8447-568b05b19367_5", + "runId": "01950160-25a1-7459-b37d-fc3f04f31c54" }, "workflowType": { "name": "TestChildWorkflow" @@ -130,12 +130,12 @@ }, { "eventId": "7", - "eventTime": "2025-02-13T20:04:01.998785Z", + "eventTime": "2025-02-13T22:13:53.195166Z", "eventType": "WorkflowTaskScheduled", "taskId": "1048592", "workflowTaskScheduledEventAttributes": { "taskQueue": { - "name": "Chetans-MacBook-Pro.local:9000c21f-2b60-4db6-ba6b-0fca943abea7", + "name": "Chetans-MacBook-Pro.local:e70ca8e4-1e99-469e-a225-00d9321a7d80", "kind": "Sticky", "normalName": "child-workflow-test-queue" }, @@ -145,27 +145,27 @@ }, { "eventId": "8", - "eventTime": "2025-02-13T20:04:02.008738Z", + "eventTime": "2025-02-13T22:13:53.205568Z", "eventType": "WorkflowTaskStarted", "taskId": "1048597", "workflowTaskStartedEventAttributes": { "scheduledEventId": "7", - "identity": "18680@Chetans-MacBook-Pro.local@", - "requestId": "713e4b74-e3f6-4a24-bca6-543b7a83550a", - "historySizeBytes": "1104" + "identity": "56115@Chetans-MacBook-Pro.local@", + "requestId": "4df83586-7eee-4208-a952-3cb4bb3e5366", + "historySizeBytes": "1097" } }, { "eventId": "9", - "eventTime": "2025-02-13T20:04:02.022741Z", + "eventTime": "2025-02-13T22:13:53.214995Z", "eventType": "WorkflowTaskCompleted", "taskId": "1048601", "workflowTaskCompletedEventAttributes": { "scheduledEventId": "7", "startedEventId": "8", - "identity": "18680@Chetans-MacBook-Pro.local@", + "identity": "56115@Chetans-MacBook-Pro.local@", "workerVersion": { - "buildId": "6213b43af5b83a4356641f12cd89b58e" + "buildId": "a277330db220a2781727bb4745e33c3f" }, "sdkMetadata": {}, "meteringMetadata": {} @@ -173,7 +173,7 @@ }, { "eventId": "10", - "eventTime": "2025-02-13T20:04:04.106279Z", + "eventTime": "2025-02-13T22:13:55.267309Z", "eventType": "ChildWorkflowExecutionCompleted", "taskId": "1048603", "childWorkflowExecutionCompletedEventAttributes": { @@ -188,10 +188,10 @@ ] }, "namespace": "default", - "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", + "namespaceId": "802222ac-c291-449e-a204-d658e5724955", "workflowExecution": { - "workflowId": "019500e9-42f4-7897-b0d3-726eac6ff3c6_5", - "runId": "019500e9-4340-7b1f-bd78-c4e790f6ee75" + "workflowId": "01950160-2559-7b46-8447-568b05b19367_5", + "runId": "01950160-25a1-7459-b37d-fc3f04f31c54" }, "workflowType": { "name": "TestChildWorkflow" @@ -202,12 +202,12 @@ }, { "eventId": "11", - "eventTime": "2025-02-13T20:04:04.106293Z", + "eventTime": "2025-02-13T22:13:55.267317Z", "eventType": "WorkflowTaskScheduled", "taskId": "1048604", "workflowTaskScheduledEventAttributes": { "taskQueue": { - "name": "Chetans-MacBook-Pro.local:9000c21f-2b60-4db6-ba6b-0fca943abea7", + "name": "Chetans-MacBook-Pro.local:e70ca8e4-1e99-469e-a225-00d9321a7d80", "kind": "Sticky", "normalName": "child-workflow-test-queue" }, @@ -217,37 +217,84 @@ }, { "eventId": "12", - "eventTime": "2025-02-13T20:04:04.125989Z", + "eventTime": "2025-02-13T22:13:55.284276Z", "eventType": "WorkflowTaskStarted", "taskId": "1048608", "workflowTaskStartedEventAttributes": { "scheduledEventId": "11", - "identity": "18680@Chetans-MacBook-Pro.local@", - "requestId": "d481f043-cae6-422a-a4a6-e4dec5881cab", - "historySizeBytes": "1702" + "identity": "56115@Chetans-MacBook-Pro.local@", + "requestId": "e3e47143-240f-40c7-a15a-db6f5bdbfe68", + "historySizeBytes": "1695" } }, { "eventId": "13", - "eventTime": "2025-02-13T20:04:04.143914Z", - "eventType": "WorkflowTaskCompleted", - "taskId": "1048612", - "workflowTaskCompletedEventAttributes": { + "eventTime": "2025-02-13T22:14:01.670430Z", + "eventType": "WorkflowTaskFailed", + "taskId": "1048619", + "workflowTaskFailedEventAttributes": { "scheduledEventId": "11", "startedEventId": "12", - "identity": "18680@Chetans-MacBook-Pro.local@", + "cause": "ResetWorkflow", + "failure": { + "message": "chetan:testing reset", + "resetWorkflowFailureInfo": {} + }, + "identity": "history-service", + "baseRunId": "01950160-2559-7b46-8447-568b05b19367", + "newRunId": "b64f8938-b361-4a06-8821-a5d5ad8c8992" + } + }, + { + "eventId": "14", + "eventTime": "2025-02-13T22:14:01.672896Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048620", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "15", + "eventTime": "2025-02-13T22:14:01.688254Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048625", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "14", + "identity": "56115@Chetans-MacBook-Pro.local@", + "requestId": "10d6641e-6dac-454a-adfd-1d3f68144788", + "historySizeBytes": "2050" + } + }, + { + "eventId": "16", + "eventTime": "2025-02-13T22:14:01.707427Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048629", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "14", + "startedEventId": "15", + "identity": "56115@Chetans-MacBook-Pro.local@", "workerVersion": { - "buildId": "6213b43af5b83a4356641f12cd89b58e" + "buildId": "a277330db220a2781727bb4745e33c3f" + }, + "sdkMetadata": { + "sdkName": "temporal-go", + "sdkVersion": "1.32.1" }, - "sdkMetadata": {}, "meteringMetadata": {} } }, { - "eventId": "14", - "eventTime": "2025-02-13T20:04:04.143951Z", + "eventId": "17", + "eventTime": "2025-02-13T22:14:01.707453Z", "eventType": "WorkflowExecutionCompleted", - "taskId": "1048613", + "taskId": "1048630", "workflowExecutionCompletedEventAttributes": { "result": { "payloads": [ @@ -259,7 +306,7 @@ } ] }, - "workflowTaskCompletedEventId": "13" + "workflowTaskCompletedEventId": "16" } } ] diff --git a/test/replaytests/reset-workflow-before-child-init.json b/test/replaytests/reset-workflow-before-child-init.json new file mode 100644 index 000000000..1b05044fb --- /dev/null +++ b/test/replaytests/reset-workflow-before-child-init.json @@ -0,0 +1,310 @@ +{ + "events": [ + { + "eventId": "1", + "eventTime": "2025-02-13T21:55:05.549984Z", + "eventType": "WorkflowExecutionStarted", + "taskId": "1048576", + "workflowExecutionStartedEventAttributes": { + "workflowType": { + "name": "ResetWorkflowWithChild" + }, + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "workflowExecutionTimeout": "0s", + "workflowRunTimeout": "0s", + "workflowTaskTimeout": "10s", + "originalExecutionRunId": "0195014e-f0cd-7efb-916a-ed234543d9b1", + "identity": "50567@Chetans-MacBook-Pro.local@", + "firstExecutionRunId": "0195014e-f0cd-7efb-916a-ed234543d9b1", + "attempt": 1, + "firstWorkflowTaskBackoff": "0s", + "header": {}, + "workflowId": "parent-workflow-id" + } + }, + { + "eventId": "2", + "eventTime": "2025-02-13T21:55:05.550096Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048577", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "3", + "eventTime": "2025-02-13T21:55:05.571533Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048582", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "2", + "identity": "50541@Chetans-MacBook-Pro.local@", + "requestId": "e6ac69d4-8407-406c-8a54-ac35986d3cff", + "historySizeBytes": "297" + } + }, + { + "eventId": "4", + "eventTime": "2025-02-13T21:55:25.756043Z", + "eventType": "WorkflowTaskFailed", + "taskId": "1048650", + "workflowTaskFailedEventAttributes": { + "scheduledEventId": "2", + "startedEventId": "3", + "cause": "ResetWorkflow", + "failure": { + "message": "chetan:testing reset", + "resetWorkflowFailureInfo": {} + }, + "identity": "history-service", + "baseRunId": "0195014e-f0cd-7efb-916a-ed234543d9b1", + "newRunId": "3129cd20-4f19-4066-aa0b-23dd7e363424" + } + }, + { + "eventId": "5", + "eventTime": "2025-02-13T21:55:25.757915Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048651", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "6", + "eventTime": "2025-02-13T21:55:25.772221Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048656", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "5", + "identity": "50541@Chetans-MacBook-Pro.local@", + "requestId": "9dea1650-f3db-4fc2-8dee-dd65a8250f11", + "historySizeBytes": "652" + } + }, + { + "eventId": "7", + "eventTime": "2025-02-13T21:55:25.786888Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048660", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "5", + "startedEventId": "6", + "identity": "50541@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "622ff21cd5fefabab2a70f9f04f5eabb" + }, + "sdkMetadata": { + "langUsedFlags": [ + 3 + ], + "sdkName": "temporal-go", + "sdkVersion": "1.32.1" + }, + "meteringMetadata": {} + } + }, + { + "eventId": "8", + "eventTime": "2025-02-13T21:55:25.786933Z", + "eventType": "StartChildWorkflowExecutionInitiated", + "taskId": "1048661", + "startChildWorkflowExecutionInitiatedEventAttributes": { + "namespace": "default", + "namespaceId": "a1576956-7d24-4a2b-8e6c-1477979b053e", + "workflowId": "3129cd20-4f19-4066-aa0b-23dd7e363424_8", + "workflowType": { + "name": "TestChildWorkflow" + }, + "taskQueue": { + "name": "child-workflow-test-queue", + "kind": "Normal" + }, + "input": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkNISUxEIElOUFVUIg==" + } + ] + }, + "workflowExecutionTimeout": "0s", + "workflowRunTimeout": "0s", + "workflowTaskTimeout": "10s", + "parentClosePolicy": "Terminate", + "workflowTaskCompletedEventId": "7", + "workflowIdReusePolicy": "AllowDuplicate", + "header": {}, + "useCompatibleVersion": true + } + }, + { + "eventId": "9", + "eventTime": "2025-02-13T21:55:25.811375Z", + "eventType": "ChildWorkflowExecutionStarted", + "taskId": "1048669", + "childWorkflowExecutionStartedEventAttributes": { + "namespace": "default", + "namespaceId": "a1576956-7d24-4a2b-8e6c-1477979b053e", + "initiatedEventId": "8", + "workflowExecution": { + "workflowId": "3129cd20-4f19-4066-aa0b-23dd7e363424_8", + "runId": "0195014f-3fe8-75b4-9468-9eaa7bd7fce5" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "header": {} + } + }, + { + "eventId": "10", + "eventTime": "2025-02-13T21:55:25.811383Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048670", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "Chetans-MacBook-Pro.local:64ec3e04-335b-4ef7-9ff5-f237d8dbc95c", + "kind": "Sticky", + "normalName": "child-workflow-test-queue" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "11", + "eventTime": "2025-02-13T21:55:25.822002Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048678", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "10", + "identity": "50541@Chetans-MacBook-Pro.local@", + "requestId": "08ae2fe6-2115-4daf-b748-d4ae04328166", + "historySizeBytes": "1459" + } + }, + { + "eventId": "12", + "eventTime": "2025-02-13T21:55:25.842868Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048685", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "10", + "startedEventId": "11", + "identity": "50541@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "622ff21cd5fefabab2a70f9f04f5eabb" + }, + "sdkMetadata": {}, + "meteringMetadata": {} + } + }, + { + "eventId": "13", + "eventTime": "2025-02-13T21:55:27.910532Z", + "eventType": "ChildWorkflowExecutionCompleted", + "taskId": "1048708", + "childWorkflowExecutionCompletedEventAttributes": { + "result": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkhlbGxvIENISUxEIElOUFVUISI=" + } + ] + }, + "namespace": "default", + "namespaceId": "a1576956-7d24-4a2b-8e6c-1477979b053e", + "workflowExecution": { + "workflowId": "3129cd20-4f19-4066-aa0b-23dd7e363424_8", + "runId": "0195014f-3fe8-75b4-9468-9eaa7bd7fce5" + }, + "workflowType": { + "name": "TestChildWorkflow" + }, + "initiatedEventId": "8", + "startedEventId": "9" + } + }, + { + "eventId": "14", + "eventTime": "2025-02-13T21:55:27.910542Z", + "eventType": "WorkflowTaskScheduled", + "taskId": "1048709", + "workflowTaskScheduledEventAttributes": { + "taskQueue": { + "name": "Chetans-MacBook-Pro.local:64ec3e04-335b-4ef7-9ff5-f237d8dbc95c", + "kind": "Sticky", + "normalName": "child-workflow-test-queue" + }, + "startToCloseTimeout": "10s", + "attempt": 1 + } + }, + { + "eventId": "15", + "eventTime": "2025-02-13T21:55:27.924369Z", + "eventType": "WorkflowTaskStarted", + "taskId": "1048713", + "workflowTaskStartedEventAttributes": { + "scheduledEventId": "14", + "identity": "50541@Chetans-MacBook-Pro.local@", + "requestId": "57b84006-6fdb-420a-8d2a-6dccf6e7277f", + "historySizeBytes": "2061" + } + }, + { + "eventId": "16", + "eventTime": "2025-02-13T21:55:27.939558Z", + "eventType": "WorkflowTaskCompleted", + "taskId": "1048717", + "workflowTaskCompletedEventAttributes": { + "scheduledEventId": "14", + "startedEventId": "15", + "identity": "50541@Chetans-MacBook-Pro.local@", + "workerVersion": { + "buildId": "622ff21cd5fefabab2a70f9f04f5eabb" + }, + "sdkMetadata": {}, + "meteringMetadata": {} + } + }, + { + "eventId": "17", + "eventTime": "2025-02-13T21:55:27.939592Z", + "eventType": "WorkflowExecutionCompleted", + "taskId": "1048718", + "workflowExecutionCompletedEventAttributes": { + "result": { + "payloads": [ + { + "metadata": { + "encoding": "anNvbi9wbGFpbg==" + }, + "data": "IkhlbGxvIENISUxEIElOUFVUISI=" + } + ] + }, + "workflowTaskCompletedEventId": "16" + } + } + ] +} diff --git a/test/replaytests/reset-workflow-with-child-failed.json b/test/replaytests/reset-workflow-with-child-failed.json deleted file mode 100644 index e666291b9..000000000 --- a/test/replaytests/reset-workflow-with-child-failed.json +++ /dev/null @@ -1,275 +0,0 @@ -{ - "events": [ - { - "eventId": "1", - "eventTime": "2025-02-13T20:14:02.650135Z", - "eventType": "WorkflowExecutionStarted", - "taskId": "1048618", - "workflowExecutionStartedEventAttributes": { - "workflowType": { - "name": "ResetWorkflowWithChild" - }, - "taskQueue": { - "name": "child-workflow-test-queue", - "kind": "Normal" - }, - "workflowExecutionTimeout": "0s", - "workflowRunTimeout": "0s", - "workflowTaskTimeout": "10s", - "originalExecutionRunId": "019500f2-6d9a-7207-8c9f-69cb0647bbae", - "identity": "23299@Chetans-MacBook-Pro.local@", - "firstExecutionRunId": "019500f2-6d9a-7207-8c9f-69cb0647bbae", - "attempt": 1, - "firstWorkflowTaskBackoff": "0s", - "header": {}, - "workflowId": "parent-workflow-id" - } - }, - { - "eventId": "2", - "eventTime": "2025-02-13T20:14:02.650219Z", - "eventType": "WorkflowTaskScheduled", - "taskId": "1048619", - "workflowTaskScheduledEventAttributes": { - "taskQueue": { - "name": "child-workflow-test-queue", - "kind": "Normal" - }, - "startToCloseTimeout": "10s", - "attempt": 1 - } - }, - { - "eventId": "3", - "eventTime": "2025-02-13T20:14:02.704393Z", - "eventType": "WorkflowTaskStarted", - "taskId": "1048626", - "workflowTaskStartedEventAttributes": { - "scheduledEventId": "2", - "identity": "23259@Chetans-MacBook-Pro.local@", - "requestId": "323d0cf7-54d1-4604-9256-d5c90937403c", - "historySizeBytes": "594" - } - }, - { - "eventId": "4", - "eventTime": "2025-02-13T20:14:02.728590Z", - "eventType": "WorkflowTaskCompleted", - "taskId": "1048630", - "workflowTaskCompletedEventAttributes": { - "scheduledEventId": "2", - "startedEventId": "3", - "identity": "23259@Chetans-MacBook-Pro.local@", - "workerVersion": { - "buildId": "fb33118f3ecb446bcfc5091fbba8aa33" - }, - "sdkMetadata": { - "langUsedFlags": [ - 3 - ], - "sdkName": "temporal-go", - "sdkVersion": "1.32.1" - }, - "meteringMetadata": {} - } - }, - { - "eventId": "5", - "eventTime": "2025-02-13T20:14:02.728670Z", - "eventType": "StartChildWorkflowExecutionInitiated", - "taskId": "1048631", - "startChildWorkflowExecutionInitiatedEventAttributes": { - "namespace": "default", - "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", - "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", - "workflowType": { - "name": "TestChildWorkflow" - }, - "taskQueue": { - "name": "child-workflow-test-queue", - "kind": "Normal" - }, - "input": { - "payloads": [ - { - "metadata": { - "encoding": "anNvbi9wbGFpbg==" - }, - "data": "IkNISUxEIElOUFVUIg==" - } - ] - }, - "workflowExecutionTimeout": "0s", - "workflowRunTimeout": "0s", - "workflowTaskTimeout": "10s", - "parentClosePolicy": "Terminate", - "workflowTaskCompletedEventId": "4", - "workflowIdReusePolicy": "AllowDuplicate", - "header": {}, - "useCompatibleVersion": true - } - }, - { - "eventId": "6", - "eventTime": "2025-02-13T20:14:02.753687Z", - "eventType": "ChildWorkflowExecutionStarted", - "taskId": "1048635", - "childWorkflowExecutionStartedEventAttributes": { - "namespace": "default", - "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", - "initiatedEventId": "5", - "workflowExecution": { - "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", - "runId": "019500f2-6df8-7320-8517-ccbd0eaaf3c7" - }, - "workflowType": { - "name": "TestChildWorkflow" - }, - "header": {} - } - }, - { - "eventId": "7", - "eventTime": "2025-02-13T20:14:02.753698Z", - "eventType": "WorkflowTaskScheduled", - "taskId": "1048636", - "workflowTaskScheduledEventAttributes": { - "taskQueue": { - "name": "Chetans-MacBook-Pro.local:19ef4a77-99af-42ec-ae24-d5d1488aa955", - "kind": "Sticky", - "normalName": "child-workflow-test-queue" - }, - "startToCloseTimeout": "10s", - "attempt": 1 - } - }, - { - "eventId": "8", - "eventTime": "2025-02-13T20:14:02.770381Z", - "eventType": "WorkflowTaskStarted", - "taskId": "1048641", - "workflowTaskStartedEventAttributes": { - "scheduledEventId": "7", - "identity": "23259@Chetans-MacBook-Pro.local@", - "requestId": "934c75ea-43bb-4673-b651-5ca0338acfc3", - "historySizeBytes": "1401" - } - }, - { - "eventId": "9", - "eventTime": "2025-02-13T20:14:02.785845Z", - "eventType": "WorkflowTaskCompleted", - "taskId": "1048645", - "workflowTaskCompletedEventAttributes": { - "scheduledEventId": "7", - "startedEventId": "8", - "identity": "23259@Chetans-MacBook-Pro.local@", - "workerVersion": { - "buildId": "fb33118f3ecb446bcfc5091fbba8aa33" - }, - "sdkMetadata": {}, - "meteringMetadata": {} - } - }, - { - "eventId": "10", - "eventTime": "2025-02-13T20:14:02.803076Z", - "eventType": "ChildWorkflowExecutionFailed", - "taskId": "1048647", - "childWorkflowExecutionFailedEventAttributes": { - "failure": { - "message": "Child workflow execution failed", - "source": "GoSDK", - "applicationFailureInfo": {} - }, - "namespace": "default", - "namespaceId": "5f71958a-e718-4740-9dab-be5c0502e822", - "workflowExecution": { - "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", - "runId": "019500f2-6df8-7320-8517-ccbd0eaaf3c7" - }, - "workflowType": { - "name": "TestChildWorkflow" - }, - "initiatedEventId": "5", - "startedEventId": "6", - "retryState": "RetryPolicyNotSet" - } - }, - { - "eventId": "11", - "eventTime": "2025-02-13T20:14:02.803084Z", - "eventType": "WorkflowTaskScheduled", - "taskId": "1048648", - "workflowTaskScheduledEventAttributes": { - "taskQueue": { - "name": "Chetans-MacBook-Pro.local:19ef4a77-99af-42ec-ae24-d5d1488aa955", - "kind": "Sticky", - "normalName": "child-workflow-test-queue" - }, - "startToCloseTimeout": "10s", - "attempt": 1 - } - }, - { - "eventId": "12", - "eventTime": "2025-02-13T20:14:02.842854Z", - "eventType": "WorkflowTaskStarted", - "taskId": "1048652", - "workflowTaskStartedEventAttributes": { - "scheduledEventId": "11", - "identity": "23259@Chetans-MacBook-Pro.local@", - "requestId": "6c3d79eb-1eef-4e5d-aa19-53fca86d8fe4", - "historySizeBytes": "1999" - } - }, - { - "eventId": "13", - "eventTime": "2025-02-13T20:14:02.854644Z", - "eventType": "WorkflowTaskCompleted", - "taskId": "1048656", - "workflowTaskCompletedEventAttributes": { - "scheduledEventId": "11", - "startedEventId": "12", - "identity": "23259@Chetans-MacBook-Pro.local@", - "workerVersion": { - "buildId": "fb33118f3ecb446bcfc5091fbba8aa33" - }, - "sdkMetadata": {}, - "meteringMetadata": {} - } - }, - { - "eventId": "14", - "eventTime": "2025-02-13T20:14:02.854672Z", - "eventType": "WorkflowExecutionFailed", - "taskId": "1048657", - "workflowExecutionFailedEventAttributes": { - "failure": { - "message": "child workflow execution error", - "source": "GoSDK", - "cause": { - "message": "Child workflow execution failed", - "source": "GoSDK", - "applicationFailureInfo": {} - }, - "childWorkflowExecutionFailureInfo": { - "namespace": "default", - "workflowExecution": { - "workflowId": "019500f2-6d9a-7207-8c9f-69cb0647bbae_5", - "runId": "019500f2-6df8-7320-8517-ccbd0eaaf3c7" - }, - "workflowType": { - "name": "TestChildWorkflow" - }, - "initiatedEventId": "5", - "startedEventId": "6", - "retryState": "RetryPolicyNotSet" - } - }, - "retryState": "RetryPolicyNotSet", - "workflowTaskCompletedEventId": "13" - } - } - ] -} From 985cba888554ecfbc7db4e0a00d80c5df3e82b56 Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Thu, 13 Feb 2025 17:45:34 -0800 Subject: [PATCH 09/10] Add integration tests --- test/integration_test.go | 96 ++++++++++++++++++++++++++++++++++++++++ test/workflow_test.go | 18 ++++++++ 2 files changed, 114 insertions(+) diff --git a/test/integration_test.go b/test/integration_test.go index 8a05591b3..60bbdc616 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -2040,6 +2040,102 @@ 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() { + 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()) + } + fmt.Println(event.String()) + } + return childIDs +} + func (ts *IntegrationTestSuite) TestResetWorkflowExecutionWithUpdate() { ctx := context.Background() wfId := "reset-workflow-execution-with-update" diff --git a/test/workflow_test.go b/test/workflow_test.go index 53aae82dd..13be607dd 100644 --- a/test/workflow_test.go +++ b/test/workflow_test.go @@ -3374,6 +3374,23 @@ func (w *Workflows) WorkflowTemporalPrefixSignal(ctx workflow.Context) error { return nil } +// WorkflowWithChildren starts two child workflows and waits for them to complete in sequence. +func (w *Workflows) WorkflowWithChildren(ctx workflow.Context) (string, error) { + var result string + err := workflow.ExecuteChildWorkflow(ctx, w.child, "hello child-1", false).Get(ctx, &result) + if err != nil { + return "", err + } + + var result2 string + err = workflow.ExecuteChildWorkflow(ctx, w.child, "hello child-2", false).Get(ctx, &result2) + if err != nil { + return "", err + } + + return "Parent Workflow Complete", nil +} + func (w *Workflows) register(worker worker.Worker) { worker.RegisterWorkflow(w.ActivityCancelRepro) worker.RegisterWorkflow(w.ActivityCompletionUsingID) @@ -3447,6 +3464,7 @@ func (w *Workflows) register(worker worker.Worker) { worker.RegisterWorkflow(w.WorkflowWithParallelSideEffects) worker.RegisterWorkflow(w.WorkflowWithParallelMutableSideEffects) worker.RegisterWorkflow(w.WorkflowWithLocalActivityStartToCloseTimeout) + worker.RegisterWorkflow(w.WorkflowWithChildren) worker.RegisterWorkflow(w.LocalActivityStaleCache) worker.RegisterWorkflow(w.UpdateInfoWorkflow) worker.RegisterWorkflow(w.UpdateEntityWorkflow) From a6e46a3186270d65d8e78b3c3c24d1b60b1bf9f0 Mon Sep 17 00:00:00 2001 From: Chetan Gowda Date: Thu, 13 Feb 2025 18:05:34 -0800 Subject: [PATCH 10/10] Remove print --- test/integration_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/test/integration_test.go b/test/integration_test.go index 60bbdc616..162d3e5e3 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -2131,7 +2131,6 @@ func (ts *IntegrationTestSuite) getChildInitEventsFromHistory(ctx context.Contex if event.GetEventType() == enumspb.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED { childIDs = append(childIDs, event.GetStartChildWorkflowExecutionInitiatedEventAttributes().GetWorkflowId()) } - fmt.Println(event.String()) } return childIDs }