From 9c5e11e991d73104fecd7a954dbfdb0baf5d42b9 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Mon, 22 Aug 2016 12:00:07 +1000 Subject: [PATCH 1/2] Fix static URL conformance test 1. /validate service does not exist, so remove the test for it and add some that actually do exist 2. The namespace does not exist so this will always return NotFound Note: DoRaw() ignores the StatusCode. This is in preparation for the next commit --- test/e2e/networking.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/networking.go b/test/e2e/networking.go index a09fba670b2..ee6bdd337da 100644 --- a/test/e2e/networking.go +++ b/test/e2e/networking.go @@ -59,14 +59,18 @@ var _ = framework.KubeDescribe("Networking", func() { tests := []struct { path string }{ - {path: "/validate"}, {path: "/healthz"}, + {path: "/api"}, + {path: "/apis"}, + {path: "/logs"}, + {path: "/metrics"}, + {path: "/swaggerapi"}, + {path: "/version"}, // TODO: test proxy links here } for _, test := range tests { By(fmt.Sprintf("testing: %s", test.path)) data, err := f.Client.RESTClient.Get(). - Namespace(f.Namespace.Name). AbsPath(test.path). DoRaw() if err != nil { From c955de2ba8db3eb17058c02d61af9e4527edac78 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Fri, 19 Aug 2016 15:54:48 +1000 Subject: [PATCH 2/2] Make sure the StatusCode is taken into account in DoRaw() Currently if there is an error (not found) the error printed out is to do with the inablity to convert an empty body into the expected json. This patch will fill in the err correctly. example of before (with NotFound error): $ kubectl top node failed to unmarshall heapster response: json: cannot unmarshal object into Go value of type []v1alpha1.NodeMetrics Now: $ kubectl top node the server could not find the requested resource (get services http:heapster:) --- pkg/client/restclient/request.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/client/restclient/request.go b/pkg/client/restclient/request.go index cad9f90ca9b..b57f5558e42 100644 --- a/pkg/client/restclient/request.go +++ b/pkg/client/restclient/request.go @@ -881,6 +881,9 @@ func (r *Request) DoRaw() ([]byte, error) { var result Result err := r.request(func(req *http.Request, resp *http.Response) { result.body, result.err = ioutil.ReadAll(resp.Body) + if resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent { + result.err = r.transformUnstructuredResponseError(resp, req, result.body) + } }) if err != nil { return nil, err