E2E test for kubectl replace

Fixes #10764
This commit is contained in:
Davanum Srinivas 2016-07-08 16:29:18 -04:00
parent becb3b44e7
commit 87771957d0
No known key found for this signature in database
GPG Key ID: 80D83A796103BF59

View File

@ -1040,6 +1040,54 @@ var _ = framework.KubeDescribe("Kubectl client", func() {
})
})
framework.KubeDescribe("Kubectl replace", func() {
var nsFlag string
var podName string
BeforeEach(func() {
nsFlag = fmt.Sprintf("--namespace=%v", ns)
podName = "e2e-test-nginx-pod"
})
AfterEach(func() {
framework.RunKubectlOrDie("delete", "pods", podName, nsFlag)
})
It("should update a single-container pod's image [Conformance]", func() {
framework.SkipUnlessServerVersionGTE(jobsVersion, c)
By("running the image " + nginxImage)
framework.RunKubectlOrDie("run", podName, "--generator=run-pod/v1", "--image="+nginxImage, "--labels=run="+podName, nsFlag)
By("verifying the pod " + podName + " is running")
label := labels.SelectorFromSet(labels.Set(map[string]string{"run": podName}))
err := framework.WaitForPodsWithLabelRunning(c, ns, label)
if err != nil {
framework.Failf("Failed getting pod %s: %v", podName, err)
}
By("verifying the pod " + podName + " was created")
podJson := framework.RunKubectlOrDie("get", "pod", podName, nsFlag, "-o", "json")
if !strings.Contains(podJson, podName) {
framework.Failf("Failed to find pod %s in [%s]", podName, podJson)
}
By("replace the image in the pod")
podJson = strings.Replace(podJson, nginxImage, busyboxImage, 1)
framework.RunKubectlOrDieInput(podJson, "replace", "-f", "-", nsFlag)
By("verifying the pod " + podName + " has the right image " + busyboxImage)
pod, err := c.Pods(ns).Get(podName)
if err != nil {
framework.Failf("Failed getting deployment %s: %v", podName, err)
}
containers := pod.Spec.Containers
if containers == nil || len(containers) != 1 || containers[0].Image != busyboxImage {
framework.Failf("Failed creating pod with expected image %s", busyboxImage)
}
})
})
framework.KubeDescribe("Kubectl run --rm job", func() {
nsFlag := fmt.Sprintf("--namespace=%v", ns)
jobName := "e2e-test-rm-busybox-job"