Skip to content

Commit 325e7ca

Browse files
authored
IWF-475: Cleanup unnecessary waiting in integ tests and add wait comments (#549)
1 parent e103716 commit 325e7ca

32 files changed

+76
-53
lines changed

integ/any_command_close_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func doTestAnyCommandCloseWorkflow(t *testing.T, backendType service.BackendType
9696
}).Execute()
9797
failTestAtHttpError(err, httpResp, t)
9898

99-
// wait for the workflow
99+
// Wait for the workflow to complete
100100
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
101101
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
102102
WorkflowId: wfId,

integ/any_command_combination_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ func doTestAnyCommandCombinationWorkflow(t *testing.T, backendType service.Backe
108108
}).Execute()
109109
failTestAtHttpError(err, httpResp, t)
110110

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

121+
// Add delay to wait for timer to be skipped
122+
time.Sleep(time.Second)
123+
121124
// now it should be running at S2
122125
// Future: we can check it is already done S1
123126

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

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

156-
// workflow should be completed now
157+
// Workflow should be completed now
157158
if config == nil {
159+
// Wait for workflow to move to execution
158160
time.Sleep(time.Second)
159161
descResp, httpResp, err = reqDesc.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
160162
WorkflowId: wfId,

integ/any_timer_signal_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func doTestAnyTimerSignalWorkflow(t *testing.T, backendType service.BackendType,
125125
}).Execute()
126126
failTestAtHttpError(err, httpResp, t)
127127

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

142-
// wait for the workflow
142+
// Wait for the workflow to complete
143143
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
144144
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
145145
WorkflowId: wfId,

integ/conditional_close_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func doTestConditionalForceCompleteOnChannelEmptyWorkflow(
107107
_, httpResp, err := req.WorkflowStartRequest(startReq).Execute()
108108
failTestAtHttpError(err, httpResp, t)
109109

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

129129
failTestAtHttpError(err, httpResp, t)
130130
if i == 0 {
131-
// wait for a second so that the workflow is in execute state
131+
// Wait for a second so that the workflow is in execute state
132132
time.Sleep(time.Second)
133133
}
134134
}
135135

136-
// wait for the workflow
136+
// Wait for the workflow to complete
137137
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
138138
resp2, httpResp, err := req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
139139
WorkflowId: wfId,

integ/create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func doTestCreateWithoutStartingState(t *testing.T, backendType service.BackendT
113113
}).Execute()
114114
failTestAtHttpError(err, httpResp, t)
115115

116-
// wait for the workflow
116+
// Wait for the workflow to complete
117117
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
118118
respWait, httpResp, err := reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
119119
WorkflowId: wfId,

integ/deadend_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func doTestDeadEndWorkflow(t *testing.T, backendType service.BackendType, config
8888

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

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

120+
// Wait for workflow to move to execution
118121
time.Sleep(time.Second * 2)
119-
// wait for the workflow
122+
120123
reqCancel := apiClient.DefaultApi.ApiV1WorkflowStopPost(context.Background())
121124
httpResp, err = reqCancel.WorkflowStopRequest(iwfidl.WorkflowStopRequest{
122125
WorkflowId: wfId,

integ/get_with_wait_timeout_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func doTestWorkflowWithWaitTimeout(t *testing.T, backendType service.BackendType
6767
}).Execute()
6868
failTestAtHttpError(err, httpResp, t)
6969

70-
// wait for the workflow
70+
// Wait for the workflow to complete
7171
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
7272
startTimeUnix := time.Now().Unix()
7373
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{

integ/greedy_timer_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func doTestGreedyTimerWorkflowCustomConfig(t *testing.T, backendType service.Bac
103103
}).Execute()
104104
failTestAtHttpError(err, httpResp, t)
105105

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

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

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

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

141-
// wait for the workflow
143+
// Wait for the workflow to complete
142144
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
143145
_, httpResp, err = req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
144146
WorkflowId: wfId,
@@ -176,6 +178,7 @@ func scheduleTimerAndAssertExpectedScheduled(
176178
}).Execute()
177179
failTestAtHttpError(err, httpResp, t)
178180

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

181184
debug := service.DebugDumpResponse{}

integ/large_data_attributes_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func doTestLargeQueryAttributes(t *testing.T, backendType service.BackendType, c
110110
failTestAtHttpError(err, httpResp2, t)
111111
}
112112

113-
// wait for the workflow
113+
// Wait for the workflow to complete
114114
reqWait := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
115115
_, httpResp, err = reqWait.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
116116
WorkflowId: wfId,

integ/locking_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
132132
ValueType: iwfidl.INT.Ptr(),
133133
},
134134
}
135+
// Adding delay between rpc requests
135136
time.Sleep(time.Second * 2)
136137
reqRpc := apiClient.DefaultApi.ApiV1WorkflowRpcPost(context.Background())
137138
rpcResp, httpResp, err := reqRpc.WorkflowRpcRequest(iwfidl.WorkflowRpcRequest{
@@ -186,6 +187,7 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
186187
fmt.Println("rpc results, success, failure:", rpcIncrease, rpcLockingFailure)
187188
}
188189

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

200+
// 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
201+
// will match the 10*(1+1) = 20s sleep here.
198202
time.Sleep(time.Second * 20)
199203
req2 := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
200204
resp2, httpResp, err := req2.WorkflowGetRequest(iwfidl.WorkflowGetRequest{
@@ -271,6 +275,8 @@ func doTestLockingWorkflow(t *testing.T, backendType service.BackendType, config
271275
}).Execute()
272276
failTestAtHttpError(err, httpResp, t)
273277

278+
// 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
279+
// will match the 10*(1+1) = 20s sleep here.
274280
time.Sleep(time.Second * 20)
275281
req2Reset := apiClient.DefaultApi.ApiV1WorkflowGetWithWaitPost(context.Background())
276282
resp2Reset, httpResp, err := req2Reset.WorkflowGetRequest(iwfidl.WorkflowGetRequest{

0 commit comments

Comments
 (0)