Commit c7bfbe64 authored by pwittrock's avatar pwittrock Committed by pwittrock

Clean up kubectl test to use the blessed e2e test redis configs and to output…

Clean up kubectl test to use the blessed e2e test redis configs and to output debug info when failing. Debugs #25657.
parent 8b59db7b
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -79,6 +79,8 @@ const ( ...@@ -79,6 +79,8 @@ const (
busyboxImage = "gcr.io/google_containers/busybox:1.24" busyboxImage = "gcr.io/google_containers/busybox:1.24"
nginxImage = "gcr.io/google_containers/nginx:1.7.9" nginxImage = "gcr.io/google_containers/nginx:1.7.9"
kubeCtlManifestPath = "test/e2e/testing-manifests/kubectl" kubeCtlManifestPath = "test/e2e/testing-manifests/kubectl"
redisControllerFilename = "redis-master-controller.json"
redisServiceFilename = "redis-master-service.json"
) )
var ( var (
...@@ -129,6 +131,10 @@ func cleanupKubectlInputs(fileContents string, ns string, selectors ...string) { ...@@ -129,6 +131,10 @@ func cleanupKubectlInputs(fileContents string, ns string, selectors ...string) {
framework.AssertCleanup(ns, selectors...) framework.AssertCleanup(ns, selectors...)
} }
func readTestFileOrDie(file string) []byte {
return framework.ReadOrDie(path.Join(kubeCtlManifestPath, file))
}
var _ = framework.KubeDescribe("Kubectl client", func() { var _ = framework.KubeDescribe("Kubectl client", func() {
defer GinkgoRecover() defer GinkgoRecover()
f := framework.NewDefaultFramework("kubectl") f := framework.NewDefaultFramework("kubectl")
...@@ -141,13 +147,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -141,13 +147,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
ValidPhases: []api.PodPhase{api.PodRunning /*api.PodPending*/}, ValidPhases: []api.PodPhase{api.PodRunning /*api.PodPending*/},
}) })
} }
// Customized Wait / ForEach wrapper for this test. These demonstrate the
// idiomatic way to wrap the ClusterVerification structs for syntactic sugar in large
// test files.
waitFor := func(atLeast int) {
// 60 seconds can be flakey for some of the containers.
clusterState().WaitFor(atLeast, 90*time.Second)
}
forEachPod := func(podFunc func(p api.Pod)) { forEachPod := func(podFunc func(p api.Pod)) {
clusterState().ForEach(podFunc) clusterState().ForEach(podFunc)
} }
...@@ -158,6 +158,19 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -158,6 +158,19 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
ns = f.Namespace.Name ns = f.Namespace.Name
}) })
// Customized Wait / ForEach wrapper for this test. These demonstrate the
// idiomatic way to wrap the ClusterVerification structs for syntactic sugar in large
// test files.
// Print debug info if atLeast Pods are not found before the timeout
waitForOrFailWithDebug := func(atLeast int) {
pods, err := clusterState().WaitFor(atLeast, 90*time.Second)
if err != nil || len(pods) < atLeast {
// TODO: Generalize integrating debug info into these tests so we always get debug info when we need it
framework.DumpAllNamespaceInfo(c, ns)
framework.Failf("Verified %v of %v pods , error : %v", len(pods), atLeast, err)
}
}
framework.KubeDescribe("Update Demo", func() { framework.KubeDescribe("Update Demo", func() {
var nautilus, kitten []byte var nautilus, kitten []byte
BeforeEach(func() { BeforeEach(func() {
...@@ -234,7 +247,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -234,7 +247,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
var podPath []byte var podPath []byte
BeforeEach(func() { BeforeEach(func() {
podPath = framework.ReadOrDie("test/e2e/testing-manifests/kubectl/pod-with-readiness-probe.yaml") podPath = framework.ReadOrDie(path.Join(kubeCtlManifestPath, "pod-with-readiness-probe.yaml"))
By(fmt.Sprintf("creating the pod from %v", string(podPath))) By(fmt.Sprintf("creating the pod from %v", string(podPath)))
framework.RunKubectlOrDieInput(string(podPath[:]), "create", "-f", "-", fmt.Sprintf("--namespace=%v", ns)) framework.RunKubectlOrDieInput(string(podPath[:]), "create", "-f", "-", fmt.Sprintf("--namespace=%v", ns))
framework.CheckPodsRunningReady(c, ns, []string{simplePodName}, framework.PodStartTimeout) framework.CheckPodsRunningReady(c, ns, []string{simplePodName}, framework.PodStartTimeout)
...@@ -596,10 +609,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -596,10 +609,8 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
framework.KubeDescribe("Kubectl apply", func() { framework.KubeDescribe("Kubectl apply", func() {
It("should apply a new configuration to an existing RC", func() { It("should apply a new configuration to an existing RC", func() {
mkpath := func(file string) string { controllerJson := readTestFileOrDie(redisControllerFilename)
return "examples/guestbook-go/" + file
}
controllerJson := framework.ReadOrDie(mkpath("redis-master-controller.json"))
nsFlag := fmt.Sprintf("--namespace=%v", ns) nsFlag := fmt.Sprintf("--namespace=%v", ns)
By("creating Redis RC") By("creating Redis RC")
framework.RunKubectlOrDieInput(string(controllerJson), "create", "-f", "-", nsFlag) framework.RunKubectlOrDieInput(string(controllerJson), "create", "-f", "-", nsFlag)
...@@ -612,10 +623,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -612,10 +623,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
forEachReplicationController(c, ns, "app", "redis", validateReplicationControllerConfiguration) forEachReplicationController(c, ns, "app", "redis", validateReplicationControllerConfiguration)
}) })
It("should reuse nodePort when apply to an existing SVC", func() { It("should reuse nodePort when apply to an existing SVC", func() {
mkpath := func(file string) string { serviceJson := readTestFileOrDie(redisServiceFilename)
return "examples/guestbook-go/" + file
}
serviceJson := framework.ReadOrDie(mkpath("redis-master-service.json"))
nsFlag := fmt.Sprintf("--namespace=%v", ns) nsFlag := fmt.Sprintf("--namespace=%v", ns)
By("creating Redis SVC") By("creating Redis SVC")
...@@ -658,19 +666,15 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -658,19 +666,15 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
// Flaky issue: #25083 // Flaky issue: #25083
It("should check if kubectl describe prints relevant information for rc and pods [Conformance] [Flaky]", func() { It("should check if kubectl describe prints relevant information for rc and pods [Conformance] [Flaky]", func() {
framework.SkipUnlessServerVersionGTE(nodePortsOptionalVersion, c) framework.SkipUnlessServerVersionGTE(nodePortsOptionalVersion, c)
controllerJson := readTestFileOrDie(redisControllerFilename)
mkpath := func(file string) string { serviceJson := readTestFileOrDie(redisServiceFilename)
return kubeCtlManifestPath + "/" + file
}
controllerJson := framework.ReadOrDie(mkpath("redis-master-controller.json"))
serviceJson := framework.ReadOrDie(mkpath("redis-master-service.json"))
nsFlag := fmt.Sprintf("--namespace=%v", ns) nsFlag := fmt.Sprintf("--namespace=%v", ns)
framework.RunKubectlOrDieInput(string(controllerJson[:]), "create", "-f", "-", nsFlag) framework.RunKubectlOrDieInput(string(controllerJson[:]), "create", "-f", "-", nsFlag)
framework.RunKubectlOrDieInput(string(serviceJson[:]), "create", "-f", "-", nsFlag) framework.RunKubectlOrDieInput(string(serviceJson[:]), "create", "-f", "-", nsFlag)
By("Waiting for Redis master to start.") By("Waiting for Redis master to start.")
waitFor(1) waitForOrFailWithDebug(1)
// Pod // Pod
forEachPod(func(pod api.Pod) { forEachPod(func(pod api.Pod) {
output := framework.RunKubectlOrDie("describe", "pod", pod.Name, nsFlag) output := framework.RunKubectlOrDie("describe", "pod", pod.Name, nsFlag)
...@@ -761,10 +765,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -761,10 +765,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
framework.KubeDescribe("Kubectl expose", func() { framework.KubeDescribe("Kubectl expose", func() {
It("should create services for rc [Conformance]", func() { It("should create services for rc [Conformance]", func() {
mkpath := func(file string) string { controllerJson := readTestFileOrDie(redisControllerFilename)
return "examples/guestbook-go/" + file
}
controllerJson := framework.ReadOrDie(mkpath("redis-master-controller.json"))
nsFlag := fmt.Sprintf("--namespace=%v", ns) nsFlag := fmt.Sprintf("--namespace=%v", ns)
redisPort := 6379 redisPort := 6379
...@@ -776,7 +777,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -776,7 +777,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
// It may take a while for the pods to get registered in some cases, wait to be sure. // It may take a while for the pods to get registered in some cases, wait to be sure.
By("Waiting for Redis master to start.") By("Waiting for Redis master to start.")
waitFor(1) waitForOrFailWithDebug(1)
forEachPod(func(pod api.Pod) { forEachPod(func(pod api.Pod) {
framework.Logf("wait on redis-master startup in %v ", ns) framework.Logf("wait on redis-master startup in %v ", ns)
framework.LookForStringInLog(ns, pod.Name, "redis-master", "The server is now ready to accept connections", framework.PodStartTimeout) framework.LookForStringInLog(ns, pod.Name, "redis-master", "The server is now ready to accept connections", framework.PodStartTimeout)
...@@ -877,10 +878,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -877,10 +878,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
var nsFlag string var nsFlag string
containerName := "redis-master" containerName := "redis-master"
BeforeEach(func() { BeforeEach(func() {
mkpath := func(file string) string { rc = readTestFileOrDie(redisControllerFilename)
return "examples/guestbook-go/" + file
}
rc = framework.ReadOrDie(mkpath("redis-master-controller.json"))
By("creating an rc") By("creating an rc")
nsFlag = fmt.Sprintf("--namespace=%v", ns) nsFlag = fmt.Sprintf("--namespace=%v", ns)
framework.RunKubectlOrDieInput(string(rc[:]), "create", "-f", "-", nsFlag) framework.RunKubectlOrDieInput(string(rc[:]), "create", "-f", "-", nsFlag)
...@@ -899,7 +897,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -899,7 +897,7 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
} }
By("Waiting for Redis master to start.") By("Waiting for Redis master to start.")
waitFor(1) waitForOrFailWithDebug(1)
forEachPod(func(pod api.Pod) { forEachPod(func(pod api.Pod) {
By("checking for a matching strings") By("checking for a matching strings")
_, err := framework.LookForStringInLog(ns, pod.Name, containerName, "The server is now ready to accept connections", framework.PodStartTimeout) _, err := framework.LookForStringInLog(ns, pod.Name, containerName, "The server is now ready to accept connections", framework.PodStartTimeout)
...@@ -943,15 +941,12 @@ var _ = framework.KubeDescribe("Kubectl client", func() { ...@@ -943,15 +941,12 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
framework.KubeDescribe("Kubectl patch", func() { framework.KubeDescribe("Kubectl patch", func() {
It("should add annotations for pods in rc [Conformance]", func() { It("should add annotations for pods in rc [Conformance]", func() {
mkpath := func(file string) string { controllerJson := readTestFileOrDie(redisControllerFilename)
return "examples/guestbook-go/" + file
}
controllerJson := framework.ReadOrDie(mkpath("redis-master-controller.json"))
nsFlag := fmt.Sprintf("--namespace=%v", ns) nsFlag := fmt.Sprintf("--namespace=%v", ns)
By("creating Redis RC") By("creating Redis RC")
framework.RunKubectlOrDieInput(string(controllerJson[:]), "create", "-f", "-", nsFlag) framework.RunKubectlOrDieInput(string(controllerJson[:]), "create", "-f", "-", nsFlag)
By("Waiting for Redis master to start.") By("Waiting for Redis master to start.")
waitFor(1) waitForOrFailWithDebug(1)
By("patching all pods") By("patching all pods")
forEachPod(func(pod api.Pod) { forEachPod(func(pod api.Pod) {
framework.RunKubectlOrDie("patch", "pod", pod.Name, nsFlag, "-p", "{\"metadata\":{\"annotations\":{\"x\":\"y\"}}}") framework.RunKubectlOrDie("patch", "pod", pod.Name, nsFlag, "-p", "{\"metadata\":{\"annotations\":{\"x\":\"y\"}}}")
......
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