From bf1a3f99c0be8deee743b9ef65e2b2296d942236 Mon Sep 17 00:00:00 2001 From: zhouhaibing089 Date: Thu, 21 Apr 2016 04:50:55 -0700 Subject: [PATCH] Uncomment the code that cause by #19254 --- .../scheduler/integration/integration_test.go | 3 +- pkg/apiserver/apiserver_test.go | 153 ++++++------------ pkg/apiserver/handlers_test.go | 9 +- pkg/apiserver/proxy_test.go | 24 +-- pkg/apiserver/watch_test.go | 15 +- pkg/client/cache/listwatch_test.go | 6 +- pkg/client/chaosclient/chaosclient_test.go | 6 +- pkg/client/restclient/client_test.go | 9 +- pkg/client/restclient/request_test.go | 33 ++-- pkg/client/typed/discovery/client_test.go | 18 +-- pkg/client/unversioned/containerinfo_test.go | 6 +- pkg/client/unversioned/helper_test.go | 3 +- .../portforward/portforward_test.go | 21 +-- .../remotecommand/remotecommand_test.go | 9 +- .../testclient/simple/simple_testclient.go | 3 +- .../providers/mesos/client_test.go | 12 +- pkg/controller/controller_utils_test.go | 3 +- .../endpoint/endpoints_controller_test.go | 36 ++--- .../replication_controller_test.go | 12 +- pkg/credentialprovider/gcp/jwt_test.go | 3 +- pkg/credentialprovider/gcp/metadata_test.go | 18 +-- pkg/kubectl/proxy_server_test.go | 12 +- pkg/kubectl/resource/builder_test.go | 9 +- pkg/kubelet/client/kubelet_client_test.go | 3 +- pkg/kubelet/config/http_test.go | 9 +- pkg/master/master_test.go | 21 +-- pkg/probe/tcp/tcp_test.go | 3 +- pkg/registry/generic/rest/proxy_test.go | 18 +-- pkg/registry/generic/rest/streamer_test.go | 3 +- pkg/storage/etcd/testing/utils.go | 3 +- pkg/storage/etcd/util/etcd_util_test.go | 6 +- pkg/util/configz/configz_test.go | 3 +- pkg/util/httpstream/spdy/roundtripper_test.go | 6 +- pkg/util/httpstream/spdy/upgrade_test.go | 3 +- pkg/util/proxy/transport_test.go | 3 +- pkg/util/testing/fake_handler_test.go | 18 +-- pkg/util/wsstream/conn_test.go | 12 +- .../authenticator/token/oidc/oidc_test.go | 12 +- .../defaults/compatibility_test.go | 3 +- plugin/pkg/scheduler/factory/factory_test.go | 18 +-- test/component/scheduler/perf/util.go | 3 +- test/integration/auth_test.go | 27 ++-- test/integration/client_test.go | 9 +- test/integration/configmap_test.go | 3 +- test/integration/extender_test.go | 9 +- test/integration/framework/master_utils.go | 3 +- test/integration/master_test.go | 9 +- test/integration/metrics_test.go | 6 +- test/integration/persistent_volumes_test.go | 3 +- test/integration/pods.go | 6 +- test/integration/scheduler_test.go | 3 +- test/integration/secret_test.go | 3 +- test/integration/service_account_test.go | 3 +- 53 files changed, 218 insertions(+), 436 deletions(-) diff --git a/contrib/mesos/pkg/scheduler/integration/integration_test.go b/contrib/mesos/pkg/scheduler/integration/integration_test.go index e45ef4e3f8..9fc79d7143 100644 --- a/contrib/mesos/pkg/scheduler/integration/integration_test.go +++ b/contrib/mesos/pkg/scheduler/integration/integration_test.go @@ -623,8 +623,7 @@ func (lt lifecycleTest) Start() <-chan LaunchedTask { } func (lt lifecycleTest) Close() { - // TODO: Uncomment when fix #19254 - // lt.apiServer.server.Close() + lt.apiServer.server.Close() } func (lt lifecycleTest) End() <-chan struct{} { diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go index d756c4dbc7..96a9a33945 100644 --- a/pkg/apiserver/apiserver_test.go +++ b/pkg/apiserver/apiserver_test.go @@ -778,8 +778,7 @@ func TestNotFound(t *testing.T) { "simpleroots": &SimpleRESTStorage{}, }) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} for k, v := range cases { request, err := http.NewRequest(v.Method, server.URL+v.Path, nil) @@ -841,8 +840,7 @@ func TestUnimplementedRESTStorage(t *testing.T) { "foo": UnimplementedRESTStorage{}, }) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} for k, v := range cases { request, err := http.NewRequest(v.Method, server.URL+v.Path, bytes.NewReader([]byte(`{"kind":"Simple","apiVersion":"version"}`))) @@ -869,8 +867,7 @@ func TestUnimplementedRESTStorage(t *testing.T) { func TestVersion(t *testing.T) { handler := handle(map[string]rest.Storage{}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("GET", server.URL+"/version", nil) @@ -1066,8 +1063,7 @@ func TestList(t *testing.T) { } var handler = handleInternal(storage, admissionControl, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + testCase.url) if err != nil { @@ -1111,8 +1107,7 @@ func TestErrorList(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/simple") if err != nil { @@ -1137,8 +1132,7 @@ func TestNonEmptyList(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/simple") if err != nil { @@ -1189,8 +1183,7 @@ func TestSelfLinkSkipsEmptyName(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/simple") if err != nil { @@ -1272,8 +1265,7 @@ func TestExport(t *testing.T) { storage["simple"] = &simpleStorage handler := handleLinker(storage, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/id?export=true") if err != nil { @@ -1318,8 +1310,7 @@ func TestGet(t *testing.T) { storage["simple"] = &simpleStorage handler := handleLinker(storage, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/id") if err != nil { @@ -1351,8 +1342,7 @@ func TestGetBinary(t *testing.T) { } stream := simpleStorage.stream server := httptest.NewServer(handle(map[string]rest.Storage{"simple": &simpleStorage})) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() req, err := http.NewRequest("GET", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/binary", nil) if err != nil { @@ -1429,8 +1419,7 @@ func TestGetWithOptions(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/id?param1=test1¶m2=test2") if err != nil { @@ -1472,8 +1461,7 @@ func TestGetWithOptionsAndPath(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/id/a/different/path?param1=test1¶m2=test2&atAPath=not") if err != nil { @@ -1517,8 +1505,7 @@ func TestGetAlternateSelfLink(t *testing.T) { storage["simple"] = &simpleStorage handler := handleLinker(storage, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/test/simple/id") if err != nil { @@ -1556,8 +1543,7 @@ func TestGetNamespaceSelfLink(t *testing.T) { storage["simple"] = &simpleStorage handler := handleInternal(storage, admissionControl, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + newGroupVersion.Group + "/" + newGroupVersion.Version + "/namespaces/foo/simple/id") if err != nil { @@ -1586,8 +1572,7 @@ func TestGetMissing(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/simple/id") if err != nil { @@ -1613,8 +1598,7 @@ func TestConnect(t *testing.T) { } handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/" + itemID + "/connect") @@ -1652,8 +1636,7 @@ func TestConnectResponderObject(t *testing.T) { } handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/" + itemID + "/connect") @@ -1694,8 +1677,7 @@ func TestConnectResponderError(t *testing.T) { } handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/" + itemID + "/connect") @@ -1764,8 +1746,7 @@ func TestConnectWithOptions(t *testing.T) { } handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/" + itemID + "/connect?param1=value1¶m2=value2") @@ -1815,8 +1796,7 @@ func TestConnectWithOptionsAndPath(t *testing.T) { } handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/" + itemID + "/connect/" + testPath + "?param1=value1¶m2=value2") @@ -1856,8 +1836,7 @@ func TestDelete(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil) @@ -1880,8 +1859,7 @@ func TestDeleteWithOptions(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() grace := int64(300) item := &api.DeleteOptions{ @@ -1922,8 +1900,7 @@ func TestLegacyDelete(t *testing.T) { var _ rest.Deleter = storage["simple"].(LegacyRESTStorage) handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil) @@ -1949,8 +1926,7 @@ func TestLegacyDeleteIgnoresOptions(t *testing.T) { storage["simple"] = LegacyRESTStorage{&simpleStorage} handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := api.NewDeleteOptions(300) body, err := runtime.Encode(codec, item) @@ -1982,8 +1958,7 @@ func TestDeleteInvokesAdmissionControl(t *testing.T) { storage["simple"] = &simpleStorage handler := handleDeny(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil) @@ -2005,8 +1980,7 @@ func TestDeleteMissing(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("DELETE", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, nil) @@ -2040,8 +2014,7 @@ func TestPatch(t *testing.T) { } handler := handleLinker(storage, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"labels":{"foo":"bar"}}`))) @@ -2073,8 +2046,7 @@ func TestPatchRequiresMatchingName(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("PATCH", server.URL+"/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/simple/"+ID, bytes.NewReader([]byte(`{"metadata":{"name":"idbar"}}`))) @@ -2101,8 +2073,7 @@ func TestUpdate(t *testing.T) { } handler := handleLinker(storage, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ ObjectMeta: api.ObjectMeta{ @@ -2139,8 +2110,7 @@ func TestUpdateInvokesAdmissionControl(t *testing.T) { storage["simple"] = &simpleStorage handler := handleDeny(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ ObjectMeta: api.ObjectMeta{ @@ -2173,8 +2143,7 @@ func TestUpdateRequiresMatchingName(t *testing.T) { storage["simple"] = &simpleStorage handler := handleDeny(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ Other: "bar", @@ -2203,8 +2172,7 @@ func TestUpdateAllowsMissingNamespace(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ ObjectMeta: api.ObjectMeta{ @@ -2241,8 +2209,7 @@ func TestUpdateAllowsMismatchedNamespaceOnError(t *testing.T) { } handler := handleLinker(storage, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ ObjectMeta: api.ObjectMeta{ @@ -2279,8 +2246,7 @@ func TestUpdatePreventsMismatchedNamespace(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ ObjectMeta: api.ObjectMeta{ @@ -2315,8 +2281,7 @@ func TestUpdateMissing(t *testing.T) { storage["simple"] = &simpleStorage handler := handle(storage) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() item := &apiservertesting.Simple{ ObjectMeta: api.ObjectMeta{ @@ -2350,8 +2315,7 @@ func TestCreateNotFound(t *testing.T) { }, }) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{Other: "foo"} @@ -2377,8 +2341,7 @@ func TestCreateNotFound(t *testing.T) { func TestCreateChecksDecode(t *testing.T) { handler := handle(map[string]rest.Storage{"simple": &SimpleRESTStorage{}}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &api.Pod{} @@ -2574,8 +2537,7 @@ func TestCreateWithName(t *testing.T) { "simple/sub": storage, }) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{Other: "foo"} @@ -2602,8 +2564,7 @@ func TestCreateWithName(t *testing.T) { func TestUpdateChecksDecode(t *testing.T) { handler := handle(map[string]rest.Storage{"simple": &SimpleRESTStorage{}}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &api.Pod{} @@ -2677,8 +2638,7 @@ func TestCreate(t *testing.T) { } handler := handleLinker(map[string]rest.Storage{"foo": &storage}, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{ @@ -2805,8 +2765,7 @@ func TestCreateInNamespace(t *testing.T) { } handler := handleLinker(map[string]rest.Storage{"foo": &storage}, selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{ @@ -2865,8 +2824,7 @@ func TestCreateInvokesAdmissionControl(t *testing.T) { } handler := handleInternal(map[string]rest.Storage{"foo": &storage}, deny.NewAlwaysDeny(), selfLinker) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{ @@ -2928,8 +2886,7 @@ func TestDelayReturnsError(t *testing.T) { } handler := handle(map[string]rest.Storage{"foo": &storage}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() status := expectApiStatus(t, "DELETE", fmt.Sprintf("%s/"+prefix+"/"+testGroupVersion.Group+"/"+testGroupVersion.Version+"/namespaces/default/foo/bar", server.URL), nil, http.StatusConflict) if status.Status != unversioned.StatusFailure || status.Message == "" || status.Details == nil || status.Reason != unversioned.StatusReasonAlreadyExists { @@ -2949,8 +2906,7 @@ func TestWriteJSONDecodeError(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { writeNegotiated(api.Codecs, newGroupVersion, w, req, http.StatusOK, &UnregisteredAPIObject{"Undecodable"}) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // We send a 200 status code before we encode the object, so we expect OK, but there will // still be an error object. This seems ok, the alternative is to validate the object before // encoding, but this really should never happen, so it's wasted compute for every API request. @@ -2975,8 +2931,7 @@ func TestWriteRAWJSONMarshalError(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { writeRawJSON(http.StatusOK, &marshalError{errors.New("Undecodable")}, w) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} resp, err := client.Get(server.URL) if err != nil { @@ -3002,8 +2957,7 @@ func TestCreateTimeout(t *testing.T) { "foo": &storage, }) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() simple := &apiservertesting.Simple{Other: "foo"} data, err := runtime.Encode(testCodec, simple) @@ -3040,8 +2994,7 @@ func TestCORSAllowedOrigins(t *testing.T) { allowedOriginRegexps, nil, nil, "true", ) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} request, err := http.NewRequest("GET", server.URL+"/version", nil) @@ -3094,8 +3047,7 @@ func TestCORSAllowedOrigins(t *testing.T) { func TestCreateChecksAPIVersion(t *testing.T) { handler := handle(map[string]rest.Storage{"simple": &SimpleRESTStorage{}}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{} @@ -3126,8 +3078,7 @@ func TestCreateChecksAPIVersion(t *testing.T) { func TestCreateDefaultsAPIVersion(t *testing.T) { handler := handle(map[string]rest.Storage{"simple": &SimpleRESTStorage{}}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{} @@ -3162,8 +3113,7 @@ func TestCreateDefaultsAPIVersion(t *testing.T) { func TestUpdateChecksAPIVersion(t *testing.T) { handler := handle(map[string]rest.Storage{"simple": &SimpleRESTStorage{}}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{} simple := &apiservertesting.Simple{ObjectMeta: api.ObjectMeta{Name: "bar"}} @@ -3270,8 +3220,7 @@ func TestXGSubresource(t *testing.T) { handler := defaultAPIServer{mux, container} server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() resp, err := http.Get(server.URL + "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/namespaces/default/simple/" + itemID + "/subsimple") if err != nil { diff --git a/pkg/apiserver/handlers_test.go b/pkg/apiserver/handlers_test.go index 7eddc2e188..1cfc032520 100644 --- a/pkg/apiserver/handlers_test.go +++ b/pkg/apiserver/handlers_test.go @@ -112,8 +112,7 @@ func TestMaxInFlight(t *testing.T) { }), ), ) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // These should hang, but not affect accounting. use a query param match for i := 0; i < AllowedInflightRequestsNo; i++ { @@ -175,8 +174,7 @@ func TestReadOnly(t *testing.T) { } }, ))) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() for _, verb := range []string{"GET", "POST", "PUT", "DELETE", "CREATE"} { req, err := http.NewRequest(verb, server.URL, nil) if err != nil { @@ -202,8 +200,7 @@ func TestTimeout(t *testing.T) { func(*http.Request) (<-chan time.Time, string) { return timeout, timeoutResp })) - // TODO: Uncomment when fix #19254 - // defer ts.Close() + defer ts.Close() // No timeouts sendResponse <- struct{}{} diff --git a/pkg/apiserver/proxy_test.go b/pkg/apiserver/proxy_test.go index 657bd0192c..b8a0a09153 100644 --- a/pkg/apiserver/proxy_test.go +++ b/pkg/apiserver/proxy_test.go @@ -194,8 +194,7 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { // Write successful response w.Write([]byte(successfulResponse)) })) - // TODO: Uncomment when fix #19254 - // defer downstreamServer.Close() + defer downstreamServer.Close() // Start the proxy server serverURL, _ := url.Parse(downstreamServer.URL) @@ -206,8 +205,7 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { } namespaceHandler := handleNamespaced(map[string]rest.Storage{"foo": simpleStorage}) server := httptest.NewServer(namespaceHandler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Dial the proxy server conn, err := net.Dial(server.Listener.Addr().Network(), server.Listener.Addr().String()) @@ -302,8 +300,7 @@ func TestProxy(t *testing.T) { } fmt.Fprint(out, item.respBody) })) - // TODO: Uncomment when fix #19254 - // defer downstreamServer.Close() + defer downstreamServer.Close() serverURL, _ := url.Parse(downstreamServer.URL) simpleStorage := &SimpleRESTStorage{ @@ -314,8 +311,7 @@ func TestProxy(t *testing.T) { namespaceHandler := handleNamespaced(map[string]rest.Storage{"foo": simpleStorage}) namespaceServer := httptest.NewServer(namespaceHandler) - // TODO: Uncomment when fix #19254 - // defer namespaceServer.Close() + defer namespaceServer.Close() // test each supported URL pattern for finding the redirection resource in the proxy in a particular namespace serverPatterns := []struct { @@ -424,8 +420,7 @@ func TestProxyUpgrade(t *testing.T) { ws.Read(body) ws.Write([]byte("hello " + string(body))) })) - // TODO: Uncomment when fix #19254 - // defer backendServer.Close() + defer backendServer.Close() serverURL, _ := url.Parse(backendServer.URL) simpleStorage := &SimpleRESTStorage{ @@ -438,8 +433,7 @@ func TestProxyUpgrade(t *testing.T) { namespaceHandler := handleNamespaced(map[string]rest.Storage{"foo": simpleStorage}) server := httptest.NewServer(namespaceHandler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() ws, err := websocket.Dial("ws://"+server.Listener.Addr().String()+"/"+prefix+"/"+newGroupVersion.Group+"/"+newGroupVersion.Version+"/proxy/namespaces/myns/foo/123", "", "http://127.0.0.1/") if err != nil { @@ -492,8 +486,7 @@ func TestRedirectOnMissingTrailingSlash(t *testing.T) { t.Errorf("Unexpected query on url: %s, expected: %s", req.URL.RawQuery, item.query) } })) - // TODO: Uncomment when fix #19254 - // defer downstreamServer.Close() + defer downstreamServer.Close() serverURL, _ := url.Parse(downstreamServer.URL) simpleStorage := &SimpleRESTStorage{ @@ -504,8 +497,7 @@ func TestRedirectOnMissingTrailingSlash(t *testing.T) { handler := handleNamespaced(map[string]rest.Storage{"foo": simpleStorage}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() proxyTestPattern := "/" + prefix + "/" + newGroupVersion.Group + "/" + newGroupVersion.Version + "/proxy/namespaces/ns/foo/id" + item.path req, err := http.NewRequest( diff --git a/pkg/apiserver/watch_test.go b/pkg/apiserver/watch_test.go index 8f2d0c42b7..153d716fc4 100644 --- a/pkg/apiserver/watch_test.go +++ b/pkg/apiserver/watch_test.go @@ -88,8 +88,7 @@ func TestWatchWebsocket(t *testing.T) { _ = rest.Watcher(simpleStorage) // Give compile error if this doesn't work. handler := handle(map[string]rest.Storage{"simples": simpleStorage}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() dest, _ := url.Parse(server.URL) dest.Scheme = "ws" // Required by websocket, though the server never sees it. @@ -142,8 +141,7 @@ func TestWatchRead(t *testing.T) { _ = rest.Watcher(simpleStorage) // Give compile error if this doesn't work. handler := handle(map[string]rest.Storage{"simples": simpleStorage}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() dest, _ := url.Parse(server.URL) dest.Path = "/" + prefix + "/" + testGroupVersion.Group + "/" + testGroupVersion.Version + "/simples" @@ -328,8 +326,7 @@ func TestWatchParamParsing(t *testing.T) { "simpleroots": simpleStorage, }) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() dest, _ := url.Parse(server.URL) @@ -436,8 +433,7 @@ func TestWatchProtocolSelection(t *testing.T) { simpleStorage := &SimpleRESTStorage{} handler := handle(map[string]rest.Storage{"simples": simpleStorage}) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer server.CloseClientConnections() client := http.Client{} @@ -520,8 +516,7 @@ func TestWatchHTTPTimeout(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { watchServer.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() // Setup a client dest, _ := url.Parse(s.URL) diff --git a/pkg/client/cache/listwatch_test.go b/pkg/client/cache/listwatch_test.go index 0008bd0ff5..ddd58cf747 100644 --- a/pkg/client/cache/listwatch_test.go +++ b/pkg/client/cache/listwatch_test.go @@ -96,8 +96,7 @@ func TestListWatchesCanList(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) lw := NewListWatchFromClient(client, item.resource, item.namespace, item.fieldSelector) // This test merely tests that the correct request is made. @@ -163,8 +162,7 @@ func TestListWatchesCanWatch(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) lw := NewListWatchFromClient(client, item.resource, item.namespace, item.fieldSelector) // This test merely tests that the correct request is made. diff --git a/pkg/client/chaosclient/chaosclient_test.go b/pkg/client/chaosclient/chaosclient_test.go index fd2cf876b7..0c76736cfc 100644 --- a/pkg/client/chaosclient/chaosclient_test.go +++ b/pkg/client/chaosclient/chaosclient_test.go @@ -42,8 +42,7 @@ func TestChaos(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := http.Client{ Transport: NewChaosRoundTripper(http.DefaultTransport, TestLogChaos{t}, ErrSimulatedConnectionResetByPeer), } @@ -60,8 +59,7 @@ func TestPartialChaos(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusOK) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() seed := NewSeed(1) client := http.Client{ Transport: NewChaosRoundTripper( diff --git a/pkg/client/restclient/client_test.go b/pkg/client/restclient/client_test.go index 182b936b76..6bd9596a7e 100644 --- a/pkg/client/restclient/client_test.go +++ b/pkg/client/restclient/client_test.go @@ -42,8 +42,7 @@ func TestDoRequestSuccess(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c, err := RESTClientFor(&Config{ Host: testServer.URL, ContentConfig: ContentConfig{ @@ -88,8 +87,7 @@ func TestDoRequestFailed(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c, err := RESTClientFor(&Config{ Host: testServer.URL, ContentConfig: ContentConfig{ @@ -127,8 +125,7 @@ func TestDoRequestCreated(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c, err := RESTClientFor(&Config{ Host: testServer.URL, ContentConfig: ContentConfig{ diff --git a/pkg/client/restclient/request_test.go b/pkg/client/restclient/request_test.go index 06141692e7..31f2f9fcf5 100644 --- a/pkg/client/restclient/request_test.go +++ b/pkg/client/restclient/request_test.go @@ -723,8 +723,7 @@ func TestDoRequestNewWay(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) obj, err := c.Verb("POST"). Prefix("foo", "bar"). @@ -760,8 +759,7 @@ func TestBackoffLifecycle(t *testing.T) { return } })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) // Test backoff recovery and increase. This correlates to the constants @@ -806,8 +804,7 @@ func TestCheckRetryClosesBody(t *testing.T) { w.Header().Set("Retry-After", "0") w.WriteHeader(apierrors.StatusTooManyRequests) })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) _, err := c.Verb("POST"). @@ -839,8 +836,7 @@ func TestCheckRetryHandles429And5xx(t *testing.T) { w.WriteHeader([]int{apierrors.StatusTooManyRequests, 500, 501, 504}[count]) count++ })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) _, err := c.Verb("POST"). @@ -869,8 +865,7 @@ func BenchmarkCheckRetryClosesBody(b *testing.B) { w.Header().Set("Retry-After", "0") w.WriteHeader(apierrors.StatusTooManyRequests) })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(b, testServer) r := c.Verb("POST"). @@ -901,8 +896,7 @@ func TestDoRequestNewWayReader(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) obj, err := c.Verb("POST"). Resource("bar"). @@ -942,8 +936,7 @@ func TestDoRequestNewWayObj(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) obj, err := c.Verb("POST"). Suffix("baz"). @@ -998,8 +991,7 @@ func TestDoRequestNewWayFile(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) wasCreated := true obj, err := c.Verb("POST"). @@ -1044,8 +1036,7 @@ func TestWasCreated(t *testing.T) { T: t, } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := testRESTClient(t, testServer) wasCreated := false obj, err := c.Verb("PUT"). @@ -1250,8 +1241,7 @@ func TestWatch(t *testing.T) { flusher.Flush() } })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() s := testRESTClient(t, testServer) watching, err := s.Get().Prefix("path/to/watch/thing").Watch() @@ -1291,8 +1281,7 @@ func TestStream(t *testing.T) { w.Write([]byte(expectedBody)) flusher.Flush() })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() s := testRESTClient(t, testServer) readCloser, err := s.Get().Prefix("path/to/stream/thing").Stream() diff --git a/pkg/client/typed/discovery/client_test.go b/pkg/client/typed/discovery/client_test.go index 62d0869207..674b92f0f6 100644 --- a/pkg/client/typed/discovery/client_test.go +++ b/pkg/client/typed/discovery/client_test.go @@ -47,8 +47,7 @@ func TestGetServerVersion(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write(output) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) got, err := client.ServerVersion() @@ -83,8 +82,7 @@ func TestGetServerGroupsWithV1Server(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write(output) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) // ServerGroups should not return an error even if server returns error at /api and /apis apiGroupList, err := client.ServerGroups() @@ -120,8 +118,7 @@ func TestGetServerResourcesWithV1Server(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write(output) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) // ServerResources should not return an error even if server returns error at /api/v1. resourceMap, err := client.ServerResources() @@ -213,8 +210,7 @@ func TestGetServerResources(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write(output) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) for _, test := range tests { got, err := client.ServerResourcesForGroupVersion(test.request) @@ -275,8 +271,7 @@ func TestGetSwaggerSchema(t *testing.T) { if err != nil { t.Errorf("unexpected encoding error: %v", err) } - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) got, err := client.SwaggerSchema(v1.SchemeGroupVersion) @@ -295,8 +290,7 @@ func TestGetSwaggerSchemaFail(t *testing.T) { if err != nil { t.Errorf("unexpected encoding error: %v", err) } - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := NewDiscoveryClientForConfigOrDie(&restclient.Config{Host: server.URL}) got, err := client.SwaggerSchema(unversioned.GroupVersion{Group: "api.group", Version: "v4"}) diff --git a/pkg/client/unversioned/containerinfo_test.go b/pkg/client/unversioned/containerinfo_test.go index 5e7e9768dd..797ad51398 100644 --- a/pkg/client/unversioned/containerinfo_test.go +++ b/pkg/client/unversioned/containerinfo_test.go @@ -70,8 +70,7 @@ func testHTTPContainerInfoGetter( t.Fatal(err) } })) - // TODO: Uncomment when fix #19254 - // defer ts.Close() + defer ts.Close() hostURL, err := url.Parse(ts.URL) if err != nil { t.Fatal(err) @@ -172,8 +171,7 @@ func TestHTTPGetMachineInfo(t *testing.T) { t.Fatal(err) } })) - // TODO: Uncomment when fix #19254 - // defer ts.Close() + defer ts.Close() hostURL, err := url.Parse(ts.URL) if err != nil { t.Fatal(err) diff --git a/pkg/client/unversioned/helper_test.go b/pkg/client/unversioned/helper_test.go index b4d9a76444..1d506ff976 100644 --- a/pkg/client/unversioned/helper_test.go +++ b/pkg/client/unversioned/helper_test.go @@ -124,8 +124,7 @@ func TestHelperGetServerAPIVersions(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write(output) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() got, err := restclient.ServerAPIVersions(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: &unversioned.GroupVersion{Group: "invalid version", Version: "one"}, Codec: testapi.Default.Codec()}}) if err != nil { t.Fatalf("unexpected encoding error: %v", err) diff --git a/pkg/client/unversioned/portforward/portforward_test.go b/pkg/client/unversioned/portforward/portforward_test.go index 6a2a261443..52fae85014 100644 --- a/pkg/client/unversioned/portforward/portforward_test.go +++ b/pkg/client/unversioned/portforward/portforward_test.go @@ -320,8 +320,7 @@ func TestForwardPorts(t *testing.T) { clientConn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", port)) if err != nil { t.Errorf("%s: error dialing %d: %s", testName, port, err) - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } defer clientConn.Close() @@ -329,28 +328,24 @@ func TestForwardPorts(t *testing.T) { n, err := clientConn.Write([]byte(data)) if err != nil && err != io.EOF { t.Errorf("%s: Error sending data '%s': %s", testName, data, err) - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } if n == 0 { t.Errorf("%s: unexpected write of 0 bytes", testName) - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } b := make([]byte, 4) n, err = clientConn.Read(b) if err != nil && err != io.EOF { t.Errorf("%s: Error reading data: %s", testName, err) - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } if !bytes.Equal([]byte(test.serverSends[port]), b) { t.Errorf("%s: expected to read '%s', got '%s'", testName, test.serverSends[port], b) - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } } @@ -362,16 +357,14 @@ func TestForwardPorts(t *testing.T) { if err != nil { t.Errorf("%s: unexpected error: %s", testName, err) } - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() } } func TestForwardPortsReturnsErrorWhenAllBindsFailed(t *testing.T) { server := httptest.NewServer(fakePortForwardServer(t, "allBindsFailed", nil, nil)) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() url, _ := url.Parse(server.URL) exec, err := remotecommand.NewExecutor(&restclient.Config{}, "POST", url) diff --git a/pkg/client/unversioned/remotecommand/remotecommand_test.go b/pkg/client/unversioned/remotecommand/remotecommand_test.go index 034d423917..84b16219d9 100644 --- a/pkg/client/unversioned/remotecommand/remotecommand_test.go +++ b/pkg/client/unversioned/remotecommand/remotecommand_test.go @@ -257,15 +257,13 @@ func TestStream(t *testing.T) { } } - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } if hasErr { t.Errorf("%s: unexpected error: %v", name, err) - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() continue } @@ -281,8 +279,7 @@ func TestStream(t *testing.T) { } } - // TODO: Uncomment when fix #19254 - // server.Close() + server.Close() } } } diff --git a/pkg/client/unversioned/testclient/simple/simple_testclient.go b/pkg/client/unversioned/testclient/simple/simple_testclient.go index 8697da29ea..b35a34427c 100644 --- a/pkg/client/unversioned/testclient/simple/simple_testclient.go +++ b/pkg/client/unversioned/testclient/simple/simple_testclient.go @@ -110,8 +110,7 @@ func (c *Client) Setup(t *testing.T) *Client { func (c *Client) Close() { if c.server != nil { - // TODO: Uncomment when fix #19254 - // c.server.Close() + c.server.Close() } } diff --git a/pkg/cloudprovider/providers/mesos/client_test.go b/pkg/cloudprovider/providers/mesos/client_test.go index b92fbaf9f8..849a039ca0 100644 --- a/pkg/cloudprovider/providers/mesos/client_test.go +++ b/pkg/cloudprovider/providers/mesos/client_test.go @@ -214,10 +214,8 @@ func Test_parseMesosState(t *testing.T) { func Test_listSlaves(t *testing.T) { defer log.Flush() md := FakeMasterDetector{} - // TODO: Uncomment next two lines and remove third line when fix #19254 - // defer httpServer.Close() - // httpServer, httpClient, httpTransport := makeHttpMocks() - _, httpClient, httpTransport := makeHttpMocks() + httpServer, httpClient, httpTransport := makeHttpMocks() + defer httpServer.Close() cacheTTL := 500 * time.Millisecond mesosClient, err := createMesosClient(md, httpClient, httpTransport, cacheTTL) @@ -255,10 +253,8 @@ func Test_listSlaves(t *testing.T) { func Test_clusterName(t *testing.T) { defer log.Flush() md := FakeMasterDetector{} - // TODO: Uncomment next two lines and remove third line when fix #19254 - // defer httpServer.Close() - // httpServer, httpClient, httpTransport := makeHttpMocks() - _, httpClient, httpTransport := makeHttpMocks() + httpServer, httpClient, httpTransport := makeHttpMocks() + defer httpServer.Close() cacheTTL := 500 * time.Millisecond mesosClient, err := createMesosClient(md, httpClient, httpTransport, cacheTTL) diff --git a/pkg/controller/controller_utils_test.go b/pkg/controller/controller_utils_test.go index bf5c8782d4..3a383caf70 100644 --- a/pkg/controller/controller_utils_test.go +++ b/pkg/controller/controller_utils_test.go @@ -242,8 +242,7 @@ func TestCreatePods(t *testing.T) { ResponseBody: string(body), } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() clientset := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) podControl := RealPodControl{ diff --git a/pkg/controller/endpoint/endpoints_controller_test.go b/pkg/controller/endpoint/endpoints_controller_test.go index 06998739b3..7efac8e2b2 100644 --- a/pkg/controller/endpoint/endpoints_controller_test.go +++ b/pkg/controller/endpoint/endpoints_controller_test.go @@ -105,8 +105,7 @@ func TestSyncEndpointsItemsPreserveNoSelector(t *testing.T) { Ports: []api.EndpointPort{{Port: 1000}}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -139,8 +138,7 @@ func TestCheckLeftoverEndpoints(t *testing.T) { }}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -169,8 +167,7 @@ func TestSyncEndpointsProtocolTCP(t *testing.T) { Ports: []api.EndpointPort{{Port: 1000, Protocol: "TCP"}}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -213,8 +210,7 @@ func TestSyncEndpointsProtocolUDP(t *testing.T) { Ports: []api.EndpointPort{{Port: 1000, Protocol: "UDP"}}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -253,8 +249,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAll(t *testing.T) { }, Subsets: []api.EndpointSubset{}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -292,8 +287,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllNotReady(t *testing.T) { }, Subsets: []api.EndpointSubset{}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -331,8 +325,7 @@ func TestSyncEndpointsItemsEmptySelectorSelectsAllMixed(t *testing.T) { }, Subsets: []api.EndpointSubset{}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -374,8 +367,7 @@ func TestSyncEndpointsItemsPreexisting(t *testing.T) { Ports: []api.EndpointPort{{Port: 1000}}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -416,8 +408,7 @@ func TestSyncEndpointsItemsPreexistingIdentical(t *testing.T) { Ports: []api.EndpointPort{{Port: 8080, Protocol: "TCP"}}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -437,8 +428,7 @@ func TestSyncEndpointsItems(t *testing.T) { ns := "other" testServer, endpointsHandler := makeTestServer(t, ns, serverResponse{http.StatusOK, &api.Endpoints{}}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -481,8 +471,7 @@ func TestSyncEndpointsItemsWithLabels(t *testing.T) { ns := "other" testServer, endpointsHandler := makeTestServer(t, ns, serverResponse{http.StatusOK, &api.Endpoints{}}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady @@ -543,8 +532,7 @@ func TestSyncEndpointsItemsPreexistingLabelsChange(t *testing.T) { Ports: []api.EndpointPort{{Port: 1000}}, }}, }}) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() client := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) endpoints := NewEndpointControllerFromClient(client, controller.NoResyncPeriodFunc) endpoints.podStoreSynced = alwaysReady diff --git a/pkg/controller/replication/replication_controller_test.go b/pkg/controller/replication/replication_controller_test.go index d9641db6cb..83cf06d2e6 100644 --- a/pkg/controller/replication/replication_controller_test.go +++ b/pkg/controller/replication/replication_controller_test.go @@ -222,8 +222,7 @@ func TestStatusUpdatesWithoutReplicasChange(t *testing.T) { ResponseBody: "", } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) manager := NewReplicationManagerFromClient(c, controller.NoResyncPeriodFunc, BurstReplicas, 0) manager.podStoreSynced = alwaysReady @@ -264,8 +263,7 @@ func TestControllerUpdateReplicas(t *testing.T) { ResponseBody: "", } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) manager := NewReplicationManagerFromClient(c, controller.NoResyncPeriodFunc, BurstReplicas, 0) manager.podStoreSynced = alwaysReady @@ -309,8 +307,7 @@ func TestSyncReplicationControllerDormancy(t *testing.T) { ResponseBody: "{}", } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) fakePodControl := controller.FakePodControl{} manager := NewReplicationManagerFromClient(c, controller.NoResyncPeriodFunc, BurstReplicas, 0) @@ -564,8 +561,7 @@ func TestControllerUpdateRequeue(t *testing.T) { ResponseBody: "", } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() c := clientset.NewForConfigOrDie(&restclient.Config{Host: testServer.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) manager := NewReplicationManagerFromClient(c, controller.NoResyncPeriodFunc, BurstReplicas, 0) diff --git a/pkg/credentialprovider/gcp/jwt_test.go b/pkg/credentialprovider/gcp/jwt_test.go index 8aa2ad7336..4066d02af9 100644 --- a/pkg/credentialprovider/gcp/jwt_test.go +++ b/pkg/credentialprovider/gcp/jwt_test.go @@ -77,8 +77,7 @@ func TestJwtProvider(t *testing.T) { "expires_in": 3600 }`, token))) })) - // TODO: Uncomment when fix #19254 - // defer ts.Close() + defer ts.Close() file, err := ioutil.TempFile(os.TempDir(), "temp") if err != nil { diff --git a/pkg/credentialprovider/gcp/metadata_test.go b/pkg/credentialprovider/gcp/metadata_test.go index c2e275f1f5..b65b13a015 100644 --- a/pkg/credentialprovider/gcp/metadata_test.go +++ b/pkg/credentialprovider/gcp/metadata_test.go @@ -57,8 +57,7 @@ func TestDockerKeyringFromGoogleDockerConfigMetadata(t *testing.T) { w.WriteHeader(http.StatusNotFound) } })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Make a transport that reroutes all traffic to the example server transport := utilnet.SetTransportDefaults(&http.Transport{ @@ -130,8 +129,7 @@ func TestDockerKeyringFromGoogleDockerConfigMetadataUrl(t *testing.T) { w.WriteHeader(http.StatusNotFound) } })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Make a transport that reroutes all traffic to the example server transport := utilnet.SetTransportDefaults(&http.Transport{ @@ -204,8 +202,7 @@ func TestContainerRegistryBasics(t *testing.T) { w.WriteHeader(http.StatusNotFound) } })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Make a transport that reroutes all traffic to the example server transport := utilnet.SetTransportDefaults(&http.Transport{ @@ -261,8 +258,7 @@ func TestContainerRegistryNoStorageScope(t *testing.T) { w.WriteHeader(http.StatusNotFound) } })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Make a transport that reroutes all traffic to the example server transport := utilnet.SetTransportDefaults(&http.Transport{ @@ -295,8 +291,7 @@ func TestComputePlatformScopeSubstitutesStorageScope(t *testing.T) { w.WriteHeader(http.StatusNotFound) } })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Make a transport that reroutes all traffic to the example server transport := utilnet.SetTransportDefaults(&http.Transport{ @@ -318,8 +313,7 @@ func TestAllProvidersNoMetadata(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Make a transport that reroutes all traffic to the example server transport := utilnet.SetTransportDefaults(&http.Transport{ diff --git a/pkg/kubectl/proxy_server_test.go b/pkg/kubectl/proxy_server_test.go index 2d403149fe..79d1365a33 100644 --- a/pkg/kubectl/proxy_server_test.go +++ b/pkg/kubectl/proxy_server_test.go @@ -205,8 +205,7 @@ func TestFileServing(t *testing.T) { const prefix = "/foo/" handler := newFileHandler(prefix, dir) server := httptest.NewServer(handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() url := server.URL + prefix + fname res, err := http.Get(url) @@ -236,8 +235,7 @@ func TestAPIRequests(t *testing.T) { } fmt.Fprintf(w, "%s %s %s", r.Method, r.RequestURI, string(b)) })) - // TODO: Uncomment when fix #19254 - // defer ts.Close() + defer ts.Close() // httptest.NewServer should always generate a valid URL. target, _ := url.Parse(ts.URL) @@ -273,8 +271,7 @@ func TestPathHandling(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, r.URL.Path) })) - // TODO: Uncomment when fix #19254 - // defer ts.Close() + defer ts.Close() table := []struct { prefix string @@ -304,8 +301,7 @@ func TestPathHandling(t *testing.T) { t.Fatalf("%#v: %v", item, err) } pts := httptest.NewServer(p.handler) - // TODO: Uncomment when fix #19254 - // defer pts.Close() + defer pts.Close() r, err := http.Get(pts.URL + item.reqPath) if err != nil { diff --git a/pkg/kubectl/resource/builder_test.go b/pkg/kubectl/resource/builder_test.go index 3100cfa43a..d99ba8e747 100644 --- a/pkg/kubectl/resource/builder_test.go +++ b/pkg/kubectl/resource/builder_test.go @@ -452,8 +452,7 @@ func TestNamespaceOverride(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write([]byte(runtime.EncodeOrDie(testapi.Default.Codec(), &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "foo", Name: "test"}}))) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). FilenameParam(false, false, s.URL). @@ -484,8 +483,7 @@ func TestURLBuilder(t *testing.T) { w.Write([]byte(runtime.EncodeOrDie(testapi.Default.Codec(), &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "foo", Name: "test"}}))) w.Write([]byte(runtime.EncodeOrDie(testapi.Default.Codec(), &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "foo", Name: "test1"}}))) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). FilenameParam(false, false, s.URL). @@ -514,8 +512,7 @@ func TestURLBuilderRequireNamespace(t *testing.T) { w.WriteHeader(http.StatusOK) w.Write([]byte(runtime.EncodeOrDie(testapi.Default.Codec(), &api.Pod{ObjectMeta: api.ObjectMeta{Namespace: "foo", Name: "test"}}))) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() b := NewBuilder(testapi.Default.RESTMapper(), api.Scheme, fakeClient(), testapi.Default.Codec()). FilenameParam(false, false, s.URL). diff --git a/pkg/kubelet/client/kubelet_client_test.go b/pkg/kubelet/client/kubelet_client_test.go index 19c816b166..a8352a9d8a 100644 --- a/pkg/kubelet/client/kubelet_client_test.go +++ b/pkg/kubelet/client/kubelet_client_test.go @@ -39,8 +39,7 @@ func TestHTTPKubeletClient(t *testing.T) { ResponseBody: string(body), } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() if _, err := url.Parse(testServer.URL); err != nil { t.Errorf("unexpected error: %v", err) diff --git a/pkg/kubelet/config/http_test.go b/pkg/kubelet/config/http_test.go index a2d9359bdd..b30bf6ab0c 100644 --- a/pkg/kubelet/config/http_test.go +++ b/pkg/kubelet/config/http_test.go @@ -111,8 +111,7 @@ func TestExtractInvalidPods(t *testing.T) { ResponseBody: string(data), } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() ch := make(chan interface{}, 1) c := sourceURL{testServer.URL, http.Header{}, "localhost", ch, nil, 0, http.DefaultClient} if err := c.extractFromURL(); err == nil { @@ -290,8 +289,7 @@ func TestExtractPodsFromHTTP(t *testing.T) { ResponseBody: string(data), } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() ch := make(chan interface{}, 1) c := sourceURL{testServer.URL, http.Header{}, hostname, ch, nil, 0, http.DefaultClient} if err := c.extractFromURL(); err != nil { @@ -336,8 +334,7 @@ func TestURLWithHeader(t *testing.T) { ResponseBody: string(data), } testServer := httptest.NewServer(&fakeHandler) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() ch := make(chan interface{}, 1) header := make(http.Header) header.Set("Metadata-Flavor", "Google") diff --git a/pkg/master/master_test.go b/pkg/master/master_test.go index ca315f8876..772f408e51 100644 --- a/pkg/master/master_test.go +++ b/pkg/master/master_test.go @@ -587,8 +587,7 @@ func testInstallThirdPartyAPIListVersion(t *testing.T, version string) { for _, test := range tests { func() { master, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) if test.items != nil { @@ -698,8 +697,7 @@ func TestInstallThirdPartyAPIGet(t *testing.T) { func testInstallThirdPartyAPIGetVersion(t *testing.T, version string) { master, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) expectedObj := Foo{ @@ -746,8 +744,7 @@ func TestInstallThirdPartyAPIPost(t *testing.T) { func testInstallThirdPartyAPIPostForVersion(t *testing.T, version string) { master, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) inputObj := Foo{ @@ -811,8 +808,7 @@ func TestInstallThirdPartyAPIDelete(t *testing.T) { func testInstallThirdPartyAPIDeleteVersion(t *testing.T, version string) { master, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) expectedObj := Foo{ @@ -889,8 +885,7 @@ func TestInstallThirdPartyAPIListOptions(t *testing.T) { func testInstallThirdPartyAPIListOptionsForVersion(t *testing.T, version string) { _, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) // send a GET request with query parameter @@ -922,8 +917,7 @@ func TestInstallThirdPartyResourceRemove(t *testing.T) { func testInstallThirdPartyResourceRemove(t *testing.T, version string) { master, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) expectedObj := Foo{ @@ -1012,8 +1006,7 @@ func TestThirdPartyDiscovery(t *testing.T) { func testThirdPartyDiscovery(t *testing.T, version string) { _, etcdserver, server, assert := initThirdParty(t, version) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() defer etcdserver.Terminate(t) resp, err := http.Get(server.URL + "/apis/company.com/") diff --git a/pkg/probe/tcp/tcp_test.go b/pkg/probe/tcp/tcp_test.go index 6061218062..751d23b724 100644 --- a/pkg/probe/tcp/tcp_test.go +++ b/pkg/probe/tcp/tcp_test.go @@ -42,8 +42,7 @@ func TestTcpHealthChecker(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() tHost, tPortStr, err := net.SplitHostPort(server.Listener.Addr().String()) if err != nil { t.Errorf("unexpected error: %v", err) diff --git a/pkg/registry/generic/rest/proxy_test.go b/pkg/registry/generic/rest/proxy_test.go index 7e4c279155..8b92684029 100644 --- a/pkg/registry/generic/rest/proxy_test.go +++ b/pkg/registry/generic/rest/proxy_test.go @@ -208,8 +208,7 @@ func TestServeHTTP(t *testing.T) { responseHeader: backendResponseHeader, } backendServer := httptest.NewServer(backendHandler) - // TODO: Uncomment when fix #19254 - // defer backendServer.Close() + defer backendServer.Close() responder := &fakeResponder{} backendURL, _ := url.Parse(backendServer.URL) @@ -220,8 +219,7 @@ func TestServeHTTP(t *testing.T) { UpgradeRequired: test.upgradeRequired, } proxyServer := httptest.NewServer(proxyHandler) - // TODO: Uncomment when fix #19254 - // defer proxyServer.Close() + defer proxyServer.Close() proxyURL, _ := url.Parse(proxyServer.URL) proxyURL.Path = test.requestPath paramValues := url.Values{} @@ -377,8 +375,7 @@ func TestProxyUpgrade(t *testing.T) { ws.Read(body) ws.Write([]byte("hello " + string(body))) })) - // TODO: Uncomment when fix #19254 - // defer backendServer.Close() + defer backendServer.Close() serverURL, _ := url.Parse(backendServer.URL) proxyHandler := &UpgradeAwareProxyHandler{ @@ -386,8 +383,7 @@ func TestProxyUpgrade(t *testing.T) { Transport: tc.ProxyTransport, } proxy := httptest.NewServer(proxyHandler) - // TODO: Uncomment when fix #19254 - // defer proxy.Close() + defer proxy.Close() ws, err := websocket.Dial("ws://"+proxy.Listener.Addr().String()+"/some/path", "", "http://127.0.0.1/") if err != nil { @@ -621,8 +617,7 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { // Write successful response w.Write([]byte(successfulResponse)) })) - // TODO: Uncomment when fix #19254 - // defer downstreamServer.Close() + defer downstreamServer.Close() responder := &fakeResponder{} backendURL, _ := url.Parse(downstreamServer.URL) @@ -632,8 +627,7 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { UpgradeRequired: false, } proxyServer := httptest.NewServer(proxyHandler) - // TODO: Uncomment when fix #19254 - // defer proxyServer.Close() + defer proxyServer.Close() // Dial the proxy server conn, err := net.Dial(proxyServer.Listener.Addr().Network(), proxyServer.Listener.Addr().String()) diff --git a/pkg/registry/generic/rest/streamer_test.go b/pkg/registry/generic/rest/streamer_test.go index d941d3b23c..9562228376 100644 --- a/pkg/registry/generic/rest/streamer_test.go +++ b/pkg/registry/generic/rest/streamer_test.go @@ -36,8 +36,7 @@ func TestInputStreamReader(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { w.Write([]byte(resultString)) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() u, err := url.Parse(s.URL) if err != nil { t.Errorf("Error parsing server URL: %v", err) diff --git a/pkg/storage/etcd/testing/utils.go b/pkg/storage/etcd/testing/utils.go index 8cf623f8f0..d46085e4cb 100644 --- a/pkg/storage/etcd/testing/utils.go +++ b/pkg/storage/etcd/testing/utils.go @@ -212,8 +212,7 @@ func (m *EtcdTestServer) Terminate(t *testing.T) { time.Sleep(250 * time.Millisecond) for _, hs := range m.hss { hs.CloseClientConnections() - // TODO: Uncomment when fix #19254 - // hs.Close() + hs.Close() } if err := os.RemoveAll(m.ServerConfig.DataDir); err != nil { t.Fatal(err) diff --git a/pkg/storage/etcd/util/etcd_util_test.go b/pkg/storage/etcd/util/etcd_util_test.go index 455542017a..cc41958ad0 100644 --- a/pkg/storage/etcd/util/etcd_util_test.go +++ b/pkg/storage/etcd/util/etcd_util_test.go @@ -47,8 +47,7 @@ func TestGetEtcdVersion_ValidVersion(t *testing.T) { testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, validEtcdVersion) })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() var version string var err error @@ -63,8 +62,7 @@ func TestGetEtcdVersion_ErrorStatus(t *testing.T) { testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusServiceUnavailable) })) - // TODO: Uncomment when fix #19254 - // defer testServer.Close() + defer testServer.Close() _, err := GetEtcdVersion(testServer.URL) assert.NotNil(t, err) diff --git a/pkg/util/configz/configz_test.go b/pkg/util/configz/configz_test.go index e540d031a3..7e52020501 100644 --- a/pkg/util/configz/configz_test.go +++ b/pkg/util/configz/configz_test.go @@ -32,8 +32,7 @@ func TestConfigz(t *testing.T) { v.Set("blah") s := httptest.NewServer(http.HandlerFunc(handle)) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() resp, err := http.Get(s.URL + "/configz") if err != nil { diff --git a/pkg/util/httpstream/spdy/roundtripper_test.go b/pkg/util/httpstream/spdy/roundtripper_test.go index 1aa3a0ee8c..c80a24a69b 100644 --- a/pkg/util/httpstream/spdy/roundtripper_test.go +++ b/pkg/util/httpstream/spdy/roundtripper_test.go @@ -264,8 +264,7 @@ func TestRoundTripAndNewConnection(t *testing.T) { stream := <-streamCh io.Copy(stream, stream) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() serverURL, err := url.Parse(server.URL) if err != nil { @@ -305,8 +304,7 @@ func TestRoundTripAndNewConnection(t *testing.T) { proxyURL.User = testCase.proxyAuth return proxyURL, nil } - // TODO: Uncomment when fix #19254 - // defer proxy.Close() + defer proxy.Close() } client := &http.Client{Transport: spdyTransport} diff --git a/pkg/util/httpstream/spdy/upgrade_test.go b/pkg/util/httpstream/spdy/upgrade_test.go index 2ddfd5a59a..4e111407e8 100644 --- a/pkg/util/httpstream/spdy/upgrade_test.go +++ b/pkg/util/httpstream/spdy/upgrade_test.go @@ -66,8 +66,7 @@ func TestUpgradeResponse(t *testing.T) { } defer conn.Close() })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() req, err := http.NewRequest("GET", server.URL, nil) if err != nil { diff --git a/pkg/util/proxy/transport_test.go b/pkg/util/proxy/transport_test.go index 5a71bb1b5b..fca115526b 100644 --- a/pkg/util/proxy/transport_test.go +++ b/pkg/util/proxy/transport_test.go @@ -219,8 +219,7 @@ func TestProxyTransport(t *testing.T) { w.Header().Set("Content-Type", item.contentType) fmt.Fprint(w, item.input) })) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() // Replace source URL with our test server address. sourceURL := parseURLOrDie(item.sourceURL) diff --git a/pkg/util/testing/fake_handler_test.go b/pkg/util/testing/fake_handler_test.go index 89967a3ea4..bd0d28429d 100644 --- a/pkg/util/testing/fake_handler_test.go +++ b/pkg/util/testing/fake_handler_test.go @@ -26,8 +26,7 @@ import ( func TestFakeHandlerPath(t *testing.T) { handler := FakeHandler{StatusCode: http.StatusOK} server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() method := "GET" path := "/foo/bar" body := "somebody" @@ -49,8 +48,7 @@ func TestFakeHandlerPath(t *testing.T) { func TestFakeHandlerPathNoBody(t *testing.T) { handler := FakeHandler{StatusCode: http.StatusOK} server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() method := "GET" path := "/foo/bar" @@ -81,8 +79,7 @@ func (f *fakeError) Logf(format string, args ...interface{}) {} func TestFakeHandlerWrongPath(t *testing.T) { handler := FakeHandler{StatusCode: http.StatusOK} server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() method := "GET" path := "/foo/bar" fakeT := fakeError{} @@ -107,8 +104,7 @@ func TestFakeHandlerWrongPath(t *testing.T) { func TestFakeHandlerWrongMethod(t *testing.T) { handler := FakeHandler{StatusCode: http.StatusOK} server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() method := "GET" path := "/foo/bar" fakeT := fakeError{} @@ -133,8 +129,7 @@ func TestFakeHandlerWrongMethod(t *testing.T) { func TestFakeHandlerWrongBody(t *testing.T) { handler := FakeHandler{StatusCode: http.StatusOK} server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() method := "GET" path := "/foo/bar" body := "somebody" @@ -161,8 +156,7 @@ func TestFakeHandlerWrongBody(t *testing.T) { func TestFakeHandlerNilBody(t *testing.T) { handler := FakeHandler{StatusCode: http.StatusOK} server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() method := "GET" path := "/foo/bar" body := "somebody" diff --git a/pkg/util/wsstream/conn_test.go b/pkg/util/wsstream/conn_test.go index 7695ad81d1..c77d037b05 100644 --- a/pkg/util/wsstream/conn_test.go +++ b/pkg/util/wsstream/conn_test.go @@ -36,10 +36,8 @@ func newServer(handler websocket.Handler) (*httptest.Server, string) { func TestRawConn(t *testing.T) { conn := NewConn(ReadWriteChannel, ReadWriteChannel, IgnoreChannel, ReadChannel, WriteChannel) - // TODO: Uncomment next two lines and remove third line when fix #19254 - // s, addr := newServer(conn.handle) - // defer s.Close() - _, addr := newServer(conn.handle) + s, addr := newServer(conn.handle) + defer s.Close() client, err := websocket.Dial("ws://"+addr, "", "http://localhost/") if err != nil { @@ -115,10 +113,8 @@ func TestRawConn(t *testing.T) { func TestBase64Conn(t *testing.T) { conn := NewConn(ReadWriteChannel, ReadWriteChannel) - // TODO: Uncomment next two lines and remove third line when fix #19254 - // s, addr := newServer(conn.handle) - // defer s.Close() - _, addr := newServer(conn.handle) + s, addr := newServer(conn.handle) + defer s.Close() config, err := websocket.NewConfig("ws://"+addr, "http://localhost/") if err != nil { diff --git a/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go b/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go index f886ca7b57..3836adeb84 100644 --- a/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go +++ b/plugin/pkg/auth/authenticator/token/oidc/oidc_test.go @@ -227,8 +227,7 @@ func TestOIDCDiscoveryNoKeyEndpoint(t *testing.T) { t.Fatalf("Cannot load cert/key pair: %v", err) } srv.StartTLS() - // TODO: Uncomment when fix #19254 - // defer srv.Close() + defer srv.Close() op.pcfg = oidc.ProviderConfig{ Issuer: mustParseURL(t, srv.URL), // An invalid ProviderConfig. Keys endpoint is required. @@ -244,8 +243,7 @@ func TestOIDCDiscoverySecureConnection(t *testing.T) { // Verify that plain HTTP issuer URL is forbidden. op := newOIDCProvider(t) srv := httptest.NewServer(op.mux) - // TODO: Uncomment when fix #19254 - // defer srv.Close() + defer srv.Close() op.pcfg = oidc.ProviderConfig{ Issuer: mustParseURL(t, srv.URL), @@ -281,8 +279,7 @@ func TestOIDCDiscoverySecureConnection(t *testing.T) { t.Fatalf("Cannot load cert/key pair: %v", err) } tlsSrv.StartTLS() - // TODO: Uncomment when fix #19254 - // defer tlsSrv.Close() + defer tlsSrv.Close() op.pcfg = oidc.ProviderConfig{ Issuer: mustParseURL(t, tlsSrv.URL), @@ -317,8 +314,7 @@ func TestOIDCAuthentication(t *testing.T) { t.Fatalf("Cannot load cert/key pair: %v", err) } srv.StartTLS() - // TODO: Uncomment when fix #19254 - // defer srv.Close() + defer srv.Close() // A provider config with all required fields. op.pcfg = oidc.ProviderConfig{ diff --git a/plugin/pkg/scheduler/algorithmprovider/defaults/compatibility_test.go b/plugin/pkg/scheduler/algorithmprovider/defaults/compatibility_test.go index 2c37459fd0..5dc560082f 100644 --- a/plugin/pkg/scheduler/algorithmprovider/defaults/compatibility_test.go +++ b/plugin/pkg/scheduler/algorithmprovider/defaults/compatibility_test.go @@ -113,8 +113,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) if _, err := factory.NewConfigFactory(client, "some-scheduler-name").CreateFromConfig(policy); err != nil { diff --git a/plugin/pkg/scheduler/factory/factory_test.go b/plugin/pkg/scheduler/factory/factory_test.go index 5d8963b006..611bbe1c76 100644 --- a/plugin/pkg/scheduler/factory/factory_test.go +++ b/plugin/pkg/scheduler/factory/factory_test.go @@ -45,8 +45,7 @@ func TestCreate(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) factory := NewConfigFactory(client, api.DefaultSchedulerName) factory.Create() @@ -64,8 +63,7 @@ func TestCreateFromConfig(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) factory := NewConfigFactory(client, api.DefaultSchedulerName) @@ -106,8 +104,7 @@ func TestCreateFromEmptyConfig(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) factory := NewConfigFactory(client, api.DefaultSchedulerName) @@ -150,8 +147,7 @@ func TestDefaultErrorFunc(t *testing.T) { // FakeHandler musn't be sent requests other than the one you want to test. mux.Handle(testapi.Default.ResourcePath("pods", "bar", "foo"), &handler) server := httptest.NewServer(mux) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() factory := NewConfigFactory(client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}), api.DefaultSchedulerName) queue := cache.NewFIFO(cache.MetaNamespaceKeyFunc) podBackoff := podBackoff{ @@ -234,8 +230,7 @@ func TestBind(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) b := binder{client} @@ -320,8 +315,7 @@ func TestResponsibleForPod(t *testing.T) { T: t, } server := httptest.NewServer(&handler) - // TODO: Uncomment when fix #19254 - // defer server.Close() + defer server.Close() client := client.NewOrDie(&restclient.Config{Host: server.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) // factory of "default-scheduler" factoryDefaultScheduler := NewConfigFactory(client, api.DefaultSchedulerName) diff --git a/test/component/scheduler/perf/util.go b/test/component/scheduler/perf/util.go index 0a33818241..484086d9e2 100644 --- a/test/component/scheduler/perf/util.go +++ b/test/component/scheduler/perf/util.go @@ -75,8 +75,7 @@ func mustSetupScheduler() (schedulerConfigFactory *factory.ConfigFactory, destro destroyFunc = func() { glog.Infof("destroying") close(schedulerConfig.StopEverything) - // TODO: Uncomment when fix #19254 - // s.Close() + s.Close() glog.Infof("destroyed") } return diff --git a/test/integration/auth_test.go b/test/integration/auth_test.go index 55df0a8f4b..b7383aaf4d 100644 --- a/test/integration/auth_test.go +++ b/test/integration/auth_test.go @@ -391,8 +391,7 @@ func TestAuthModeAlwaysAllow(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() m, err := master.New(masterConfig) @@ -497,8 +496,7 @@ func TestAuthModeAlwaysDeny(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authorizer = apiserver.NewAlwaysDenyAuthorizer() @@ -555,8 +553,7 @@ func TestAliceNotForbiddenOrUnauthorized(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() @@ -634,8 +631,7 @@ func TestBobIsForbidden(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() @@ -686,8 +682,7 @@ func TestUnknownUserIsUnauthorized(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() @@ -844,8 +839,7 @@ func TestAuthorizationAttributeDetermination(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() @@ -917,8 +911,7 @@ func TestNamespaceAuthorization(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() @@ -1023,8 +1016,7 @@ func TestKindAuthorization(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() @@ -1116,8 +1108,7 @@ func TestReadOnlyAuthorization(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() masterConfig.Authenticator = getTestTokenAuth() diff --git a/test/integration/client_test.go b/test/integration/client_test.go index b4324f5d16..ff902dda74 100644 --- a/test/integration/client_test.go +++ b/test/integration/client_test.go @@ -40,8 +40,7 @@ import ( func TestClient(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() ns := api.NamespaceDefault framework.DeleteAllEtcdKeys() @@ -111,8 +110,7 @@ func TestClient(t *testing.T) { func TestSingleWatch(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() ns := "blargh" deleteAllEtcdKeys() @@ -197,8 +195,7 @@ func TestMultiWatch(t *testing.T) { framework.DeleteAllEtcdKeys() defer framework.DeleteAllEtcdKeys() _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() ns := api.NamespaceDefault client := client.NewOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) diff --git a/test/integration/configmap_test.go b/test/integration/configmap_test.go index 094881bcea..2cf1ff1223 100644 --- a/test/integration/configmap_test.go +++ b/test/integration/configmap_test.go @@ -39,8 +39,7 @@ func TestConfigMap(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() m, err := master.New(masterConfig) diff --git a/test/integration/extender_test.go b/test/integration/extender_test.go index 3f28dbc02d..28b153a30f 100644 --- a/test/integration/extender_test.go +++ b/test/integration/extender_test.go @@ -191,8 +191,7 @@ func TestSchedulerExtender(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() m, err := master.New(masterConfig) @@ -210,8 +209,7 @@ func TestSchedulerExtender(t *testing.T) { es1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { extender1.serveHTTP(t, w, req) })) - // TODO: Uncomment when fix #19254 - // defer es1.Close() + defer es1.Close() extender2 := &Extender{ name: "extender2", @@ -221,8 +219,7 @@ func TestSchedulerExtender(t *testing.T) { es2 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { extender2.serveHTTP(t, w, req) })) - // TODO: Uncomment when fix #19254 - // defer es2.Close() + defer es2.Close() policy := schedulerapi.Policy{ ExtenderConfigs: []schedulerapi.ExtenderConfig{ diff --git a/test/integration/framework/master_utils.go b/test/integration/framework/master_utils.go index c0fd44801f..7eb9d5a767 100644 --- a/test/integration/framework/master_utils.go +++ b/test/integration/framework/master_utils.go @@ -210,8 +210,7 @@ func (m *MasterComponents) Stop(apiServer, rcManager bool) { m.once.Do(m.stopRCManager) } if apiServer { - // TODO: Uncomment when fix #19254 - // m.ApiServer.Close() + m.ApiServer.Close() } } diff --git a/test/integration/master_test.go b/test/integration/master_test.go index bfffb136a0..0c37b3ae7a 100644 --- a/test/integration/master_test.go +++ b/test/integration/master_test.go @@ -35,8 +35,7 @@ import ( func testPrefix(t *testing.T, prefix string) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() resp, err := http.Get(s.URL + prefix) if err != nil { @@ -65,8 +64,7 @@ func TestExtensionsPrefix(t *testing.T) { func TestWatchSucceedsWithoutArgs(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() resp, err := http.Get(s.URL + "/api/v1/namespaces?watch=1") if err != nil { @@ -306,8 +304,7 @@ func TestBatchGroupBackwardCompatibility(t *testing.T) { func TestAccept(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() resp, err := http.Get(s.URL + "/api/") if err != nil { diff --git a/test/integration/metrics_test.go b/test/integration/metrics_test.go index 33ef7abd7f..c7445a8057 100644 --- a/test/integration/metrics_test.go +++ b/test/integration/metrics_test.go @@ -87,8 +87,7 @@ func checkForExpectedMetrics(t *testing.T, metrics []*prometheuspb.MetricFamily, func TestMasterProcessMetrics(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() metrics, err := scrapeMetrics(s) if err != nil { @@ -105,8 +104,7 @@ func TestMasterProcessMetrics(t *testing.T) { func TestApiserverMetrics(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() // Make a request to the apiserver to ensure there's at least one data point // for the metrics we're expecting -- otherwise, they won't be exported. diff --git a/test/integration/persistent_volumes_test.go b/test/integration/persistent_volumes_test.go index 5659caa95e..aec4c8046d 100644 --- a/test/integration/persistent_volumes_test.go +++ b/test/integration/persistent_volumes_test.go @@ -44,8 +44,7 @@ func init() { func TestPersistentVolumeRecycler(t *testing.T) { _, s := framework.RunAMaster(t) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() deleteAllEtcdKeys() // Use higher QPS and Burst, there is a test for race condition below, which diff --git a/test/integration/pods.go b/test/integration/pods.go index 5743488b8e..4ac98b5080 100644 --- a/test/integration/pods.go +++ b/test/integration/pods.go @@ -37,8 +37,7 @@ func TestPodUpdateActiveDeadlineSeconds(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() ns := "pod-activedeadline-update" masterConfig := framework.NewIntegrationTestMasterConfig() @@ -168,8 +167,7 @@ func TestPodReadOnlyFilesystem(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() isReadOnly := true ns := "pod-readonly-root" diff --git a/test/integration/scheduler_test.go b/test/integration/scheduler_test.go index 11b3d47444..b8a74a7dc3 100644 --- a/test/integration/scheduler_test.go +++ b/test/integration/scheduler_test.go @@ -58,8 +58,7 @@ func TestUnschedulableNodes(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() m, err := master.New(masterConfig) diff --git a/test/integration/secret_test.go b/test/integration/secret_test.go index 32b8f7561f..a87d166dbd 100644 --- a/test/integration/secret_test.go +++ b/test/integration/secret_test.go @@ -45,8 +45,7 @@ func TestSecrets(t *testing.T) { s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { m.Handler.ServeHTTP(w, req) })) - // TODO: Uncomment when fix #19254 - // defer s.Close() + defer s.Close() masterConfig := framework.NewIntegrationTestMasterConfig() m, err := master.New(masterConfig) diff --git a/test/integration/service_account_test.go b/test/integration/service_account_test.go index e80e5783e4..28bfa451d1 100644 --- a/test/integration/service_account_test.go +++ b/test/integration/service_account_test.go @@ -426,8 +426,7 @@ func startServiceAccountTestServer(t *testing.T) (*clientset.Clientset, restclie tokenController.Stop() serviceAccountController.Stop() serviceAccountAdmission.Stop() - // TODO: Uncomment when fix #19254 - // apiServer.Close() + apiServer.Close() } return rootClientset, clientConfig, stop