MCPcopy
hub / github.com/grafana/dskit / TestHTTPTransport_DisableKeepAlives

Function TestHTTPTransport_DisableKeepAlives

runtimeconfig/manager_test.go:1111–1125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1109}
1110
1111func TestHTTPTransport_DisableKeepAlives(t *testing.T) {
1112 t.Run("sets DisableKeepAlives on the transport", func(t *testing.T) {
1113 for _, disable := range []bool{true, false} {
1114 rt := httpTransport(Config{HTTPClientDisableKeepAlives: disable}, "test", prometheus.NewRegistry(), log.NewNopLogger())
1115 tr, ok := rt.(*http.Transport)
1116 require.True(t, ok, "expected an *http.Transport when no cluster validation label is set")
1117 require.Equal(t, disable, tr.DisableKeepAlives)
1118 }
1119 })
1120
1121 t.Run("does not mutate http.DefaultTransport", func(t *testing.T) {
1122 _ = httpTransport(Config{HTTPClientDisableKeepAlives: true}, "test", prometheus.NewRegistry(), log.NewNopLogger())
1123 require.False(t, http.DefaultTransport.(*http.Transport).DisableKeepAlives, "httpTransport must clone http.DefaultTransport, not mutate it")
1124 })
1125}
1126
1127// TestHTTPClient_DisableKeepAlives verifies that, with keep-alives disabled, every
1128// fetch opens a fresh connection (so requests get re-balanced across backends), while

Callers

nothing calls this directly

Calls 3

httpTransportFunction · 0.85
RunMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected