mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Add some testing
This commit is contained in:
parent
0972c9ba4d
commit
ae603b8ef1
@ -1579,6 +1579,20 @@ func TestDebuggingDisabledHandlers(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestFailedParseParamsSummaryHandler(t *testing.T) {
|
||||
fw := newServerTest()
|
||||
defer fw.testHTTPServer.Close()
|
||||
|
||||
resp, err := http.Post(fw.testHTTPServer.URL+"/stats/summary", "invalid/content/type", nil)
|
||||
assert.NoError(t, err)
|
||||
defer resp.Body.Close()
|
||||
v, err := ioutil.ReadAll(resp.Body)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, http.StatusInternalServerError, resp.StatusCode)
|
||||
assert.Contains(t, string(v), "parse form failed")
|
||||
|
||||
}
|
||||
|
||||
func TestTrimURLPath(t *testing.T) {
|
||||
tests := []struct {
|
||||
path, expected string
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
|
||||
restful "github.com/emicklei/go-restful"
|
||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
@ -217,7 +218,7 @@ func (h *handler) handleSummary(request *restful.Request, response *restful.Resp
|
||||
onlyCPUAndMemory := false
|
||||
err := request.Request.ParseForm()
|
||||
if err != nil {
|
||||
handleError(response, "/stats/summary", err)
|
||||
handleError(response, "/stats/summary", errors.Wrapf(err, "parse form failed"))
|
||||
return
|
||||
}
|
||||
if onlyCluAndMemoryParam, found := request.Request.Form["only_cpu_and_memory"]; found &&
|
||||
|
Loading…
Reference in New Issue
Block a user