Skip to content

Commit

Permalink
[test] fix flaky telemetry zpages test
Browse files Browse the repository at this point in the history
  • Loading branch information
paivagustavo committed Oct 19, 2022
1 parent ee02bc7 commit d75fc60
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions service/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -391,7 +392,7 @@ func testCollectorStartHelper(t *testing.T, telemetry *telemetryInitializer, tc

assertMetrics(t, metricsAddr, tc.expectedLabels)

assertZPages(t)
assertZPages(t, zpagesAddr)

col.Shutdown()

Expand Down Expand Up @@ -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.
Expand All @@ -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
}
Expand Down

0 comments on commit d75fc60

Please sign in to comment.