Skip to content

Commit

Permalink
IWF-124: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lwolczynski committed Dec 18, 2024
1 parent 4748f34 commit 6543355
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 40 deletions.
6 changes: 3 additions & 3 deletions integ/internalchannel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import (
"time"
)

// TODO: Fix
func _TestInterStateWorkflowTemporal(t *testing.T) {
func TestInterStateWorkflowTemporal(t *testing.T) {
if !*temporalIntegTest {
t.Skip()
}
Expand Down Expand Up @@ -88,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
10 changes: 4 additions & 6 deletions integ/locking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
"github.com/stretchr/testify/assert"
)

// TODO: Fix
func _TestLockingWorkflowTemporal(t *testing.T) {
func TestLockingWorkflowTemporal(t *testing.T) {
if !*temporalIntegTest {
t.Skip()
}
Expand All @@ -27,8 +26,7 @@ func _TestLockingWorkflowTemporal(t *testing.T) {
}
}

// TODO: Fix
func _TestLockingWorkflowTemporalContinueAsNew(t *testing.T) {
func TestLockingWorkflowTemporalContinueAsNew(t *testing.T) {
if !*temporalIntegTest {
t.Skip()
}
Expand Down Expand Up @@ -200,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 @@ -212,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
11 changes: 3 additions & 8 deletions integ/wf_state_execute_api_fail_and_proceed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
"github.com/stretchr/testify/assert"
)

// TODO: Fix
func _TestStateExecuteApiFailAndProceedTemporal(t *testing.T) {
func TestStateExecuteApiFailAndProceedTemporal(t *testing.T) {
if !*temporalIntegTest {
t.Skip()
}
Expand Down Expand Up @@ -104,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")
}
11 changes: 3 additions & 8 deletions integ/wf_state_wait_until_api_fail_and_proceed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import (
"github.com/stretchr/testify/assert"
)

// TODO: Fix
func _TestStateApiFailAndProceedTemporal(t *testing.T) {
func TestStateApiFailAndProceedTemporal(t *testing.T) {
if !*temporalIntegTest {
t.Skip()
}
Expand Down Expand Up @@ -103,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")
}
19 changes: 4 additions & 15 deletions service/interpreter/outputCollector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,11 @@ type OutputCollector struct {
}

func NewOutputCollector(initOutputs []iwfidl.StateCompletionOutput) *OutputCollector {
filteredOutputs := []iwfidl.StateCompletionOutput{}

if initOutputs == nil {
return &OutputCollector{
outputs: filteredOutputs,
}
} else {
for _, output := range initOutputs {
if output.CompletedStateOutput != nil {
filteredOutputs = append(filteredOutputs, output)
}
}

return &OutputCollector{
outputs: filteredOutputs,
}
initOutputs = []iwfidl.StateCompletionOutput{}
}
return &OutputCollector{
outputs: initOutputs,
}
}

Expand Down

0 comments on commit 6543355

Please sign in to comment.