MCPcopy Index your code
hub / github.com/netdata/netdata / TestPrometheusGzip

Function TestPrometheusGzip

src/go/pkg/prometheus/client_test.go:87–112  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestPrometheusGzip(t *testing.T) {
88 counter := 0
89 rawTestData := [][]byte{testData, testDataNoMeta}
90 tsMux := http.NewServeMux()
91 tsMux.HandleFunc("/metrics", func(w http.ResponseWriter, r *http.Request) {
92 w.Header().Set("Content-Encoding", "gzip")
93 w.WriteHeader(200)
94 gz := new(bytes.Buffer)
95 ww := gzip.NewWriter(gz)
96 _, _ = ww.Write(rawTestData[counter])
97 _ = ww.Close()
98 _, _ = gz.WriteTo(w)
99 counter++
100 })
101 ts := httptest.NewServer(tsMux)
102 defer ts.Close()
103
104 req := web.RequestConfig{URL: ts.URL + "/metrics"}
105 prom := New(http.DefaultClient, req)
106
107 for range 2 {
108 res, err := prom.ScrapeSeries()
109 assert.NoError(t, err)
110 verifyTestData(t, res)
111 }
112}
113
114func TestPrometheusReadFromFile(t *testing.T) {
115 req := web.RequestConfig{URL: "file://testdata/testdata.txt"}

Callers

nothing calls this directly

Calls 7

verifyTestDataFunction · 0.85
NewFunction · 0.70
SetMethod · 0.65
WriteMethod · 0.65
CloseMethod · 0.65
WriteToMethod · 0.65
ScrapeSeriesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…