From 20103a8ad81a7a7397610bea8bbd0f584eef3c93 Mon Sep 17 00:00:00 2001 From: lwolczynski <54366429+lwolczynski@users.noreply.github.com> Date: Wed, 18 Dec 2024 09:51:12 -0600 Subject: [PATCH] IWF-124: Ignore empty output for collector (#524) --- integ/internalchannel_test.go | 3 ++- integ/locking_test.go | 4 ++-- integ/wf_state_execute_api_fail_and_proceed_test.go | 8 ++------ integ/wf_state_wait_until_api_fail_and_proceed_test.go | 8 ++------ service/interpreter/outputCollector.go | 4 +++- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/integ/internalchannel_test.go b/integ/internalchannel_test.go index ca727490..3d44b805 100644 --- a/integ/internalchannel_test.go +++ b/integ/internalchannel_test.go @@ -87,7 +87,8 @@ func doTestInterStateWorkflow(t *testing.T, backendType service.BackendType, con }, history, "interstate test fail, %v", history) assertions.Equal(iwfidl.COMPLETED, resp2.GetWorkflowStatus()) - assertions.Equal(1, len(resp2.GetResults())) + // State completions with empty output are ignored + assertions.Equal(0, len(resp2.GetResults())) assertions.Equal(map[string]interface{}{ interstate.State21 + "received": interstate.TestVal1, interstate.State31 + "received": interstate.TestVal2, diff --git a/integ/locking_test.go b/integ/locking_test.go index aeba50e8..fffd4777 100644 --- a/integ/locking_test.go +++ b/integ/locking_test.go @@ -198,7 +198,6 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config s2StartsDecides := locking.InParallelS2 + rpcIncrease // locking.InParallelS2 original state executions, and a new trigger from rpc finalCounterValue := int64(locking.InParallelS2 + 2*rpcIncrease) - stateCompletionCount := locking.InParallelS2 + rpcIncrease + 1 history, _ := wfHandler.GetTestResult() assertions.Equalf(map[string]int64{ "S1_start": 1, @@ -210,7 +209,8 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config }, history, "locking.test fail, %v", history) assertions.Equal(iwfidl.COMPLETED, resp2.GetWorkflowStatus()) - assertions.Equal(stateCompletionCount, len(resp2.GetResults())) + // State completions with empty output are ignored + assertions.Equal(0, len(resp2.GetResults())) reqSearch := apiClient.DefaultApi.ApiV1WorkflowSearchattributesGetPost(context.Background()) searchResult2, httpResp, err := reqSearch.WorkflowGetSearchAttributesRequest(iwfidl.WorkflowGetSearchAttributesRequest{ diff --git a/integ/wf_state_execute_api_fail_and_proceed_test.go b/integ/wf_state_execute_api_fail_and_proceed_test.go index 81b7ddce..177f7909 100644 --- a/integ/wf_state_execute_api_fail_and_proceed_test.go +++ b/integ/wf_state_execute_api_fail_and_proceed_test.go @@ -103,11 +103,7 @@ func doTestStateExecuteApiFailAndProceed(t *testing.T, backendType service.Backe assertions.Equalf(&iwfidl.WorkflowGetResponse{ WorkflowRunId: startResp.GetWorkflowRunId(), WorkflowStatus: iwfidl.COMPLETED, - Results: []iwfidl.StateCompletionOutput{ - { - CompletedStateId: wf_execute_api_fail_and_proceed.StateRecover, - CompletedStateExecutionId: wf_execute_api_fail_and_proceed.StateRecover + "-1", - }, - }, + // State completions with empty output are ignored + Results: []iwfidl.StateCompletionOutput(nil), }, resp, "response not expected") } diff --git a/integ/wf_state_wait_until_api_fail_and_proceed_test.go b/integ/wf_state_wait_until_api_fail_and_proceed_test.go index 9913d2c3..45140c72 100644 --- a/integ/wf_state_wait_until_api_fail_and_proceed_test.go +++ b/integ/wf_state_wait_until_api_fail_and_proceed_test.go @@ -102,11 +102,7 @@ func doTestStateApiFailAndProceed(t *testing.T, backendType service.BackendType, assertions.Equalf(&iwfidl.WorkflowGetResponse{ WorkflowRunId: startResp.GetWorkflowRunId(), WorkflowStatus: iwfidl.COMPLETED, - Results: []iwfidl.StateCompletionOutput{ - { - CompletedStateId: wf_state_api_fail_and_proceed.State1, - CompletedStateExecutionId: wf_state_api_fail_and_proceed.State1 + "-1", - }, - }, + // State completions with empty output are ignored + Results: []iwfidl.StateCompletionOutput(nil), }, resp, "response not expected") } diff --git a/service/interpreter/outputCollector.go b/service/interpreter/outputCollector.go index b28332b8..10da70cd 100644 --- a/service/interpreter/outputCollector.go +++ b/service/interpreter/outputCollector.go @@ -16,7 +16,9 @@ func NewOutputCollector(initOutputs []iwfidl.StateCompletionOutput) *OutputColle } func (o *OutputCollector) Add(output iwfidl.StateCompletionOutput) { - o.outputs = append(o.outputs, output) + if output.CompletedStateOutput != nil { + o.outputs = append(o.outputs, output) + } } func (o *OutputCollector) GetAll() []iwfidl.StateCompletionOutput {