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 abd3a9efad7..d006bec43aa 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 @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) 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 b7893df00df..cc26cf65037 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 @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) 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 0f32b3408ea..daad17105f1 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 @@ -255,18 +255,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole={{ .ProjectName}}-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -276,18 +273,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) diff --git a/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go b/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go index 9c6095b56c1..1de800a001b 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go +++ b/testdata/project-v4-multigroup-with-deploy-image/test/e2e/e2e_test.go @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-v4-multigroup-with-deploy-image-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) diff --git a/testdata/project-v4-multigroup/test/e2e/e2e_test.go b/testdata/project-v4-multigroup/test/e2e/e2e_test.go index fb396885421..b54416080e6 100644 --- a/testdata/project-v4-multigroup/test/e2e/e2e_test.go +++ b/testdata/project-v4-multigroup/test/e2e/e2e_test.go @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-v4-multigroup-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) diff --git a/testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go b/testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go index f48626f98af..169bc170e2a 100644 --- a/testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go +++ b/testdata/project-v4-with-deploy-image/test/e2e/e2e_test.go @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-v4-with-deploy-image-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) diff --git a/testdata/project-v4-with-grafana/test/e2e/e2e_test.go b/testdata/project-v4-with-grafana/test/e2e/e2e_test.go index 577e32bc9b6..0802996ee85 100644 --- a/testdata/project-v4-with-grafana/test/e2e/e2e_test.go +++ b/testdata/project-v4-with-grafana/test/e2e/e2e_test.go @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-v4-with-grafana-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed()) diff --git a/testdata/project-v4/test/e2e/e2e_test.go b/testdata/project-v4/test/e2e/e2e_test.go index c700fcd9f74..9a2bef28adc 100644 --- a/testdata/project-v4/test/e2e/e2e_test.go +++ b/testdata/project-v4/test/e2e/e2e_test.go @@ -122,18 +122,15 @@ var _ = Describe("Manager", Ordered, func() { "--clusterrole=project-v4-metrics-reader", fmt.Sprintf("--serviceaccount=%s:%s", namespace, serviceAccountName), ) - _, err := utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create ClusterRoleBinding") By("validating that the metrics service is available") cmd = exec.Command("kubectl", "get", "service", metricsServiceName, "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "Metrics service should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Metrics service should exist") By("validating that the ServiceMonitor for Prometheus is applied in the namespace") cmd = exec.Command("kubectl", "get", "ServiceMonitor", "-n", namespace) - _, err = utils.Run(cmd) - Expect(err).NotTo(HaveOccurred(), "ServiceMonitor should exist") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "ServiceMonitor should exist") By("getting the service account token") token, err := serviceAccountToken() @@ -143,18 +140,14 @@ var _ = Describe("Manager", Ordered, func() { By("waiting for the metrics endpoint to be ready") verifyMetricsEndpointReady := func(g Gomega) { cmd := exec.Command("kubectl", "get", "endpoints", metricsServiceName, "-n", namespace) - output, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve endpoints information") - g.Expect(string(output)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") + g.Expect(utils.Run(cmd)).To(ContainSubstring("8443"), "Metrics endpoint is not ready") } Eventually(verifyMetricsEndpointReady).Should(Succeed()) By("verifying that the controller manager is serving the metrics server") verifyMetricsServerStarted := func(g Gomega) { cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace) - logs, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller manager logs") - g.Expect(string(logs)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), + g.Expect(utils.Run(cmd)).To(ContainSubstring("controller-runtime.metrics\tServing metrics server"), "Metrics server not yet started") } Eventually(verifyMetricsServerStarted).Should(Succeed())