Add service reachability polling to avoid flakiness

This commit is contained in:
Mayank Gaikwad 2019-08-14 06:22:33 +05:30
parent 125fb72850
commit eddd7da462
2 changed files with 11 additions and 2 deletions

View File

@ -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
)

View File

@ -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)
}
}