diff --git a/docs/book/src/cronjob-tutorial/testdata/project/test/e2e/e2e_test.go b/docs/book/src/cronjob-tutorial/testdata/project/test/e2e/e2e_test.go index d006bec43aa..fcfbe51c462 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/test/e2e/e2e_test.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/test/e2e/e2e_test.go @@ -100,7 +100,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -110,7 +110,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) @@ -278,9 +278,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go b/docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go index db4ad3f02f6..9cf28e39780 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go @@ -41,7 +41,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -54,10 +54,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) { diff --git a/docs/book/src/getting-started/testdata/project/test/e2e/e2e_test.go b/docs/book/src/getting-started/testdata/project/test/e2e/e2e_test.go index cc26cf65037..9d05f017cf4 100644 --- a/docs/book/src/getting-started/testdata/project/test/e2e/e2e_test.go +++ b/docs/book/src/getting-started/testdata/project/test/e2e/e2e_test.go @@ -100,7 +100,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -110,7 +110,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) @@ -240,9 +240,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/docs/book/src/getting-started/testdata/project/test/utils/utils.go b/docs/book/src/getting-started/testdata/project/test/utils/utils.go index db4ad3f02f6..9cf28e39780 100644 --- a/docs/book/src/getting-started/testdata/project/test/utils/utils.go +++ b/docs/book/src/getting-started/testdata/project/test/utils/utils.go @@ -41,7 +41,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -54,10 +54,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) { diff --git a/docs/book/src/multiversion-tutorial/testdata/project/test/e2e/e2e_test.go b/docs/book/src/multiversion-tutorial/testdata/project/test/e2e/e2e_test.go index d006bec43aa..fcfbe51c462 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/test/e2e/e2e_test.go +++ b/docs/book/src/multiversion-tutorial/testdata/project/test/e2e/e2e_test.go @@ -100,7 +100,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -110,7 +110,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) @@ -278,9 +278,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go b/docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go index db4ad3f02f6..9cf28e39780 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go +++ b/docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go @@ -41,7 +41,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -54,10 +54,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) { diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/test/e2e/test.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/test/e2e/test.go index daad17105f1..4a73507fe4d 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/test/e2e/test.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/test/e2e/test.go @@ -233,7 +233,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -243,7 +243,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -299,7 +299,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5 * time.Minute).Should(Succeed()) @@ -373,9 +373,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go index fd68964be6f..b4d97b3421b 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/test/utils/utils.go @@ -66,7 +66,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -79,10 +79,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -117,7 +117,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -178,7 +178,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) { diff --git a/test/e2e/utils/kubectl.go b/test/e2e/utils/kubectl.go index dd1d770388a..78d587763c6 100644 --- a/test/e2e/utils/kubectl.go +++ b/test/e2e/utils/kubectl.go @@ -35,7 +35,7 @@ type Kubectl struct { func (k *Kubectl) Command(cmdOptions ...string) (string, error) { cmd := exec.Command("kubectl", cmdOptions...) output, err := k.Run(cmd) - return string(output), err + return output, err } // WithInput is a general func to run kubectl commands with input diff --git a/test/e2e/utils/test_context.go b/test/e2e/utils/test_context.go index d9c561edc5f..ba285613247 100644 --- a/test/e2e/utils/test_context.go +++ b/test/e2e/utils/test_context.go @@ -301,7 +301,7 @@ type CmdContext struct { } // Run executes the provided command within this context -func (cc *CmdContext) Run(cmd *exec.Cmd) ([]byte, error) { +func (cc *CmdContext) Run(cmd *exec.Cmd) (string, error) { cmd.Dir = cc.Dir cmd.Env = append(os.Environ(), cc.Env...) cmd.Stdin = cc.Stdin @@ -309,10 +309,10 @@ func (cc *CmdContext) Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // AllowProjectBeMultiGroup will update the PROJECT file with the information to allow we scaffold diff --git a/test/e2e/v4/plugin_cluster_test.go b/test/e2e/v4/plugin_cluster_test.go index 2a9082365d3..ebab0a93fd3 100644 --- a/test/e2e/v4/plugin_cluster_test.go +++ b/test/e2e/v4/plugin_cluster_test.go @@ -104,7 +104,7 @@ var _ = Describe("kubebuilder", func() { func Run(kbc *utils.TestContext, hasWebhook, isToUseInstaller, hasMetrics bool, hasNetworkPolicies bool) { var controllerPodName string var err error - var output []byte + var output string By("creating manager namespace") err = kbc.CreateManagerNamespace() diff --git a/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go b/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go index 7daa08340f5..2974ec3a409 100644 --- a/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go +++ b/testdata/project-v4-multigroup-with-plugins/test/e2e/e2e_test.go @@ -100,7 +100,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -110,7 +110,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) @@ -278,9 +278,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/testdata/project-v4-multigroup-with-plugins/test/utils/utils.go b/testdata/project-v4-multigroup-with-plugins/test/utils/utils.go index db4ad3f02f6..9cf28e39780 100644 --- a/testdata/project-v4-multigroup-with-plugins/test/utils/utils.go +++ b/testdata/project-v4-multigroup-with-plugins/test/utils/utils.go @@ -41,7 +41,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -54,10 +54,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) { diff --git a/testdata/project-v4-with-plugins/test/e2e/e2e_test.go b/testdata/project-v4-with-plugins/test/e2e/e2e_test.go index 6687582890d..3a15adb6c70 100644 --- a/testdata/project-v4-with-plugins/test/e2e/e2e_test.go +++ b/testdata/project-v4-with-plugins/test/e2e/e2e_test.go @@ -100,7 +100,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -110,7 +110,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) @@ -264,9 +264,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/testdata/project-v4-with-plugins/test/utils/utils.go b/testdata/project-v4-with-plugins/test/utils/utils.go index db4ad3f02f6..9cf28e39780 100644 --- a/testdata/project-v4-with-plugins/test/utils/utils.go +++ b/testdata/project-v4-with-plugins/test/utils/utils.go @@ -41,7 +41,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -54,10 +54,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) { diff --git a/testdata/project-v4/test/e2e/e2e_test.go b/testdata/project-v4/test/e2e/e2e_test.go index 9a2bef28adc..ca5af0d3639 100644 --- a/testdata/project-v4/test/e2e/e2e_test.go +++ b/testdata/project-v4/test/e2e/e2e_test.go @@ -100,7 +100,7 @@ var _ = Describe("Manager", Ordered, func() { podOutput, err := utils.Run(cmd) g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") - podNames := utils.GetNonEmptyLines(string(podOutput)) + podNames := utils.GetNonEmptyLines(podOutput) g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] g.Expect(controllerPodName).To(ContainSubstring("controller-manager")) @@ -110,7 +110,7 @@ var _ = Describe("Manager", Ordered, func() { "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Running"), "Incorrect controller-manager pod status") + g.Expect(utils.Run(cmd)).To(Equal("Running"), "Incorrect controller-manager pod status") } // Repeatedly check if the controller-manager pod is running until it succeeds or times out. Eventually(verifyControllerUp).Should(Succeed()) @@ -166,7 +166,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - g.Expect(utils.Run(cmd)).To(BeEquivalentTo("Succeeded"), "curl pod in wrong status") + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), "curl pod in wrong status") } Eventually(verifyCurlUp, 5*time.Minute).Should(Succeed()) @@ -278,9 +278,9 @@ func getMetricsOutput() string { cmd := exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace) metricsOutput, err := utils.Run(cmd) Expect(err).NotTo(HaveOccurred(), "Failed to retrieve logs from curl pod") - metricsOutputStr := string(metricsOutput) - Expect(metricsOutputStr).To(ContainSubstring("< HTTP/1.1 200 OK")) - return metricsOutputStr + + Expect(metricsOutput).To(ContainSubstring("< HTTP/1.1 200 OK")) + return metricsOutput } // tokenRequest is a simplified representation of the Kubernetes TokenRequest API response, diff --git a/testdata/project-v4/test/utils/utils.go b/testdata/project-v4/test/utils/utils.go index db4ad3f02f6..9cf28e39780 100644 --- a/testdata/project-v4/test/utils/utils.go +++ b/testdata/project-v4/test/utils/utils.go @@ -41,7 +41,7 @@ func warnError(err error) { } // Run executes the provided command within this context -func Run(cmd *exec.Cmd) ([]byte, error) { +func Run(cmd *exec.Cmd) (string, error) { dir, _ := GetProjectDir() cmd.Dir = dir @@ -54,10 +54,10 @@ func Run(cmd *exec.Cmd) ([]byte, error) { _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { - return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) + return "", fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output)) } - return output, nil + return string(output), nil } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool { if err != nil { return false } - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range prometheusCRDs { for _, line := range crdList { if strings.Contains(line, crd) { @@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool { } // Check if any of the Cert Manager CRDs are present - crdList := GetNonEmptyLines(string(output)) + crdList := GetNonEmptyLines(output) for _, crd := range certManagerCRDs { for _, line := range crdList { if strings.Contains(line, crd) {