From 5ec087fa3036311a5dafcddf765b0f84fdae9144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sat, 5 Dec 2015 13:27:05 +0100 Subject: [PATCH] Properly close http connection on TestList If not, using `go test -count=n` would make them pile up and ultimately get to the limit of open files: apiserver_test.go:984: 17: unexpected error: Get http://127.0.0.1:44131/apis/test.group/version/simple: dial tcp 127.0.0.1:44131: socket: too many open files Steps to reproduce (no longer fails): godep go test -short -run '^$' -o test . ./test -test.run '^TestList$' -test.count 100 Note that this might not fail if your `ulimit -n` is not low enough. --- pkg/apiserver/apiserver_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index 49b7ca69335..a14de58ba5c 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -984,6 +984,7 @@ func TestList(t *testing.T) { t.Errorf("%d: unexpected error: %v", i, err) continue } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { t.Errorf("%d: unexpected status: %d from url %s, Expected: %d, %#v", i, resp.StatusCode, testCase.url, http.StatusOK, resp) body, err := ioutil.ReadAll(resp.Body)