Fix a test flake where a retry timer was being reused causing tests after the first to exit early (#19864)

Fix a test flake where a retry timer was being reused causing tests after the first to exit too early.
This commit is contained in:
Matt Keeler 2023-12-08 11:31:59 -05:00 committed by GitHub
parent 8125a32a4e
commit d4fda945bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -22,7 +22,9 @@ import (
const externalServerName = libservice.StaticServerServiceName
var requestRetryTimer = &retry.Timer{Timeout: 120 * time.Second, Wait: 500 * time.Millisecond}
func requestRetryTimer() *retry.Timer {
return &retry.Timer{Timeout: 120 * time.Second, Wait: 500 * time.Millisecond}
}
// TestTerminatingGateway Summary
// This test makes sure an external service can be reached via and terminating gateway. External server
@ -171,7 +173,7 @@ func createTerminatingGatewayConfigEntry(t *testing.T, consulClient *api.Client,
// in the response.
func assertHTTPRequestToServiceAddress(t *testing.T, client *libservice.ConnectContainer, serviceName string, port int, expSuccess bool) {
upstreamURL := fmt.Sprintf("http://localhost:%d/debug?env=dump", port)
retry.RunWith(requestRetryTimer, t, func(r *retry.R) {
retry.RunWith(requestRetryTimer(), t, func(r *retry.R) {
out, err := client.Exec(context.Background(), []string{"curl", "-s", upstreamURL})
r.Logf("curl request to upstream service address: url=%s\nerr = %v\nout = %s", upstreamURL, err, out)