scrape: update test after review

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
pull/15563/head
Giedrius Statkevičius 2024-12-09 08:17:32 +02:00
parent 90e832c861
commit 5479fb3cfd
1 changed files with 7 additions and 22 deletions

View File

@ -4795,19 +4795,12 @@ func newScrapableServer(scrapeText string) (s *httptest.Server, scrapedTwice cha
})), scrapedTwice })), scrapedTwice
} }
type srvSameResp struct { func TestTargetScraperSetsMetricsField(t *testing.T) {
resp []byte h := httptest.NewServer(http.HandlerFunc(
} func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte{0x42, 0x42})
func (s *srvSameResp) ServeHTTP(w http.ResponseWriter, r *http.Request) { },
w.Write(s.resp) ))
}
func TestTargetScraperSegfault(t *testing.T) {
emptySrv := &srvSameResp{
resp: []byte{0x42, 0x42},
}
h := httptest.NewServer(emptySrv)
t.Cleanup(h.Close) t.Cleanup(h.Close)
cfg := &config.ScrapeConfig{ cfg := &config.ScrapeConfig{
@ -4826,15 +4819,7 @@ func TestTargetScraperSegfault(t *testing.T) {
}, },
} }
p, err := newScrapePool( p, err := newScrapePool(cfg, &nopAppendable{}, 0, nil, nil, &Options{}, newTestScrapeMetrics(t))
cfg,
&nopAppendable{},
0,
nil,
pool.New(1e3, 100e6, 3, func(sz int) interface{} { return make([]byte, 0, sz) }),
&Options{},
newTestScrapeMetrics(t),
)
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(p.stop) t.Cleanup(p.stop)