Merge pull request #95831 from cpanato/fix-test-flaky

use patch instead of replace to test the dry-run option
This commit is contained in:
Kubernetes Prow Robot 2020-11-03 13:28:03 -08:00 committed by GitHub
commit 7e1f4a9fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

@ -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

View File

@ -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{})