MCPcopy
hub / github.com/kubernetes/client-go / BenchmarkCheckRetryClosesBody

Function BenchmarkCheckRetryClosesBody

rest/request_test.go:1429–1454  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1427}
1428
1429func BenchmarkCheckRetryClosesBody(b *testing.B) {
1430 count := 0
1431 testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
1432 count++
1433 if count%3 == 0 {
1434 w.WriteHeader(http.StatusOK)
1435 return
1436 }
1437 w.Header().Set("Retry-After", "0")
1438 w.WriteHeader(http.StatusTooManyRequests)
1439 }))
1440 defer testServer.Close()
1441
1442 c := testRESTClient(b, testServer)
1443 r := c.Verb("POST").
1444 Prefix("foo", "bar").
1445 Suffix("baz").
1446 Timeout(time.Second).
1447 Body([]byte(strings.Repeat("abcd", 1000)))
1448
1449 for i := 0; i < b.N; i++ {
1450 if _, err := r.DoRaw(); err != nil {
1451 b.Fatalf("Unexpected error: %v %#v", err, err)
1452 }
1453 }
1454}
1455
1456func TestDoRequestNewWayReader(t *testing.T) {
1457 reqObj := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "foo"}}

Callers

nothing calls this directly

Calls 9

testRESTClientFunction · 0.85
BodyMethod · 0.80
TimeoutMethod · 0.80
SuffixMethod · 0.80
PrefixMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
VerbMethod · 0.65
DoRawMethod · 0.65

Tested by

no test coverage detected