From eddd7da46245ee0f63e088cd9d1a0be2efe0ee4a Mon Sep 17 00:00:00 2001 From: Mayank Gaikwad <8110509+mgdevstack@users.noreply.github.com> Date: Wed, 14 Aug 2019 06:22:33 +0530 Subject: [PATCH] Add service reachability polling to avoid flakiness --- test/e2e/framework/service/const.go | 3 +++ test/e2e/framework/service/jig.go | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/test/e2e/framework/service/const.go b/test/e2e/framework/service/const.go index b4901f3cbc4..64e1fc326ac 100644 --- a/test/e2e/framework/service/const.go +++ b/test/e2e/framework/service/const.go @@ -78,4 +78,7 @@ const ( // ServiceEndpointsTimeout is the maximum time in which endpoints for the service should be created. ServiceEndpointsTimeout = 2 * time.Minute + + // ServiceReachabilityShortPollTimeout is the maximum time in which service must be reachable during polling. + ServiceReachabilityShortPollTimeout = 2 * time.Minute ) diff --git a/test/e2e/framework/service/jig.go b/test/e2e/framework/service/jig.go index fac30235175..238bb3f9e66 100644 --- a/test/e2e/framework/service/jig.go +++ b/test/e2e/framework/service/jig.go @@ -812,8 +812,14 @@ func testEndpointReachability(endpoint string, port int32, protocol v1.Protocol, e2elog.Failf("Service reachablity check is not supported for %v", protocol) } if cmd != "" { - _, err := framework.RunHostCmd(execPod.Namespace, execPod.Name, cmd) - framework.ExpectNoError(err, "Service is not reachable on following endpoint %s over %s protocol", ep, protocol) + err := wait.PollImmediate(1*time.Second, ServiceReachabilityShortPollTimeout, func() (bool, error) { + if _, err := framework.RunHostCmd(execPod.Namespace, execPod.Name, cmd); err != nil { + e2elog.Logf("Service reachability failing with error: %v\nRetrying...", err) + return false, nil + } + return true, nil + }) + framework.ExpectNoError(err, "Service is not reachable within %v timeout on endpoint %s over %s protocol", ServiceReachabilityShortPollTimeout, ep, protocol) } }