Commit 0609b9e7 authored by Quinton Hoole's avatar Quinton Hoole

Merge pull request #6712 from quinton-hoole/2015-04-10-remove-hostip-check-from-rc-e2e

Remove check for host IP from e2e test for replication controller
parents ad59fb5e 4e799837
...@@ -24,7 +24,9 @@ import ( ...@@ -24,7 +24,9 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubectl"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -126,7 +128,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) { ...@@ -126,7 +128,7 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
By("Ensuring each pod is running and has a hostIP") By("Ensuring each pod is running")
// Wait for the pods to enter the running state. Waiting loops until the pods // Wait for the pods to enter the running state. Waiting loops until the pods
// are running so non-running pods cause a timeout for this test. // are running so non-running pods cause a timeout for this test.
...@@ -135,35 +137,43 @@ func ServeImageOrFail(c *client.Client, test string, image string) { ...@@ -135,35 +137,43 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
} }
// Try to make sure we get a hostIP for each pod. // Verify that something is listening.
hostIPTimeout := 2 * time.Minute By("Trying to dial each unique pod")
t = time.Now() retryTimeout := 2 * time.Minute
for i, pod := range pods.Items { retryInterval := 5 * time.Second
for { err = wait.Poll(retryInterval, retryTimeout, responseChecker{c, ns, label, name, pods}.checkAllResponses)
p, err := c.Pods(ns).Get(pod.Name) if err != nil {
Expect(err).NotTo(HaveOccurred()) Failf("Did not get expected responses within the timeout period of %.2f seconds.", retryTimeout.Seconds())
if p.Status.HostIP != "" {
Logf("Controller %s: Replica %d has hostIP: %s", name, i+1, p.Status.HostIP)
break
}
if time.Since(t) >= hostIPTimeout {
Failf("Controller %s: Gave up waiting for hostIP of replica %d after %v seconds",
name, i, time.Since(t).Seconds())
} }
Logf("Controller %s: Retrying to get the hostIP of replica %d", name, i+1) }
time.Sleep(5 * time.Second)
func isElementOf(podUID types.UID, pods *api.PodList) bool {
for _, pod := range pods.Items {
if pod.UID == podUID {
return true
} }
} }
return false
}
// Re-fetch the pod information to update the host port information. type responseChecker struct {
pods, err = c.Pods(ns).List(label) c *client.Client
Expect(err).NotTo(HaveOccurred()) ns string
label labels.Selector
// Verify that something is listening. controllerName string
By("Trying to dial each unique pod") pods *api.PodList
}
for i, pod := range pods.Items { func (r responseChecker) checkAllResponses() (done bool, err error) {
body, err := c.Get(). successes := 0
currentPods, err := r.c.Pods(r.ns).List(r.label)
Expect(err).NotTo(HaveOccurred())
for i, pod := range r.pods.Items {
// Check that the replica list remains unchanged, otherwise we have problems.
if !isElementOf(pod.UID, currentPods) {
return false, fmt.Errorf("Pod with UID %s is no longer a member of the replica set. Must have been restarted for some reason. Current replica set: %v", pod.UID, currentPods)
}
body, err := r.c.Get().
Prefix("proxy"). Prefix("proxy").
Namespace(api.NamespaceDefault). Namespace(api.NamespaceDefault).
Resource("pods"). Resource("pods").
...@@ -171,12 +181,19 @@ func ServeImageOrFail(c *client.Client, test string, image string) { ...@@ -171,12 +181,19 @@ func ServeImageOrFail(c *client.Client, test string, image string) {
Do(). Do().
Raw() Raw()
if err != nil { if err != nil {
Failf("Controller %s: Failed to GET from replica %d: %v", name, i+1, err) Logf("Controller %s: Failed to GET from replica %d (%s): %v:", r.controllerName, i+1, pod.Name, err)
continue
} }
// The body should be the pod name. // The body should be the pod name.
if string(body) != pod.Name { if string(body) != pod.Name {
Failf("Controller %s: Replica %d expected response %s but got %s", name, i+1, pod.Name, string(body)) Logf("Controller %s: Replica %d expected response %s but got %s", r.controllerName, i+1, pod.Name, string(body))
continue
}
successes++
Logf("Controller %s: Got expected result from replica %d: %s, %d of %d required successes so far", r.controllerName, i+1, string(body), successes, len(r.pods.Items))
} }
Logf("Controller %s: Got expected result from replica %d: %s", name, i+1, string(body)) if successes < len(r.pods.Items) {
return false, nil
} }
return true, nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment