Skip to content

Commit

Permalink
Skip initial tick-delay when pining servers in CI tests.
Browse files Browse the repository at this point in the history
The `Eventually` function will always wait for its initial tick-delay.
This commit ensures that the PingInterceptedEchoServer pings immediately
and then uses Eventually if that ping fails.

Signed-off-by: Thomas Hallgren <thomas@tada.se>
  • Loading branch information
thallgren committed Jan 5, 2025
1 parent f0bad4e commit b96a3b8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions integration_test/itest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,9 @@ func PingInterceptedEchoServer(ctx context.Context, svc, svcPort string, headers
svc = svc[:slashIdx]
}
expectedOutput := fmt.Sprintf("%s from intercept at /", wl)
require.Eventually(getT(ctx), func() bool {
dlog.Infof(ctx, "pinging %s, expecting output: %s", net.JoinHostPort(svc, svcPort), expectedOutput)

ping := func() bool {
// condition
ips, err := net.DefaultResolver.LookupIP(ctx, "ip", svc)
if err != nil {
Expand Down Expand Up @@ -1203,11 +1205,11 @@ func PingInterceptedEchoServer(ctx context.Context, svc, svcPort string, headers
return false
}
return true
},
time.Minute, // waitFor
5*time.Second, // polling interval
`body of %q equals %q`, "http://"+svc, expectedOutput,
)
}
if ping() {
return
}
require.Eventually(getT(ctx), ping, time.Minute, 5*time.Second, `body of %q equals %q`, "http://"+svc, expectedOutput)
}

func WithConfig(c context.Context, modifierFunc func(config client.Config)) context.Context {
Expand Down

0 comments on commit b96a3b8

Please sign in to comment.