mirror of https://github.com/k3s-io/k3s
Wait for at least 1 endpoint in E2E test for examples
parent
b840357d6f
commit
d5c40479f1
|
@ -34,10 +34,9 @@ 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 = `
|
||||||
|
@ -149,6 +148,8 @@ var _ = Describe("Examples e2e", func() {
|
||||||
_, err := lookForStringInLog(ns, pod.Name, "rabbitmq", "Server startup complete", serverStartTimeout)
|
_, err := lookForStringInLog(ns, pod.Name, "rabbitmq", "Server startup complete", serverStartTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
waitForEndpoint(c, ns, "rabbitmq-service")
|
||||||
|
|
||||||
By("starting celery")
|
By("starting celery")
|
||||||
runKubectl("create", "-f", celeryControllerYaml, nsFlag)
|
runKubectl("create", "-f", celeryControllerYaml, nsFlag)
|
||||||
forEachPod(c, ns, "component", "celery", func(pod api.Pod) {
|
forEachPod(c, ns, "component", "celery", func(pod api.Pod) {
|
||||||
|
@ -192,6 +193,9 @@ var _ = Describe("Examples e2e", func() {
|
||||||
_, err = lookForStringInLog(ns, "spark-driver", "spark-driver", "Use kubectl exec", serverStartTimeout)
|
_, err = lookForStringInLog(ns, "spark-driver", "spark-driver", "Use kubectl exec", serverStartTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
By("waiting for master endpoint")
|
||||||
|
waitForEndpoint(c, ns, "spark-master")
|
||||||
|
|
||||||
By("starting workers")
|
By("starting workers")
|
||||||
runKubectl("create", "-f", workerControllerJson, nsFlag)
|
runKubectl("create", "-f", workerControllerJson, nsFlag)
|
||||||
ScaleRC(c, ns, "spark-worker-controller", 2, true)
|
ScaleRC(c, ns, "spark-worker-controller", 2, true)
|
||||||
|
@ -221,6 +225,8 @@ var _ = Describe("Examples e2e", func() {
|
||||||
_, err = lookForStringInLog(ns, "cassandra", "cassandra", "Listening for thrift clients", serverStartTimeout)
|
_, err = lookForStringInLog(ns, "cassandra", "cassandra", "Listening for thrift clients", serverStartTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
waitForEndpoint(c, ns, "cassandra")
|
||||||
|
|
||||||
By("create and scale rc")
|
By("create and scale rc")
|
||||||
runKubectl("create", "-f", controllerYaml, nsFlag)
|
runKubectl("create", "-f", controllerYaml, nsFlag)
|
||||||
err = ScaleRC(c, ns, "cassandra", 2, true)
|
err = ScaleRC(c, ns, "cassandra", 2, true)
|
||||||
|
@ -263,12 +269,14 @@ var _ = Describe("Examples e2e", func() {
|
||||||
By("checking if zookeeper is up and running")
|
By("checking if zookeeper is up and running")
|
||||||
_, err = lookForStringInLog(ns, zookeeperPod, "zookeeper", "binding to port", serverStartTimeout)
|
_, err = lookForStringInLog(ns, zookeeperPod, "zookeeper", "binding to port", serverStartTimeout)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
waitForEndpoint(c, ns, "zookeeper")
|
||||||
|
|
||||||
By("starting Nimbus")
|
By("starting Nimbus")
|
||||||
runKubectl("create", "-f", nimbusPodJson, nsFlag)
|
runKubectl("create", "-f", nimbusPodJson, nsFlag)
|
||||||
runKubectl("create", "-f", nimbusServiceJson, nsFlag)
|
runKubectl("create", "-f", nimbusServiceJson, nsFlag)
|
||||||
err = waitForPodRunningInNamespace(c, "nimbus", ns)
|
err = waitForPodRunningInNamespace(c, "nimbus", ns)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
waitForEndpoint(c, ns, "nimbus")
|
||||||
|
|
||||||
By("starting workers")
|
By("starting workers")
|
||||||
runKubectl("create", "-f", workerControllerJson, nsFlag)
|
runKubectl("create", "-f", workerControllerJson, nsFlag)
|
||||||
|
@ -382,6 +390,7 @@ var _ = Describe("Examples e2e", func() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
checkDbInstances()
|
checkDbInstances()
|
||||||
|
waitForEndpoint(c, ns, "rethinkdb-driver")
|
||||||
|
|
||||||
By("scaling rethinkdb")
|
By("scaling rethinkdb")
|
||||||
ScaleRC(c, ns, "rethinkdb-rc", 2, true)
|
ScaleRC(c, ns, "rethinkdb-rc", 2, true)
|
||||||
|
@ -420,6 +429,8 @@ var _ = Describe("Examples e2e", func() {
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
waitForEndpoint(c, ns, "hazelcast")
|
||||||
|
|
||||||
By("scaling hazelcast")
|
By("scaling hazelcast")
|
||||||
ScaleRC(c, ns, "hazelcast", 2, true)
|
ScaleRC(c, ns, "hazelcast", 2, true)
|
||||||
forEachPod(c, ns, "name", "hazelcast", func(pod api.Pod) {
|
forEachPod(c, ns, "name", "hazelcast", func(pod api.Pod) {
|
||||||
|
|
|
@ -89,6 +89,7 @@ const (
|
||||||
|
|
||||||
podRespondingTimeout = 2 * time.Minute
|
podRespondingTimeout = 2 * time.Minute
|
||||||
serviceRespondingTimeout = 2 * time.Minute
|
serviceRespondingTimeout = 2 * time.Minute
|
||||||
|
endpointRegisterTimeout = time.Minute
|
||||||
|
|
||||||
// How wide to print pod names, by default. Useful for aligning printing to
|
// How wide to print pod names, by default. Useful for aligning printing to
|
||||||
// quickly scan through output.
|
// quickly scan through output.
|
||||||
|
@ -714,6 +715,20 @@ func waitForReplicationController(c *client.Client, namespace, name string, exis
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func waitForEndpoint(c *client.Client, ns, name string) error {
|
||||||
|
for t := time.Now(); time.Since(t) < endpointRegisterTimeout; time.Sleep(poll) {
|
||||||
|
endpoint, err := c.Endpoints(ns).Get(name)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
if len(endpoint.Subsets) == 0 || len(endpoint.Subsets[0].Addresses) == 0 {
|
||||||
|
Logf("Endpoint %s/%s is not ready yet", ns, name)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("Failed to get entpoints for %s/%s", ns, name)
|
||||||
|
}
|
||||||
|
|
||||||
// Context for checking pods responses by issuing GETs to them and verifying if the answer with pod name.
|
// Context for checking pods responses by issuing GETs to them and verifying if the answer with pod name.
|
||||||
type podResponseChecker struct {
|
type podResponseChecker struct {
|
||||||
c *client.Client
|
c *client.Client
|
||||||
|
|
Loading…
Reference in New Issue