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