Fix integration test failure message

The error message should be printf style, not just concatenated. The
current message is garbled if the command or result contains things that
look like formatting directives:

`Internal error occurred: error sending request: Post "https://10.10.10.102:10250/exec/default/volume-test/volume-test?command=sh&command=-c&command=echo+local-path-test+%!!(MISSING)E(MISSING)+%!!(MISSING)F(MISSING)data%!!(MISSING)F(MISSING)test&error=1&output=1": proxy error from 127.0.0.1:6443 while dialing 10.10.10.102:10250, code 502: 502 Bad Gateway`

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
pull/11430/head
Brad Davidson 2024-11-22 18:11:41 +00:00 committed by Brad Davidson
parent 81dda9d626
commit 45195e2654
2 changed files with 14 additions and 14 deletions

View File

@ -95,7 +95,7 @@ var _ = Describe("Verify snapshots and cluster restores work", Ordered, func() {
cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-clusterip --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-clusterip --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
g.Expect(res).Should((ContainSubstring("test-clusterip")), "failed cmd: "+cmd+" result: "+res) g.Expect(res).Should((ContainSubstring("test-clusterip")), "failed cmd: %q result: %s", cmd, res)
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
}) })

View File

@ -95,7 +95,7 @@ var _ = Describe("Verify Create", Ordered, func() {
cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-clusterip --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-clusterip --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
g.Expect(res).Should((ContainSubstring("test-clusterip")), "failed cmd: "+cmd+" result: "+res) g.Expect(res).Should((ContainSubstring("test-clusterip")), "failed cmd: %q result: %s", cmd, res)
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
clusterip, _ := e2e.FetchClusterIP(kubeConfigFile, "nginx-clusterip-svc", false) clusterip, _ := e2e.FetchClusterIP(kubeConfigFile, "nginx-clusterip-svc", false)
@ -130,7 +130,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("test-nodeport")) g.Expect(res).Should(ContainSubstring("test-nodeport"))
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
} }
@ -150,14 +150,14 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-loadbalancer --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile cmd := "kubectl get pods -o=name -l k8s-app=nginx-app-loadbalancer --field-selector=status.phase=Running --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("test-loadbalancer")) g.Expect(res).Should(ContainSubstring("test-loadbalancer"))
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd = "curl -L --insecure http://" + ip + ":" + port + "/name.html" cmd = "curl -L --insecure http://" + ip + ":" + port + "/name.html"
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("test-loadbalancer")) g.Expect(res).Should(ContainSubstring("test-loadbalancer"))
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
} }
@ -174,7 +174,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("test-ingress")) g.Expect(res).Should(ContainSubstring("test-ingress"))
}, "240s", "5s").Should(Succeed()) }, "240s", "5s").Should(Succeed())
} }
@ -204,7 +204,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd := "kubectl get pods dnsutils --kubeconfig=" + kubeConfigFile cmd := "kubectl get pods dnsutils --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("dnsutils")) g.Expect(res).Should(ContainSubstring("dnsutils"))
}, "420s", "2s").Should(Succeed()) }, "420s", "2s").Should(Succeed())
@ -212,7 +212,7 @@ var _ = Describe("Verify Create", Ordered, func() {
cmd := "kubectl --kubeconfig=" + kubeConfigFile + " exec -i -t dnsutils -- nslookup kubernetes.default" cmd := "kubectl --kubeconfig=" + kubeConfigFile + " exec -i -t dnsutils -- nslookup kubernetes.default"
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("kubernetes.default.svc.cluster.local")) g.Expect(res).Should(ContainSubstring("kubernetes.default.svc.cluster.local"))
}, "420s", "2s").Should(Succeed()) }, "420s", "2s").Should(Succeed())
}) })
@ -224,7 +224,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd := "kubectl get pvc local-path-pvc --kubeconfig=" + kubeConfigFile cmd := "kubectl get pvc local-path-pvc --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("local-path-pvc")) g.Expect(res).Should(ContainSubstring("local-path-pvc"))
g.Expect(res).Should(ContainSubstring("Bound")) g.Expect(res).Should(ContainSubstring("Bound"))
}, "420s", "2s").Should(Succeed()) }, "420s", "2s").Should(Succeed())
@ -232,18 +232,18 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd := "kubectl get pod volume-test --kubeconfig=" + kubeConfigFile cmd := "kubectl get pod volume-test --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("volume-test")) g.Expect(res).Should(ContainSubstring("volume-test"))
g.Expect(res).Should(ContainSubstring("Running")) g.Expect(res).Should(ContainSubstring("Running"))
}, "420s", "2s").Should(Succeed()) }, "420s", "2s").Should(Succeed())
cmd := "kubectl --kubeconfig=" + kubeConfigFile + " exec volume-test -- sh -c 'echo local-path-test > /data/test'" cmd := "kubectl --kubeconfig=" + kubeConfigFile + " exec volume-test -- sh -c 'echo local-path-test > /data/test'"
res, err = e2e.RunCommand(cmd) res, err = e2e.RunCommand(cmd)
Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
cmd = "kubectl delete pod volume-test --kubeconfig=" + kubeConfigFile cmd = "kubectl delete pod volume-test --kubeconfig=" + kubeConfigFile
res, err = e2e.RunCommand(cmd) res, err = e2e.RunCommand(cmd)
Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
_, err = e2e.DeployWorkload("local-path-provisioner.yaml", kubeConfigFile, *hardened) _, err = e2e.DeployWorkload("local-path-provisioner.yaml", kubeConfigFile, *hardened)
Expect(err).NotTo(HaveOccurred(), "local-path-provisioner manifest not deployed") Expect(err).NotTo(HaveOccurred(), "local-path-provisioner manifest not deployed")
@ -257,7 +257,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd := "kubectl get pod volume-test --kubeconfig=" + kubeConfigFile cmd := "kubectl get pod volume-test --kubeconfig=" + kubeConfigFile
res, err := e2e.RunCommand(cmd) res, err := e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
g.Expect(res).Should(ContainSubstring("volume-test")) g.Expect(res).Should(ContainSubstring("volume-test"))
g.Expect(res).Should(ContainSubstring("Running")) g.Expect(res).Should(ContainSubstring("Running"))
@ -266,7 +266,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
cmd := "kubectl exec volume-test --kubeconfig=" + kubeConfigFile + " -- cat /data/test" cmd := "kubectl exec volume-test --kubeconfig=" + kubeConfigFile + " -- cat /data/test"
res, err = e2e.RunCommand(cmd) res, err = e2e.RunCommand(cmd)
g.Expect(err).NotTo(HaveOccurred(), "failed cmd: "+cmd+" result: "+res) g.Expect(err).NotTo(HaveOccurred(), "failed cmd: %q result: %s", cmd, res)
fmt.Println("Data after re-creation", res) fmt.Println("Data after re-creation", res)
g.Expect(res).Should(ContainSubstring("local-path-test")) g.Expect(res).Should(ContainSubstring("local-path-test"))
}, "180s", "2s").Should(Succeed()) }, "180s", "2s").Should(Succeed())