Skip to content

Commit

Permalink
IWF-124: Ignore empty output for collector (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwolczynski authored Dec 18, 2024
1 parent 36e5a27 commit 20103a8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
3 changes: 2 additions & 1 deletion integ/internalchannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions integ/locking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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{
Expand Down
8 changes: 2 additions & 6 deletions integ/wf_state_execute_api_fail_and_proceed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
8 changes: 2 additions & 6 deletions integ/wf_state_wait_until_api_fail_and_proceed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 3 additions & 1 deletion service/interpreter/outputCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 20103a8

Please sign in to comment.