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

Function TestPprofCmdlineDisabled

server/server_test.go:1067–1092  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1065}
1066
1067func TestPprofCmdlineDisabled(t *testing.T) {
1068 var cfg Config
1069 flagext.DefaultValues(&cfg)
1070 setAutoAssignedPorts("tcp", &cfg)
1071 reg := prometheus.NewPedanticRegistry()
1072 cfg.Registerer, cfg.Gatherer = reg, reg
1073
1074 srv, err := New(cfg)
1075 require.NoError(t, err)
1076 go func() { require.NoError(t, srv.Run()) }()
1077 t.Cleanup(srv.Shutdown)
1078
1079 // /debug/pprof/cmdline should return 404
1080 resp, err := http.Get(httpTarget(srv, "/debug/pprof/cmdline"))
1081 require.NoError(t, err)
1082 defer resp.Body.Close()
1083 assert.Equal(t, http.StatusNotFound, resp.StatusCode)
1084
1085 // Other pprof endpoints should still work
1086 for _, path := range []string{"/debug/pprof/", "/debug/pprof/heap"} {
1087 resp, err := http.Get(httpTarget(srv, path))
1088 require.NoError(t, err)
1089 resp.Body.Close()
1090 assert.Equal(t, http.StatusOK, resp.StatusCode, "expected 200 for %s", path)
1091 }
1092}
1093
1094func httpTarget(srv *Server, path string) string {
1095 return fmt.Sprintf("http://%s%s", srv.HTTPListenAddr().String(), path)

Callers

nothing calls this directly

Calls 8

DefaultValuesFunction · 0.92
setAutoAssignedPortsFunction · 0.85
httpTargetFunction · 0.85
RunMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected