mirror of https://github.com/k3s-io/k3s
Add retry logic to http service request in test/e2e/examples.go
parent
769230e735
commit
aa7d009b96
|
@ -37,6 +37,7 @@ const (
|
|||
podListTimeout = time.Minute
|
||||
serverStartTimeout = podStartTimeout + 3*time.Minute
|
||||
dnsReadyTimeout = time.Minute
|
||||
endpointRegisterTimeout = time.Minute
|
||||
)
|
||||
|
||||
const queryDnsPythonTemplate string = `
|
||||
|
@ -161,7 +162,7 @@ var _ = Describe("Examples e2e", func() {
|
|||
forEachPod(c, ns, "component", "flower", func(pod api.Pod) {
|
||||
// Do nothing. just wait for it to be up and running.
|
||||
})
|
||||
content, err := makeHttpRequestToService(c, ns, "flower-service", "/")
|
||||
content, err := makeHttpRequestToService(c, ns, "flower-service", "/", endpointRegisterTimeout)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if !strings.Contains(content, "<title>Celery Flower</title>") {
|
||||
Failf("Flower HTTP request failed")
|
||||
|
@ -388,7 +389,7 @@ var _ = Describe("Examples e2e", func() {
|
|||
err := waitForPodRunningInNamespace(c, "rethinkdb-admin", ns)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
checkDbInstances()
|
||||
content, err := makeHttpRequestToService(c, ns, "rethinkdb-admin", "/")
|
||||
content, err := makeHttpRequestToService(c, ns, "rethinkdb-admin", "/", endpointRegisterTimeout)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
if !strings.Contains(content, "<title>RethinkDB Administration Console</title>") {
|
||||
Failf("RethinkDB console is not running")
|
||||
|
@ -522,8 +523,11 @@ var _ = Describe("Examples e2e", func() {
|
|||
})
|
||||
})
|
||||
|
||||
func makeHttpRequestToService(c *client.Client, ns, service, path string) (string, error) {
|
||||
result, err := c.Get().
|
||||
func makeHttpRequestToService(c *client.Client, ns, service, path string, timeout time.Duration) (string, error) {
|
||||
var result []byte
|
||||
var err error
|
||||
for t := time.Now(); time.Since(t) < timeout; time.Sleep(poll) {
|
||||
result, err = c.Get().
|
||||
Prefix("proxy").
|
||||
Namespace(ns).
|
||||
Resource("services").
|
||||
|
@ -531,6 +535,10 @@ func makeHttpRequestToService(c *client.Client, ns, service, path string) (strin
|
|||
Suffix(path).
|
||||
Do().
|
||||
Raw()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
return string(result), err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue