Update test/e2e/framework/network/utils.go

add logging about min/max interval
Co-authored-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
This commit is contained in:
jay vyas 2020-10-05 05:15:30 -04:00 committed by jay vyas
parent 56def96d9d
commit 8630dc924a

View File

@ -380,12 +380,12 @@ func (config *NetworkingTestConfig) GetHTTPCodeFromTestContainer(path, targetIP
return code, nil
}
// DialFromNode executes a tcp or udp curl/echo request based on protocol via kubectl exec
// DialFromNode executes a tcp/udp curl/nc request based on protocol via kubectl exec
// in a test container running with host networking.
// - minTries is the minimum number of curl/echo attempts required before declaring
// - minTries is the minimum number of curl/nc attempts required before declaring
// success. If 0, then we return as soon as all endpoints succeed.
// - There is no logical change to test results if faillures happen AFTER endpoints have succeeded,
// hence over-padding minTries will NOT reverse a successfull result and is thus not very useful yet
// hence over-padding minTries will NOT reverse a successful result and is thus not very useful yet
// (See the TODO about checking probability, which isnt implemented yet).
// - maxTries is the maximum number of curl/echo attempts before an error is returned. The
// smaller this number is, the less 'slack' there is for declaring success.
@ -411,6 +411,7 @@ func (config *NetworkingTestConfig) DialFromNode(protocol, targetIP string, targ
eps := sets.NewString()
filterCmd := fmt.Sprintf("%s | grep -v '^\\s*$'", cmd)
framework.Logf("Going to poll %v on port %v at least %v times, with a maximum of %v tries before failing", targetIP, targetPort, minTries, maxTries)
for i := 0; i < maxTries; i++ {
stdout, stderr, err := config.f.ExecShellInPodWithFullOutput(config.HostTestContainerPod.Name, filterCmd)
if err != nil || len(stderr) > 0 {
@ -427,7 +428,7 @@ func (config *NetworkingTestConfig) DialFromNode(protocol, targetIP string, targ
// Check against i+1 so we exit if minTries == maxTries.
if eps.Equal(expectedEps) && i+1 >= minTries {
framework.Logf("Found all %+v expected endpoints: %+v", len(eps.List()), eps.List())
framework.Logf("Found all %d expected endpoints: %+v", eps.Len(), eps.List())
return nil
}
@ -438,7 +439,7 @@ func (config *NetworkingTestConfig) DialFromNode(protocol, targetIP string, targ
}
config.diagnoseMissingEndpoints(eps)
return fmt.Errorf("failed to find expected endpoints:\nTries %d\nCommand %v\nretrieved %v\nexpected %v\n", maxTries, cmd, eps, expectedEps)
return fmt.Errorf("failed to find expected endpoints, \ntries %d\nCommand %v\nretrieved %v\nexpected %v", maxTries, cmd, eps, expectedEps)
}
// GetSelfURL executes a curl against the given path via kubectl exec into a