From cfce7286ac7f17766a52131ec1dfd343211910b8 Mon Sep 17 00:00:00 2001 From: jackgopack4 Date: Wed, 13 Nov 2024 12:29:59 -0500 Subject: [PATCH] Revert "add retries to flaky metrics http test" This reverts commit ad8ab82e4f450037bf590aafe4eb1a8f15d2f97a. --- service/telemetry/metrics_test.go | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/service/telemetry/metrics_test.go b/service/telemetry/metrics_test.go index 3bf0042151c..09ee8616471 100644 --- a/service/telemetry/metrics_test.go +++ b/service/telemetry/metrics_test.go @@ -8,7 +8,6 @@ import ( "fmt" "net/http" "testing" - "time" io_prometheus_client "github.com/prometheus/client_model/go" "github.com/prometheus/common/expfmt" @@ -202,31 +201,11 @@ func createTestMetrics(t *testing.T, mp metric.MeterProvider) { } func getMetricsFromPrometheus(t *testing.T, endpoint string) map[string]*io_prometheus_client.MetricFamily { - client := &http.Client{ - Timeout: 10 * time.Second, - } - var ( - req *http.Request - err error - rr *http.Response - ) - req, err = http.NewRequest(http.MethodGet, endpoint, nil) + req, err := http.NewRequest(http.MethodGet, endpoint, nil) require.NoError(t, err) - maxRetries := 5 - for i := 0; i < maxRetries; i++ { - rr, err = client.Do(req) - if err == nil && rr.StatusCode == http.StatusOK { - break - } - - if i < maxRetries-1 { - time.Sleep(2 * time.Second) // Wait before retrying - } - } - require.NoError(t, err, "failed to get metrics from Prometheus after %d attempts", maxRetries) - require.Equal(t, http.StatusOK, rr.StatusCode, "unexpected status code after %d attempts", maxRetries) - defer rr.Body.Close() + rr, err := http.DefaultClient.Do(req) + require.NoError(t, err) var parser expfmt.TextParser parsed, err := parser.TextToMetricFamilies(rr.Body)