diff --git a/test/e2e/kubectl.go b/test/e2e/kubectl.go index 3baedde6f04..8ca7aa95b2e 100644 --- a/test/e2e/kubectl.go +++ b/test/e2e/kubectl.go @@ -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"