diff --git a/cmd/otel-allocator/server/bench_test.go b/cmd/otel-allocator/server/bench_test.go index 2219eaadb2..2145101fb3 100644 --- a/cmd/otel-allocator/server/bench_test.go +++ b/cmd/otel-allocator/server/bench_test.go @@ -21,6 +21,7 @@ import ( "testing" "time" + "github.com/gin-gonic/gin" "github.com/prometheus/common/model" promconfig "github.com/prometheus/prometheus/config" @@ -81,8 +82,12 @@ func BenchmarkScrapeConfigsHandler(b *testing.B) { for i := 0; i < b.N; i++ { s.compareHash = 0 s.discoveryManager = &mockDiscoveryManager{m: data} - resp := httptest.NewRecorder() - s.ScrapeConfigsHandler(resp, nil) + + c, _ := gin.CreateTestContext(httptest.NewRecorder()) + gin.SetMode(gin.ReleaseMode) + c.Request = httptest.NewRequest("GET", "/scrape_configs", nil) + + s.ScrapeConfigsHandler(c) } }) } diff --git a/cmd/otel-allocator/server/server_test.go b/cmd/otel-allocator/server/server_test.go index 35ce2467e0..9dd90728c3 100644 --- a/cmd/otel-allocator/server/server_test.go +++ b/cmd/otel-allocator/server/server_test.go @@ -24,6 +24,7 @@ import ( "testing" "time" + "github.com/gin-gonic/gin" "github.com/prometheus/common/config" "github.com/prometheus/common/model" promconfig "github.com/prometheus/prometheus/config" @@ -640,10 +641,12 @@ func TestScrapeConfigsHandler_Hashing(t *testing.T) { t.Run(tc.description, func(t *testing.T) { dm := &mockDiscoveryManager{m: tc.scrapeConfigs} s.discoveryManager = dm - request := httptest.NewRequest("GET", "/scrape_configs", nil) w := httptest.NewRecorder() + c, _ := gin.CreateTestContext(w) + gin.SetMode(gin.ReleaseMode) + c.Request = httptest.NewRequest("GET", "/scrape_configs", nil) - s.ScrapeConfigsHandler(w, request) + s.ScrapeConfigsHandler(c) result := w.Result() assert.Equal(t, http.StatusOK, result.StatusCode)