diff --git a/changelog/prestoalvarez_patch3.md b/changelog/prestoalvarez_patch3.md new file mode 100644 index 000000000000..dc5c7bc27d39 --- /dev/null +++ b/changelog/prestoalvarez_patch3.md @@ -0,0 +1 @@ +Fix resource leak in prometheus service test by properly closing HTTP response body. diff --git a/monitoring/prometheus/service_test.go b/monitoring/prometheus/service_test.go index 3087ab3baa3a..6d6936c1de90 100644 --- a/monitoring/prometheus/service_test.go +++ b/monitoring/prometheus/service_test.go @@ -32,6 +32,8 @@ func TestLifecycle(t *testing.T) { // Query the service to ensure it really started. resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", port)) require.NoError(t, err) + // Close response body to avoid leaking connections. + defer resp.Body.Close() assert.NotEqual(t, uint64(0), resp.ContentLength, "Unexpected content length 0") err = prometheusService.Stop()