Uncomment the code that cause by #19254

pull/6/head
zhouhaibing089 2016-04-21 04:50:55 -07:00 committed by haibzhou
parent c0020aff59
commit bf1a3f99c0
53 changed files with 218 additions and 436 deletions

View File

@ -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{} {

View File

@ -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&param2=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&param2=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&param2=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&param2=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 {

View File

@ -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{}{}

View File

@ -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(

View File

@ -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)

View File

@ -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.

View File

@ -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(

View File

@ -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{

View File

@ -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()

View File

@ -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"})

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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()
}
}
}

View File

@ -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()
}
}

View File

@ -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)

View File

@ -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{

View File

@ -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

View File

@ -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)

View File

@ -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 {

View File

@ -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{

View File

@ -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 {

View File

@ -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).

View File

@ -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)

View File

@ -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")

View File

@ -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/")

View File

@ -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)

View File

@ -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())

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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 {

View File

@ -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}

View File

@ -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 {

View File

@ -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)

View File

@ -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"

View File

@ -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 {

View File

@ -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{

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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()

View File

@ -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()}})

View File

@ -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)

View File

@ -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{

View File

@ -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()
}
}

View File

@ -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 {

View File

@ -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.

View File

@ -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

View File

@ -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"

View File

@ -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)

View File

@ -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)

View File

@ -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