don´t panic on e2e ESIPP tests

The ESIPP tests are using a function to poll an HTTP endpoint.
This function failed the framework if the request to the http endpoint
timed out, causing a panic that ginkgo couldn´t recover.

Also, this function was used inside a pollImmediate loop, so it should
return the error instead of fail.
This commit is contained in:
Antonio Ojea
2021-01-08 10:52:49 +01:00
parent d1db90ba57
commit 6bedf4a98b
2 changed files with 16 additions and 11 deletions

View File

@@ -37,19 +37,20 @@ import (
const secondNodePortSvcName = "second-node-port-service"
// GetHTTPContent returns the content of the given url by HTTP.
func GetHTTPContent(host string, port int, timeout time.Duration, url string) bytes.Buffer {
func GetHTTPContent(host string, port int, timeout time.Duration, url string) (string, error) {
var body bytes.Buffer
if pollErr := wait.PollImmediate(framework.Poll, timeout, func() (bool, error) {
pollErr := wait.PollImmediate(framework.Poll, timeout, func() (bool, error) {
result := e2enetwork.PokeHTTP(host, port, url, nil)
if result.Status == e2enetwork.HTTPSuccess {
body.Write(result.Body)
return true, nil
}
return false, nil
}); pollErr != nil {
framework.Failf("Could not reach HTTP service through %v:%v%v after %v: %v", host, port, url, timeout, pollErr)
})
if pollErr != nil {
framework.Logf("Could not reach HTTP service through %v:%v%v after %v: %v", host, port, url, timeout, pollErr)
}
return body
return body.String(), pollErr
}
// GetHTTPContentFromTestContainer returns the content of the given url by HTTP via a test container.