Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IWF-475: Cleanup unnecessary waiting in integ tests and add wait comments #549

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integ/any_command_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func doTestAnyCommandCloseWorkflow(t *testing.T, backendType service.BackendType
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
12 changes: 7 additions & 5 deletions integ/any_command_combination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func doTestAnyCommandCombinationWorkflow(t *testing.T, backendType service.Backe
}).Execute()
failTestAtHttpError(err, httpResp, t)

// skip the timer for S1
time.Sleep(time.Second * 5) // wait for a few seconds so that timer is ready to be skipped
// Skip the timer for S1
time.Sleep(time.Second * 5) // Wait for a few seconds so that timer is ready to be skipped
req3 := apiClient.DefaultApi.ApiV1WorkflowTimerSkipPost(context.Background())
httpResp, err = req3.WorkflowSkipTimerRequest(iwfidl.WorkflowSkipTimerRequest{
WorkflowId: wfId,
Expand All @@ -118,6 +118,9 @@ func doTestAnyCommandCombinationWorkflow(t *testing.T, backendType service.Backe
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Add delay to wait for timer to be skipped
time.Sleep(time.Second)

// now it should be running at S2
// Future: we can check it is already done S1

Expand All @@ -129,8 +132,6 @@ func doTestAnyCommandCombinationWorkflow(t *testing.T, backendType service.Backe
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait and check the workflow, it should be still running
time.Sleep(time.Second)
reqDesc := apiClient.DefaultApi.ApiV1WorkflowGetPost(context.Background())
descResp, httpResp, err := reqDesc.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand All @@ -153,8 +154,9 @@ func doTestAnyCommandCombinationWorkflow(t *testing.T, backendType service.Backe
}).Execute()
failTestAtHttpError(err, httpResp, t)

// workflow should be completed now
// Workflow should be completed now
if config == nil {
// Wait for workflow to move to execution
time.Sleep(time.Second)
descResp, httpResp, err = reqDesc.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
4 changes: 2 additions & 2 deletions integ/any_timer_signal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func doTestAnyTimerSignalWorkflow(t *testing.T, backendType service.BackendType,
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for 3 secs and send the signal
// Delay for 3 secs and then send the signal
time.Sleep(time.Second * 3)
signalValue := iwfidl.EncodedObject{
Encoding: iwfidl.PtrString("json"),
Expand All @@ -139,7 +139,7 @@ func doTestAnyTimerSignalWorkflow(t *testing.T, backendType service.BackendType,
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
6 changes: 3 additions & 3 deletions integ/conditional_close_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func doTestConditionalForceCompleteOnChannelEmptyWorkflow(
_, httpResp, err := req.WorkflowStartRequest(startReq).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for a second so that query handler is ready for executing PRC
// Wait for a second so that query handler is ready for executing PRC
time.Sleep(time.Second)
// invoke RPC to send 1 messages to the internal channel to unblock the waitUntil
// then send another two messages
Expand All @@ -128,12 +128,12 @@ func doTestConditionalForceCompleteOnChannelEmptyWorkflow(

failTestAtHttpError(err, httpResp, t)
if i == 0 {
// wait for a second so that the workflow is in execute state
// Wait for a second so that the workflow is in execute state
time.Sleep(time.Second)
}
}

// wait for the workflow
// Wait for the workflow to complete
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
resp2, httpResp, err := req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
2 changes: 1 addition & 1 deletion integ/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func doTestCreateWithoutStartingState(t *testing.T, backendType service.BackendT
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
respWait, httpResp, err := reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
5 changes: 4 additions & 1 deletion integ/deadend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func doTestDeadEndWorkflow(t *testing.T, backendType service.BackendType, config

// invoke RPC to trigger write to verify continue as new is happening with no states
for i := 0; i < 3; i++ {
// Delay between rpc requests
time.Sleep(time.Second * 2)
_, httpResp, err = reqRpc.WorkflowRpcRequest(iwfidl.WorkflowRpcRequest{
WorkflowId: wfId,
Expand All @@ -107,6 +108,7 @@ func doTestDeadEndWorkflow(t *testing.T, backendType service.BackendType, config

// invoke an RPC to trigger the state execution
for i := 0; i < 3; i++ {
// Delay between rpc requests
time.Sleep(time.Second * 2)
_, httpResp, err = reqRpc.WorkflowRpcRequest(iwfidl.WorkflowRpcRequest{
WorkflowId: wfId,
Expand All @@ -115,8 +117,9 @@ func doTestDeadEndWorkflow(t *testing.T, backendType service.BackendType, config
failTestAtHttpError(err, httpResp, t)
}

// Wait for workflow to move to execution
time.Sleep(time.Second * 2)
// wait for the workflow

reqCancel := apiClient.DefaultApi.ApiV1WorkflowStopPost(context.Background())
httpResp, err = reqCancel.WorkflowStopRequest(iwfidl.WorkflowStopRequest{
WorkflowId: wfId,
Expand Down
2 changes: 1 addition & 1 deletion integ/get_with_wait_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func doTestWorkflowWithWaitTimeout(t *testing.T, backendType service.BackendType
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
startTimeUnix := time.Now().Unix()
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
Expand Down
5 changes: 4 additions & 1 deletion integ/greedy_timer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func doTestGreedyTimerWorkflowCustomConfig(t *testing.T, backendType service.Bac
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for ApiV1WorkflowStateStart to complete so the timers have been started
time.Sleep(time.Second * 1)

// assertions
Expand All @@ -125,6 +126,7 @@ func doTestGreedyTimerWorkflowCustomConfig(t *testing.T, backendType service.Bac
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for signal to be received and timer to be skipped
time.Sleep(time.Second * 1)

err = uClient.QueryWorkflow(context.Background(), &debug, wfId, "", service.DebugDumpQueryType)
Expand All @@ -138,7 +140,7 @@ func doTestGreedyTimerWorkflowCustomConfig(t *testing.T, backendType service.Bac
assertions.LessOrEqual(singleTimerScheduled, debug.FiringTimersUnixTimestamps[0])
scheduleTimerAndAssertExpectedScheduled(t, apiClient, uClient, wfId, 5, 2)

// wait for the workflow
// Wait for the workflow to complete
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down Expand Up @@ -176,6 +178,7 @@ func scheduleTimerAndAssertExpectedScheduled(
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for RPC request to complete
time.Sleep(time.Second * 1)

debug := service.DebugDumpResponse{}
Expand Down
2 changes: 1 addition & 1 deletion integ/large_data_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func doTestLargeQueryAttributes(t *testing.T, backendType service.BackendType, c
failTestAtHttpError(err, httpResp2, t)
}

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
6 changes: 6 additions & 0 deletions integ/locking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
ValueType: iwfidl.INT.Ptr(),
},
}
// Adding delay between rpc requests
time.Sleep(time.Second * 2)
reqRpc := apiClient.DefaultApi.ApiV1WorkflowRpcPost(context.Background())
rpcResp, httpResp, err := reqRpc.WorkflowRpcRequest(iwfidl.WorkflowRpcRequest{
Expand Down Expand Up @@ -186,6 +187,7 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
fmt.Println("rpc results, success, failure:", rpcIncrease, rpcLockingFailure)
}

// Wait for state to store the attributes
time.Sleep(time.Second * 1)
reqRpc := apiClient.DefaultApi.ApiV1WorkflowRpcPost(context.Background())
_, httpResp, err = reqRpc.WorkflowRpcRequest(iwfidl.WorkflowRpcRequest{
Expand All @@ -195,6 +197,8 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
}).Execute()
failTestAtHttpError(err, httpResp, t)

// State 2 of the workflow has a 1s sleep in both the start and execute phase. 10 instances of State 2 are called so we
// will match the 10*(1+1) = 20s sleep here.
time.Sleep(time.Second * 20)
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
resp2, httpResp, err := req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
Expand Down Expand Up @@ -271,6 +275,8 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
}).Execute()
failTestAtHttpError(err, httpResp, t)

// State 2 of the workflow has a 1s sleep in both the start and execute phase. 10 instances of State 2 are called so we
// will match the 10*(1+1) = 20s sleep here.
time.Sleep(time.Second * 20)
req2Reset := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
resp2Reset, httpResp, err := req2Reset.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
Expand Down
2 changes: 1 addition & 1 deletion integ/parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func doTestParallelWorkflow(t *testing.T, backendType service.BackendType, confi
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the workflow
// Wait for the workflow to complete
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
resp2, httpResp, err := req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
7 changes: 6 additions & 1 deletion integ/persistence_loading_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func doTestPersistenceLoadingPolicy(
}
failTestAtHttpError(err, httpResp, t)

// Wait for workflow
time.Sleep(time.Second * 2)

reqRpc := apiClient.DefaultApi.ApiV1WorkflowRpcPost(context.Background())
Expand Down Expand Up @@ -147,7 +148,11 @@ func doTestPersistenceLoadingPolicy(
}
failTestAtHttpError(err, httpResp, t)

time.Sleep(time.Second * 2)
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
}).Execute()
failTestAtHttpError(err, httpResp, t)

history, _ := wfHandler.GetTestResult()

Expand Down
4 changes: 2 additions & 2 deletions integ/persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func doTestPersistenceWorkflow(
break
}
// Loading data to a continuedAsNew workflow might take a few seconds thus retry mechanism is needed
time.Sleep(time.Millisecond * 1000)
time.Sleep(time.Second)
retryCount += 1
queryResult, httpResp, err = getDataAttributes(initReqQry, wfId, expectedDataAttribute, useMemo)
}
Expand Down Expand Up @@ -381,7 +381,7 @@ func doTestPersistenceWorkflow(
}).Execute()
failTestAtHttpErrorOrWorkflowUncompleted(err, httpResp, resp, t)

// wait for the search attribute index to be ready in ElasticSearch
// Wait for the search attribute index to be ready in ElasticSearch
time.Sleep(time.Duration(*searchWaitTimeIntegTest) * time.Millisecond)

if config != nil {
Expand Down
5 changes: 4 additions & 1 deletion integ/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ func doTestRpcWorkflow(
ValueType: iwfidl.BOOL.Ptr(),
},
}

// Wait for state to store the attributes
time.Sleep(time.Second * 1)

reqRpc := apiClient.DefaultApi.ApiV1WorkflowRpcPost(context.Background())
rpcRespReadOnly, httpResp, err := reqRpc.WorkflowRpcRequest(iwfidl.WorkflowRpcRequest{
WorkflowId: wfId,
Expand Down Expand Up @@ -212,7 +215,7 @@ func doTestRpcWorkflow(
}).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
respWait, httpResp, err := reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
1 change: 1 addition & 0 deletions integ/set_data_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func TestSetDataAttributesTemporal(t *testing.T) {

failTestAtHttpError(err, httpResp2, t)

// Wait for state to store the data attributes
time.Sleep(time.Second)

getReq := apiClient.DefaultApi.ApiV1WorkflowDataobjectsGetPost(context.Background())
Expand Down
1 change: 1 addition & 0 deletions integ/set_search_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func TestSetSearchAttributes(t *testing.T) {

failTestAtHttpError(err, httpResp2, t)

// Wait for state to store the search attributes
time.Sleep(time.Second)

getReq := apiClient.DefaultApi.ApiV1WorkflowSearchattributesGetPost(context.Background())
Expand Down
3 changes: 2 additions & 1 deletion integ/signal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func doTestSignalWorkflow(t *testing.T, backendType service.BackendType, config
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for workflow update
if config != nil {
time.Sleep(2 * time.Second)
}
Expand Down Expand Up @@ -200,7 +201,7 @@ func doTestSignalWorkflow(t *testing.T, backendType service.BackendType, config
failTestAtHttpError(err, httpResp2, t)
}

// wait for the workflow
// Wait for the workflow to complete
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
1 change: 1 addition & 0 deletions integ/start_delay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func doTestStartDelay(t *testing.T, backendType service.BackendType, config *iwf
_, httpResp, err := req.WorkflowStartRequest(startReq).Execute()
failTestAtHttpError(err, httpResp, t)

// The WorkflowStartDelaySeconds is delayed 10s so we need to wait before trying to execute due to timeouts
time.Sleep(5 * time.Second)
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
Expand Down
8 changes: 5 additions & 3 deletions integ/timer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func doTestTimerWorkflow(t *testing.T, backendType service.BackendType, config *
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for timers to get initialized in state
time.Sleep(time.Second * 1)
timerInfos := service.GetCurrentTimerInfosQueryResponse{}
err = uclient.QueryWorkflow(context.Background(), &timerInfos, wfId, "", service.GetCurrentTimerInfosQueryType)
Expand Down Expand Up @@ -171,6 +172,7 @@ func doTestTimerWorkflow(t *testing.T, backendType service.BackendType, config *
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for signal to be received and timer to be skipped
time.Sleep(time.Second * 1)
timerInfos = service.GetCurrentTimerInfosQueryResponse{}
err = uclient.QueryWorkflow(context.Background(), &timerInfos, wfId, "", service.GetCurrentTimerInfosQueryType)
Expand All @@ -180,14 +182,14 @@ func doTestTimerWorkflow(t *testing.T, backendType service.BackendType, config *
timer2.Status = service.TimerSkipped
assertTimerQueryResponseEqual(assertions, expectedTimerInfos, timerInfos)

time.Sleep(time.Second * 1)
httpResp, err = req3.WorkflowSkipTimerRequest(iwfidl.WorkflowSkipTimerRequest{
WorkflowId: wfId,
WorkflowStateExecutionId: "S1-1",
TimerCommandIndex: iwfidl.PtrInt32(2),
}).Execute()
failTestAtHttpError(err, httpResp, t)

// Short wait for signal to be received and timer to be skipped
time.Sleep(time.Second * 1)
timerInfos = service.GetCurrentTimerInfosQueryResponse{}
err = uclient.QueryWorkflow(context.Background(), &timerInfos, wfId, "", service.GetCurrentTimerInfosQueryType)
Expand All @@ -197,7 +199,7 @@ func doTestTimerWorkflow(t *testing.T, backendType service.BackendType, config *
timer3.Status = service.TimerSkipped
assertTimerQueryResponseEqual(assertions, expectedTimerInfos, timerInfos)

// wait for the workflow
// Wait for the workflow to complete
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err = req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand All @@ -215,7 +217,7 @@ func doTestTimerWorkflow(t *testing.T, backendType service.BackendType, config *
assertions.Equal("timer-cmd-id", data["timer_id"])
assertions.True(duration >= 9 && duration <= 11, duration)

// reset with all signals reserved (default behavior)
// Reset with all signals reserved (default behavior)
// Therefore, the skip timer would be reapplied
req4 := apiClient.DefaultApi.ApiV1WorkflowResetPost(context.Background())
_, httpResp, err = req4.WorkflowResetRequest(iwfidl.WorkflowResetRequest{
Expand Down
2 changes: 1 addition & 1 deletion integ/wait_for_state_completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func doTestWaitForStateCompletion(
}
}

// wait for the workflow
// Wait for the workflow to complete
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
_, httpResp, err := req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
WorkflowId: wfId,
Expand Down
1 change: 1 addition & 0 deletions integ/wait_until_search_attributes_optimization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func doTestWaitUntilHistoryCompleted(
_, httpResp, err := reqStart.WorkflowStartRequest(wfReq).Execute()
failTestAtHttpError(err, httpResp, t)

// Wait before sending the signal that would allow State 4 to proceed.
time.Sleep(time.Second * 5)

signalValue := iwfidl.EncodedObject{
Expand Down
2 changes: 1 addition & 1 deletion integ/wait_until_search_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func doTestWaitUntilSearchAttributes(
_, httpResp, err := reqStart.WorkflowStartRequest(wfReq).Execute()
failTestAtHttpError(err, httpResp, t)

// wait for the search attribute index to be ready in ElasticSearch
// Wait for the search attribute index to be ready in ElasticSearch
time.Sleep(time.Duration(*searchWaitTimeIntegTest) * time.Millisecond)

switch mode := config.GetExecutingStateIdMode(); mode {
Expand Down
Loading