Skip to content

Commit

Permalink
add better check for load balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkermichael committed Oct 3, 2023
1 parent 424b498 commit ae0d043
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions acceptance/tests/wan-federation/wan_federation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ func serviceFailoverCheck(t *testing.T, options *terratestK8s.KubectlOptions, po
var err error

// Retry until we get the response we expect, sometimes you get back the previous server until things stabalize
logger.Log(t, "Initial curl check")
retry.RunWith(timer, t, func(r *retry.R) {
resp, err = k8s.RunKubectlAndGetOutputE(t, options, "exec", "-i",
staticClientDeployment, "-c", connhelper.StaticClientName, "--", "curl", fmt.Sprintf("localhost:%s", port))
Expand All @@ -432,12 +433,19 @@ func serviceFailoverCheck(t *testing.T, options *terratestK8s.KubectlOptions, po
})

// Try again to rule out load-balancing. Errors can still happen so retry
retry.RunWith(timer, t, func(r *retry.R) {
resp, err = k8s.RunKubectlAndGetOutputE(t, options, "exec", "-i",
staticClientDeployment, "-c", connhelper.StaticClientName, "--", "curl", fmt.Sprintf("localhost:%s", port))
assert.NoError(r, err)
})
require.Contains(t, resp, expectedName)
logger.Log(t, "Curl check again for load balancing")
time.Sleep(500 * time.Millisecond)
for i := 0; i < 10; i++ {
resp = ""
retry.RunWith(timer, t, func(r *retry.R) {
resp, err = k8s.RunKubectlAndGetOutputE(t, options, "exec", "-i",
staticClientDeployment, "-c", connhelper.StaticClientName, "--", "curl", fmt.Sprintf("localhost:%s", port))
assert.NoError(r, err)
})
require.Contains(t, resp, expectedName)
time.Sleep(500 * time.Millisecond)
}

logger.Log(t, resp)
}

Expand Down

0 comments on commit ae0d043

Please sign in to comment.