From d75fc60f3b8d9278e54b61d4484faf34eeca689b Mon Sep 17 00:00:00 2001 From: "gustavo.paiva" Date: Wed, 19 Oct 2022 15:01:04 -0300 Subject: [PATCH] [test] fix flaky telemetry zpages test --- service/collector_test.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/service/collector_test.go b/service/collector_test.go index 860f88f0ac0..6a0bafa528d 100644 --- a/service/collector_test.go +++ b/service/collector_test.go @@ -352,11 +352,12 @@ func testCollectorStartHelper(t *testing.T, telemetry *telemetryInitializer, tc } metricsAddr := testutil.GetAvailableLocalAddress(t) + zpagesAddr := testutil.GetAvailableLocalAddress(t) // Prepare config properties to be merged with the main config. extraCfgAsProps := map[string]interface{}{ // Setup the zpages extension. - "extensions::zpages": nil, - "service::extensions": "nop, zpages", + "extensions::zpages::endpoint": zpagesAddr, + "service::extensions": "nop, zpages", // Set the metrics address to expose own metrics on. "service::telemetry::metrics::address": metricsAddr, } @@ -391,7 +392,7 @@ func testCollectorStartHelper(t *testing.T, telemetry *telemetryInitializer, tc assertMetrics(t, metricsAddr, tc.expectedLabels) - assertZPages(t) + assertZPages(t, zpagesAddr) col.Shutdown() @@ -589,7 +590,7 @@ func assertMetrics(t *testing.T, metricsAddr string, expectedLabels map[string]l } } -func assertZPages(t *testing.T) { +func assertZPages(t *testing.T, zpagesAddr string) { paths := []string{ "/debug/tracez", // TODO: enable this when otel-metrics is used and this page is available. @@ -599,11 +600,9 @@ func assertZPages(t *testing.T) { "/debug/extensionz", } - const defaultZPagesPort = "55679" - testZPagePathFn := func(t *testing.T, path string) { client := &http.Client{} - resp, err := client.Get("http://localhost:" + defaultZPagesPort + path) + resp, err := client.Get("http://" + zpagesAddr + path) if !assert.NoError(t, err, "error retrieving zpage at %q", path) { return }