mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
functions: fix goroutine leak in runner (#394)
* functions: fix goroutine leak in runner * functions: ensure taskQueue is consumed after context cancellation
This commit is contained in:
@@ -189,12 +189,13 @@ func TestTasksrvURL(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testRunner(t *testing.T) *Runner {
|
||||
r, err := New(NewFuncLogger(), NewMetricLogger())
|
||||
func testRunner(t *testing.T) (*Runner, context.CancelFunc) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
r, err := New(ctx, NewFuncLogger(), NewMetricLogger())
|
||||
if err != nil {
|
||||
t.Fatal("Test: failed to create new runner")
|
||||
}
|
||||
return r
|
||||
return r, cancel
|
||||
}
|
||||
|
||||
func TestAsyncRunnersGracefulShutdown(t *testing.T) {
|
||||
@@ -217,7 +218,9 @@ func TestAsyncRunnersGracefulShutdown(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
startAsyncRunners(ctx, ts.URL+"/tasks", tasks, testRunner(t))
|
||||
rnr, cancel := testRunner(t)
|
||||
defer cancel()
|
||||
startAsyncRunners(ctx, ts.URL+"/tasks", tasks, rnr)
|
||||
|
||||
if err := ctx.Err(); err != context.DeadlineExceeded {
|
||||
t.Log(buf.String())
|
||||
|
||||
Reference in New Issue
Block a user