Merge pull request #89412 from coderanger/fix-kubelet-method-metrics

Apply the same style of fix as #87913 but for HTTP methods too.
This commit is contained in:
Kubernetes Prow Robot
2020-05-18 17:43:36 -07:00
committed by GitHub
3 changed files with 40 additions and 8 deletions

View File

@@ -1510,8 +1510,8 @@ func TestMetricBuckets(t *testing.T) {
"stats summary sub": {url: "/stats/summary", bucket: "stats"},
"stats containerName with uid": {url: "/stats/namespace/podName/uid/containerName", bucket: "stats"},
"stats containerName": {url: "/stats/podName/containerName", bucket: "stats"},
"invalid path": {url: "/junk", bucket: "Invalid path"},
"invalid path starting with good": {url: "/healthzjunk", bucket: "Invalid path"},
"invalid path": {url: "/junk", bucket: "other"},
"invalid path starting with good": {url: "/healthzjunk", bucket: "other"},
}
fw := newServerTest()
defer fw.testHTTPServer.Close()
@@ -1523,6 +1523,26 @@ func TestMetricBuckets(t *testing.T) {
}
}
func TestMetricMethodBuckets(t *testing.T) {
tests := map[string]struct {
method string
bucket string
}{
"normal GET": {method: "GET", bucket: "GET"},
"normal POST": {method: "POST", bucket: "POST"},
"invalid method": {method: "WEIRD", bucket: "other"},
}
fw := newServerTest()
defer fw.testHTTPServer.Close()
for _, test := range tests {
method := test.method
bucket := test.bucket
require.Equal(t, fw.serverUnderTest.getMetricMethodBucket(method), bucket)
}
}
func TestDebuggingDisabledHandlers(t *testing.T) {
fw := newServerTestWithDebug(false, false, nil)
defer fw.testHTTPServer.Close()