Retry 'service unavailable' failures in proxy test

This commit is contained in:
Wojciech Tyczynski 2015-07-13 09:58:18 +02:00
parent 1e2e38ad19
commit 8d98ad7a76

View File

@ -18,6 +18,7 @@ package e2e
import (
"fmt"
"math"
"net/http"
"strings"
"sync"
@ -208,10 +209,19 @@ func nodeProxyTest(f *Framework, version, nodeDest string) {
prefix := "/api/" + version
node, err := pickNode(f.Client)
Expect(err).NotTo(HaveOccurred())
serviceUnavailableErrors := 0
for i := 0; i < proxyAttempts; i++ {
_, status, d, err := doProxy(f, prefix+"/proxy/nodes/"+node+nodeDest)
Expect(err).NotTo(HaveOccurred())
Expect(status).To(Equal(http.StatusOK))
Expect(d).To(BeNumerically("<", 15*time.Second))
if status == http.StatusServiceUnavailable {
Logf("Failed proxying node logs due to service unavailable: %v", err)
time.Sleep(time.Second)
serviceUnavailableErrors++
} else {
Expect(err).NotTo(HaveOccurred())
Expect(status).To(Equal(http.StatusOK))
Expect(d).To(BeNumerically("<", 15*time.Second))
}
}
maxFailures := int(math.Floor(0.1 * float64(proxyAttempts)))
Expect(serviceUnavailableErrors).To(BeNumerically("<", maxFailures))
}