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