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:
@@ -36,7 +36,8 @@ func TestRouteCreate(t *testing.T) {
|
||||
// success
|
||||
{&datastore.Mock{}, "/v1/apps/a/routes", `{ "route": { "image": "iron/hello", "path": "/myroute" } }`, http.StatusCreated, nil},
|
||||
} {
|
||||
router := testRouter(test.mock, &mqs.Mock{}, testRunner(t), tasks)
|
||||
rnr, cancel := testRunner(t)
|
||||
router := testRouter(test.mock, &mqs.Mock{}, rnr, tasks)
|
||||
|
||||
body := bytes.NewBuffer([]byte(test.body))
|
||||
_, rec := routerRequest(t, router, "POST", test.path, body)
|
||||
@@ -56,6 +57,7 @@ func TestRouteCreate(t *testing.T) {
|
||||
i, test.expectedError.Error(), resp.Error.Message)
|
||||
}
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +81,8 @@ func TestRouteDelete(t *testing.T) {
|
||||
},
|
||||
}, "/v1/apps/a/routes/myroute", "", http.StatusOK, nil},
|
||||
} {
|
||||
router := testRouter(test.ds, &mqs.Mock{}, testRunner(t), tasks)
|
||||
rnr, cancel := testRunner(t)
|
||||
router := testRouter(test.ds, &mqs.Mock{}, rnr, tasks)
|
||||
_, rec := routerRequest(t, router, "DELETE", test.path, nil)
|
||||
|
||||
if rec.Code != test.expectedCode {
|
||||
@@ -97,6 +100,7 @@ func TestRouteDelete(t *testing.T) {
|
||||
i, test.expectedError.Error())
|
||||
}
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +109,9 @@ func TestRouteList(t *testing.T) {
|
||||
tasks := mockTasksConduit()
|
||||
defer close(tasks)
|
||||
|
||||
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
|
||||
rnr, cancel := testRunner(t)
|
||||
defer cancel()
|
||||
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, rnr, tasks)
|
||||
|
||||
for i, test := range []struct {
|
||||
path string
|
||||
@@ -140,7 +146,10 @@ func TestRouteGet(t *testing.T) {
|
||||
tasks := mockTasksConduit()
|
||||
defer close(tasks)
|
||||
|
||||
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, testRunner(t), tasks)
|
||||
rnr, cancel := testRunner(t)
|
||||
defer cancel()
|
||||
|
||||
router := testRouter(&datastore.Mock{}, &mqs.Mock{}, rnr, tasks)
|
||||
|
||||
for i, test := range []struct {
|
||||
path string
|
||||
@@ -196,7 +205,8 @@ func TestRouteUpdate(t *testing.T) {
|
||||
},
|
||||
}, "/v1/apps/a/routes/myroute/do", `{ "route": { "image": "iron/hello", "path": "/myroute" } }`, http.StatusOK, nil},
|
||||
} {
|
||||
router := testRouter(test.ds, &mqs.Mock{}, testRunner(t), tasks)
|
||||
rnr, cancel := testRunner(t)
|
||||
router := testRouter(test.ds, &mqs.Mock{}, rnr, tasks)
|
||||
|
||||
body := bytes.NewBuffer([]byte(test.body))
|
||||
|
||||
@@ -217,5 +227,6 @@ func TestRouteUpdate(t *testing.T) {
|
||||
i, test.expectedError.Error())
|
||||
}
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user