diff --git a/test/conformance/testdata/conformance.yaml b/test/conformance/testdata/conformance.yaml index 5b2c3e97ec7..3879ba3a274 100755 --- a/test/conformance/testdata/conformance.yaml +++ b/test/conformance/testdata/conformance.yaml @@ -1476,9 +1476,9 @@ codename: '[sig-cli] Kubectl client Kubectl server-side dry-run should check if kubectl can dry-run update Pods [Conformance]' description: The command 'kubectl run' must create a pod with the specified image - name. After, the command 'kubectl replace --dry-run=server' should update the - Pod with the new image name and server-side dry-run enabled. The image name must - not change. + name. After, the command 'kubectl patch pod -p {...} --dry-run=server' should + update the Pod with the new image name and server-side dry-run enabled. The image + name must not change. release: v1.19 file: test/e2e/kubectl/kubectl.go - testname: Kubectl, version diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index 8892d6854f3..780d07cbcc9 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -910,7 +910,7 @@ metadata: /* Release: v1.19 Testname: Kubectl, server-side dry-run Pod - Description: The command 'kubectl run' must create a pod with the specified image name. After, the command 'kubectl replace --dry-run=server' should update the Pod with the new image name and server-side dry-run enabled. The image name must not change. + Description: The command 'kubectl run' must create a pod with the specified image name. After, the command 'kubectl patch pod -p {...} --dry-run=server' should update the Pod with the new image name and server-side dry-run enabled. The image name must not change. */ framework.ConformanceIt("should check if kubectl can dry-run update Pods", func() { ginkgo.By("running the image " + httpdImage) @@ -918,12 +918,8 @@ metadata: framework.RunKubectlOrDie(ns, "run", podName, "--image="+httpdImage, "--labels=run="+podName) ginkgo.By("replace the image in the pod with server-side dry-run") - podJSON := framework.RunKubectlOrDie(ns, "get", "pod", podName, "-o", "json") - podJSON = strings.Replace(podJSON, httpdImage, busyboxImage, 1) - if !strings.Contains(podJSON, busyboxImage) { - framework.Failf("Failed replacing image from %s to %s in:\n%s\n", httpdImage, busyboxImage, podJSON) - } - framework.RunKubectlOrDieInput(ns, podJSON, "replace", "-f", "-", "--dry-run=server") + specImage := fmt.Sprintf(`{"spec":{"containers":[{"name": "%s","image": "%s"}]}}`, podName, busyboxImage) + framework.RunKubectlOrDie(ns, "patch", "pod", podName, "-p", specImage, "--dry-run=server") ginkgo.By("verifying the pod " + podName + " has the right image " + httpdImage) pod, err := c.CoreV1().Pods(ns).Get(context.TODO(), podName, metav1.GetOptions{})