Skip to content

Commit 93af25c

Browse files
committed
fix deadlock on sink shutdown due to full, undrained channel to which nothing can send
1 parent 379564d commit 93af25c

14 files changed

+172
-50
lines changed

system-tests/tests/regression/cre/v2_consensus_regression_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ func ConsensusFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, consensus
4848
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
4949
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
5050
defer cancel()
51-
server.Shutdown(ctx)
52-
close(userLogsCh)
53-
close(baseMessageCh)
51+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
5452
})
5553

5654
for _, bcOutput := range testEnv.CreEnvironment.Blockchains {

system-tests/tests/regression/cre/v2_evm_regression_test.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,12 @@ func EVMReadFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, evmNegative
202202
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
203203
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
204204
defer cancel()
205-
server.Shutdown(ctx)
206-
close(userLogsCh)
207-
close(baseMessageCh)
205+
t_helpers.ShutdownChipSinkWithDrain(
206+
ctx,
207+
server,
208+
userLogsCh,
209+
baseMessageCh,
210+
)
208211
})
209212

210213
for _, bcOutput := range testEnv.CreEnvironment.Blockchains {
@@ -272,9 +275,12 @@ func EVMLogTriggerFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, evmNe
272275
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
273276
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
274277
defer cancel()
275-
server.Shutdown(ctx)
276-
close(userLogsCh)
277-
close(baseMessageCh)
278+
t_helpers.ShutdownChipSinkWithDrain(
279+
ctx,
280+
server,
281+
userLogsCh,
282+
baseMessageCh,
283+
)
278284
})
279285
// drain user logs channel in the background, we are not asserting anything on it
280286
t_helpers.IgnoreUserLogs(t.Context(), userLogsCh)
@@ -374,9 +380,12 @@ func EVMWriteFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, evmNegativ
374380
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
375381
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
376382
defer cancel()
377-
server.Shutdown(ctx)
378-
close(userLogsCh)
379-
close(baseMessageCh)
383+
t_helpers.ShutdownChipSinkWithDrain(
384+
ctx,
385+
server,
386+
userLogsCh,
387+
baseMessageCh,
388+
)
380389
})
381390

382391
for _, bcOutput := range testEnv.CreEnvironment.Blockchains {

system-tests/tests/regression/cre/v2_http_action_regression_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ func HTTPActionFailureTest(t *testing.T, testEnv *ttypes.TestEnvironment, httpAc
129129
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
130130
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
131131
defer cancel()
132-
server.Shutdown(ctx)
133-
close(userLogsCh)
134-
close(baseMessageCh)
132+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
135133
})
136134

137135
// Now register and deploy the workflow

system-tests/tests/regression/cre/v2_http_trigger_regression_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ func HTTPTriggerFailsTest(t *testing.T, testEnv *ttypes.TestEnvironment, httpNeg
113113
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
114114
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
115115
defer cancel()
116-
server.Shutdown(ctx)
117-
close(userLogsCh)
118-
close(baseMessageCh)
116+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
119117
})
120118
// drain user logs channel in the background, we are not asserting anything on it
121119
t_helpers.IgnoreUserLogs(t.Context(), userLogsCh)

system-tests/tests/smoke/cre/v2_aptos_capability_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ func executeAptosScenarios(t *testing.T, tenv *configuration.TestEnvironment, sc
171171
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
172172
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
173173
defer cancel()
174-
server.Shutdown(ctx)
175-
close(userLogsCh)
176-
close(baseMessageCh)
174+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
177175
})
178176

179177
scenario.run(t, scenarioEnv, scenarioAptosChain, userLogsCh, baseMessageCh)

system-tests/tests/smoke/cre/v2_consensus_capability_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ func ExecuteConsensusTest(t *testing.T, testEnv *ttypes.TestEnvironment) {
2626
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
2727
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
2828
defer cancel()
29-
server.Shutdown(ctx)
30-
close(userLogsCh)
31-
close(baseMessageCh)
29+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
3230
})
3331

3432
workflowName := t_helpers.UniqueWorkflowName(testEnv, "consensustest")

system-tests/tests/smoke/cre/v2_dontime_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ func ExecuteDonTimeTest(t *testing.T, testEnv *ttypes.TestEnvironment) {
3030
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
3131
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
3232
defer cancel()
33-
server.Shutdown(ctx)
34-
close(userLogsCh)
35-
close(baseMessageCh)
33+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
3634
})
3735

3836
testLogger.Info().Msg("Creating Cron workflow configuration file...")

system-tests/tests/smoke/cre/v2_evm_capability_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ func ExecuteEVMReadTestForCases(t *testing.T, testEnv *ttypes.TestEnvironment, t
8585
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
8686
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
8787
defer cancel()
88-
server.Shutdown(ctx)
89-
close(userLogsCh)
90-
close(baseMessageCh)
88+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
9189
})
9290

9391
for _, bcOutput := range perCaseEnv.CreEnvironment.Blockchains {
@@ -397,9 +395,7 @@ func ExecuteEVMLogTriggerTest(t *testing.T, testEnv *ttypes.TestEnvironment) {
397395
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
398396
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
399397
defer cancel()
400-
server.Shutdown(ctx)
401-
close(userLogsCh)
402-
close(baseMessageCh)
398+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
403399
})
404400

405401
for _, bcOutput := range testEnv.CreEnvironment.Blockchains {

system-tests/tests/smoke/cre/v2_grpc_source_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ func startWorkflowEventSink(t *testing.T) (context.Context, <-chan proto.Message
270270
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
271271
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
272272
defer cancel()
273-
server.Shutdown(ctx)
274-
close(messageChan)
273+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, messageChan)
275274
})
276275

277276
timeout := 5 * time.Minute

system-tests/tests/smoke/cre/v2_http_action_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ func HTTPActionRegressionTest(t *testing.T, testEnv *ttypes.TestEnvironment, url
131131
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
132132
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
133133
defer cancel()
134-
server.Shutdown(ctx)
135-
close(userLogsCh)
136-
close(baseMessageCh)
134+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
137135
})
138136

139137
testLogger.Info().Msg("Waiting for HTTP Action regression workflow to complete...")
@@ -229,9 +227,7 @@ func HTTPActionSuccessTest(t *testing.T, testEnv *ttypes.TestEnvironment, httpAc
229227
// can't use t.Context() here because it will have been cancelled before the cleanup function is called
230228
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
231229
defer cancel()
232-
server.Shutdown(ctx)
233-
close(userLogsCh)
234-
close(baseMessageCh)
230+
t_helpers.ShutdownChipSinkWithDrain(ctx, server, userLogsCh, baseMessageCh)
235231
})
236232

237233
// Wait for workflow execution to complete and verify success

0 commit comments

Comments
 (0)