Skip to content

Commit

Permalink
Merge branch 'main' into jira/lwolczynski/IWF-129
Browse files Browse the repository at this point in the history
  • Loading branch information
lwolczynski committed Oct 17, 2024
2 parents f848d02 + 2b0fabc commit 4370c48
Show file tree
Hide file tree
Showing 7 changed files with 949 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ iwf-server:

.PHONY: bins release clean

idl-code-gen: #generate/refresh go clent code for idl, do this after update the idl file
idl-code-gen: #generate/refresh go code for idl (API schema), do this after updating the idl file
rm -Rf ./gen ; true
java -jar openapi-generator-cli-6.6.0.jar generate -i iwf-idl/iwf.yaml -g go -o gen/iwfidl/ -p packageName=iwfidl -p generateInterfaces=true -p isGoSubmodule=false --git-user-id indeedeng --git-repo-id iwf-idl
rm ./gen/iwfidl/go.* ; rm -rf ./gen/iwfidl/test; gofmt -s -w gen; true
Expand Down
93 changes: 93 additions & 0 deletions integ/wf_state_options_data_attributes_loading_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package integ

import (
"context"
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/integ/workflow/wf_state_options_data_attributes_loading"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"github.com/stretchr/testify/assert"
"strconv"
"testing"
"time"
)

func TestWfStateOptionsDataAttributesLoading_PARTIAL_WITHOUT_LOCK(t *testing.T) {
for _, backendType := range getBackendTypes() {
for i := 0; i < *repeatIntegTest; i++ {
doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING)
smallWaitForFastTest()
doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING)
smallWaitForFastTest()
}
}
}

func TestWfStateOptionsDataAttributesLoading_PARTIAL_WITH_LOCK(t *testing.T) {
for _, backendType := range getBackendTypes() {
for i := 0; i < *repeatIntegTest; i++ {
doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK)
smallWaitForFastTest()
doTestWfStateOptionsDataAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING)
smallWaitForFastTest()
}
}
}

func doTestWfStateOptionsDataAttributesLoading(
t *testing.T, backendType service.BackendType, loadingType iwfidl.PersistenceLoadingType,
) {
assertions := assert.New(t)

wfHandler := wf_state_options_data_attributes_loading.NewHandler()
closeFunc1 := startWorkflowWorkerWithRpc(wfHandler)
defer closeFunc1()
closeFunc2 := startIwfService(backendType)
defer closeFunc2()

apiClient := iwfidl.NewAPIClient(&iwfidl.Configuration{
Servers: []iwfidl.ServerConfiguration{
{
URL: "http://localhost:" + testIwfServerPort,
},
},
})

wfId := wf_state_options_data_attributes_loading.WorkflowType + "_" + string(loadingType) + "_" + strconv.Itoa(int(time.Now().UnixNano()))

wfInput := &iwfidl.EncodedObject{
Encoding: iwfidl.PtrString("json"),
Data: iwfidl.PtrString(string(loadingType)),
}

req := apiClient.DefaultApi.ApiV1WorkflowStartPost(context.Background())

startReq := iwfidl.WorkflowStartRequest{
WorkflowId: wfId,
IwfWorkflowType: wf_state_options_data_attributes_loading.WorkflowType,
WorkflowTimeoutSeconds: 10,
IwfWorkerUrl: "http://localhost:" + testWorkflowServerPort,
StartStateId: ptr.Any(wf_state_options_data_attributes_loading.State1),
StateInput: wfInput,
}

_, httpResp, err := req.WorkflowStartRequest(startReq).Execute()
panicAtHttpError(err, httpResp)

time.Sleep(time.Second * 2)

history, _ := wfHandler.GetTestResult()

assertions.Equalf(map[string]int64{
"S1_start": 1,
"S1_decide": 1,
"S2_start": 1,
"S2_decide": 1,
"S3_start": 1,
"S3_decide": 1,
"S4_start": 1,
"S4_decide": 1,
"S5_start": 1,
"S5_decide": 1,
}, history, "state options data attributes loading, %v", history)
}
93 changes: 93 additions & 0 deletions integ/wf_state_options_search_attributes_loading_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package integ

import (
"context"
"github.com/indeedeng/iwf/gen/iwfidl"
"github.com/indeedeng/iwf/integ/workflow/wf_state_options_search_attributes_loading"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"github.com/stretchr/testify/assert"
"strconv"
"testing"
"time"
)

func TestWfStateOptionsSearchAttributesLoading_PARTIAL_WITHOUT_LOCK(t *testing.T) {
for _, backendType := range getBackendTypes() {
for i := 0; i < *repeatIntegTest; i++ {
doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING)
smallWaitForFastTest()
doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING)
smallWaitForFastTest()
}
}
}

func TestWfStateOptionsSearchAttributesLoading_PARTIAL_WITH_LOCK(t *testing.T) {
for _, backendType := range getBackendTypes() {
for i := 0; i < *repeatIntegTest; i++ {
doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITH_EXCLUSIVE_LOCK)
smallWaitForFastTest()
doTestWfStateOptionsSearchAttributesLoading(t, backendType, iwfidl.PARTIAL_WITHOUT_LOCKING)
smallWaitForFastTest()
}
}
}

func doTestWfStateOptionsSearchAttributesLoading(
t *testing.T, backendType service.BackendType, loadingType iwfidl.PersistenceLoadingType,
) {
assertions := assert.New(t)

wfHandler := wf_state_options_search_attributes_loading.NewHandler()
closeFunc1 := startWorkflowWorkerWithRpc(wfHandler)
defer closeFunc1()
closeFunc2 := startIwfService(backendType)
defer closeFunc2()

apiClient := iwfidl.NewAPIClient(&iwfidl.Configuration{
Servers: []iwfidl.ServerConfiguration{
{
URL: "http://localhost:" + testIwfServerPort,
},
},
})

wfId := wf_state_options_search_attributes_loading.WorkflowType + "_" + string(loadingType) + "_" + strconv.Itoa(int(time.Now().UnixNano()))

wfInput := &iwfidl.EncodedObject{
Encoding: iwfidl.PtrString("json"),
Data: iwfidl.PtrString(string(loadingType)),
}

req := apiClient.DefaultApi.ApiV1WorkflowStartPost(context.Background())

startReq := iwfidl.WorkflowStartRequest{
WorkflowId: wfId,
IwfWorkflowType: wf_state_options_search_attributes_loading.WorkflowType,
WorkflowTimeoutSeconds: 10,
IwfWorkerUrl: "http://localhost:" + testWorkflowServerPort,
StartStateId: ptr.Any(wf_state_options_search_attributes_loading.State1),
StateInput: wfInput,
}

_, httpResp, err := req.WorkflowStartRequest(startReq).Execute()
panicAtHttpError(err, httpResp)

time.Sleep(time.Second * 2)

history, _ := wfHandler.GetTestResult()

assertions.Equalf(map[string]int64{
"S1_start": 1,
"S1_decide": 1,
"S2_start": 1,
"S2_decide": 1,
"S3_start": 1,
"S3_decide": 1,
"S4_start": 1,
"S4_decide": 1,
"S5_start": 1,
"S5_decide": 1,
}, history, "state options search attributes loading, %v", history)
}
Loading

0 comments on commit 4370c48

Please sign in to comment.