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 62a5a412f15..b3c5947ea1c 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 @@ -72,18 +72,15 @@ var _ = Describe("Manager", Ordered, func() { BeforeAll(func() { By("creating manager namespace") cmd := exec.Command("kubectl", "create", "ns", namespace) - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to create namespace") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") By("installing CRDs") cmd = exec.Command("make", "install") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to install CRDs") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to deploy the controller-manager") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") }) // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, @@ -111,7 +108,7 @@ var _ = Describe("Manager", Ordered, func() { var controllerPodName string It("should run successfully", func() { By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func() error { + verifyControllerUp := func(g Gomega) { // Get the name of the controller-manager pod cmd := exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", @@ -123,28 +120,21 @@ var _ = Describe("Manager", Ordered, func() { ) podOutput, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") + g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") podNames := utils.GetNonEmptyLines(string(podOutput)) - if len(podNames) != 1 { - return fmt.Errorf("expected 1 controller pod running, but got %d", len(podNames)) - } + g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] - ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) + g.ExpectWithOffset(controllerPodName).To(ContainSubstring("controller-manager")) // Validate the pod's status cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - status, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod status") - if string(status) != "Running" { - return fmt.Errorf("controller pod in %s status", status) - } - return nil + 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. - EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed()) + Eventually(verifyControllerUp, time.Minute, time.Second).Should(Succeed()) }) It("should ensure the metrics endpoint is serving metrics", func() { @@ -203,9 +193,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - status, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(status).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) } Eventually(verifyCurlUp).WithTimeout(5 * time.Minute).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 a717c77c26d..e284029169f 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 @@ -48,18 +48,15 @@ var _ = Describe("Manager", Ordered, func() { BeforeAll(func() { By("creating manager namespace") cmd := exec.Command("kubectl", "create", "ns", namespace) - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to create namespace") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") By("installing CRDs") cmd = exec.Command("make", "install") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to install CRDs") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to deploy the controller-manager") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") }) // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, @@ -87,7 +84,7 @@ var _ = Describe("Manager", Ordered, func() { var controllerPodName string It("should run successfully", func() { By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func() error { + verifyControllerUp := func(g Gomega) { // Get the name of the controller-manager pod cmd := exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", @@ -99,28 +96,21 @@ var _ = Describe("Manager", Ordered, func() { ) podOutput, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") + g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") podNames := utils.GetNonEmptyLines(string(podOutput)) - if len(podNames) != 1 { - return fmt.Errorf("expected 1 controller pod running, but got %d", len(podNames)) - } + g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] - ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) + g.ExpectWithOffset(controllerPodName).To(ContainSubstring("controller-manager")) // Validate the pod's status cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - status, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod status") - if string(status) != "Running" { - return fmt.Errorf("controller pod in %s status", status) - } - return nil + 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. - EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed()) + Eventually(verifyControllerUp, time.Minute, time.Second).Should(Succeed()) }) It("should ensure the metrics endpoint is serving metrics", func() { @@ -179,9 +169,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - status, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(status).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) } Eventually(verifyCurlUp).WithTimeout(5 * time.Minute).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 463658cac4b..e08996f3a87 100644 --- a/testdata/project-v4-multigroup/test/e2e/e2e_test.go +++ b/testdata/project-v4-multigroup/test/e2e/e2e_test.go @@ -48,18 +48,15 @@ var _ = Describe("Manager", Ordered, func() { BeforeAll(func() { By("creating manager namespace") cmd := exec.Command("kubectl", "create", "ns", namespace) - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to create namespace") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") By("installing CRDs") cmd = exec.Command("make", "install") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to install CRDs") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to deploy the controller-manager") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") }) // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, @@ -87,7 +84,7 @@ var _ = Describe("Manager", Ordered, func() { var controllerPodName string It("should run successfully", func() { By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func() error { + verifyControllerUp := func(g Gomega) { // Get the name of the controller-manager pod cmd := exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", @@ -99,28 +96,21 @@ var _ = Describe("Manager", Ordered, func() { ) podOutput, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") + g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") podNames := utils.GetNonEmptyLines(string(podOutput)) - if len(podNames) != 1 { - return fmt.Errorf("expected 1 controller pod running, but got %d", len(podNames)) - } + g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] - ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) + g.ExpectWithOffset(controllerPodName).To(ContainSubstring("controller-manager")) // Validate the pod's status cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - status, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod status") - if string(status) != "Running" { - return fmt.Errorf("controller pod in %s status", status) - } - return nil + 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. - EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed()) + Eventually(verifyControllerUp, time.Minute, time.Second).Should(Succeed()) }) It("should ensure the metrics endpoint is serving metrics", func() { @@ -179,9 +169,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - status, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(status).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) } Eventually(verifyCurlUp).WithTimeout(5 * time.Minute).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 1f88caab4be..a0d8f961f47 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 @@ -48,18 +48,15 @@ var _ = Describe("Manager", Ordered, func() { BeforeAll(func() { By("creating manager namespace") cmd := exec.Command("kubectl", "create", "ns", namespace) - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to create namespace") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") By("installing CRDs") cmd = exec.Command("make", "install") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to install CRDs") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to deploy the controller-manager") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") }) // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, @@ -87,7 +84,7 @@ var _ = Describe("Manager", Ordered, func() { var controllerPodName string It("should run successfully", func() { By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func() error { + verifyControllerUp := func(g Gomega) { // Get the name of the controller-manager pod cmd := exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", @@ -99,28 +96,21 @@ var _ = Describe("Manager", Ordered, func() { ) podOutput, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") + g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") podNames := utils.GetNonEmptyLines(string(podOutput)) - if len(podNames) != 1 { - return fmt.Errorf("expected 1 controller pod running, but got %d", len(podNames)) - } + g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] - ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) + g.ExpectWithOffset(controllerPodName).To(ContainSubstring("controller-manager")) // Validate the pod's status cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - status, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod status") - if string(status) != "Running" { - return fmt.Errorf("controller pod in %s status", status) - } - return nil + 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. - EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed()) + Eventually(verifyControllerUp, time.Minute, time.Second).Should(Succeed()) }) It("should ensure the metrics endpoint is serving metrics", func() { @@ -172,16 +162,14 @@ var _ = Describe("Manager", Ordered, func() { "--", "/bin/sh", "-c", fmt.Sprintf( "curl -v -k -H 'Authorization: Bearer %s' https://%s.%s.svc.cluster.local:8443/metrics", token, metricsServiceName, namespace)) - Expect(utils.Run(cmd)).ToNot(BeEmpty(), "Failed to create curl-metrics pod") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create curl-metrics pod") By("waiting for the curl-metrics pod to complete.") verifyCurlUp := func(g Gomega) { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - status, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(status).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) } Eventually(verifyCurlUp).WithTimeout(5 * time.Minute).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 092ef75ddea..f92171dce6c 100644 --- a/testdata/project-v4-with-grafana/test/e2e/e2e_test.go +++ b/testdata/project-v4-with-grafana/test/e2e/e2e_test.go @@ -48,18 +48,15 @@ var _ = Describe("Manager", Ordered, func() { BeforeAll(func() { By("creating manager namespace") cmd := exec.Command("kubectl", "create", "ns", namespace) - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to create namespace") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") By("installing CRDs") cmd = exec.Command("make", "install") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to install CRDs") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to deploy the controller-manager") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") }) // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, @@ -87,7 +84,7 @@ var _ = Describe("Manager", Ordered, func() { var controllerPodName string It("should run successfully", func() { By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func() error { + verifyControllerUp := func(g Gomega) { // Get the name of the controller-manager pod cmd := exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", @@ -99,28 +96,21 @@ var _ = Describe("Manager", Ordered, func() { ) podOutput, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") + g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") podNames := utils.GetNonEmptyLines(string(podOutput)) - if len(podNames) != 1 { - return fmt.Errorf("expected 1 controller pod running, but got %d", len(podNames)) - } + g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] - ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) + g.ExpectWithOffset(controllerPodName).To(ContainSubstring("controller-manager")) // Validate the pod's status cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - status, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod status") - if string(status) != "Running" { - return fmt.Errorf("controller pod in %s status", status) - } - return nil + 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. - EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed()) + Eventually(verifyControllerUp, time.Minute, time.Second).Should(Succeed()) }) It("should ensure the metrics endpoint is serving metrics", func() { @@ -179,9 +169,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - status, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(status).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) } Eventually(verifyCurlUp).WithTimeout(5 * time.Minute).Should(Succeed()) diff --git a/testdata/project-v4/test/e2e/e2e_test.go b/testdata/project-v4/test/e2e/e2e_test.go index bdba09c4644..c1e905fb1b3 100644 --- a/testdata/project-v4/test/e2e/e2e_test.go +++ b/testdata/project-v4/test/e2e/e2e_test.go @@ -48,18 +48,15 @@ var _ = Describe("Manager", Ordered, func() { BeforeAll(func() { By("creating manager namespace") cmd := exec.Command("kubectl", "create", "ns", namespace) - _, err := utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to create namespace") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to create namespace") By("installing CRDs") cmd = exec.Command("make", "install") - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to install CRDs") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to install CRDs") By("deploying the controller-manager") cmd = exec.Command("make", "deploy", fmt.Sprintf("IMG=%s", projectImage)) - _, err = utils.Run(cmd) - ExpectWithOffset(1, err).NotTo(HaveOccurred(), "Failed to deploy the controller-manager") + Expect(utils.Run(cmd)).Error().NotTo(HaveOccurred(), "Failed to deploy the controller-manager") }) // After all tests have been executed, clean up by undeploying the controller, uninstalling CRDs, @@ -87,7 +84,7 @@ var _ = Describe("Manager", Ordered, func() { var controllerPodName string It("should run successfully", func() { By("validating that the controller-manager pod is running as expected") - verifyControllerUp := func() error { + verifyControllerUp := func(g Gomega) { // Get the name of the controller-manager pod cmd := exec.Command("kubectl", "get", "pods", "-l", "control-plane=controller-manager", @@ -99,28 +96,21 @@ var _ = Describe("Manager", Ordered, func() { ) podOutput, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") + g.Expect(err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod information") podNames := utils.GetNonEmptyLines(string(podOutput)) - if len(podNames) != 1 { - return fmt.Errorf("expected 1 controller pod running, but got %d", len(podNames)) - } + g.Expect(podNames).To(HaveLen(1), "expected 1 controller pod running") controllerPodName = podNames[0] - ExpectWithOffset(2, controllerPodName).Should(ContainSubstring("controller-manager")) + g.ExpectWithOffset(controllerPodName).To(ContainSubstring("controller-manager")) // Validate the pod's status cmd = exec.Command("kubectl", "get", "pods", controllerPodName, "-o", "jsonpath={.status.phase}", "-n", namespace, ) - status, err := utils.Run(cmd) - ExpectWithOffset(2, err).NotTo(HaveOccurred(), "Failed to retrieve controller-manager pod status") - if string(status) != "Running" { - return fmt.Errorf("controller pod in %s status", status) - } - return nil + 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. - EventuallyWithOffset(1, verifyControllerUp, time.Minute, time.Second).Should(Succeed()) + Eventually(verifyControllerUp, time.Minute, time.Second).Should(Succeed()) }) It("should ensure the metrics endpoint is serving metrics", func() { @@ -179,9 +169,7 @@ var _ = Describe("Manager", Ordered, func() { cmd := exec.Command("kubectl", "get", "pods", "curl-metrics", "-o", "jsonpath={.status.phase}", "-n", namespace) - status, err := utils.Run(cmd) - g.Expect(err).NotTo(HaveOccurred()) - g.Expect(status).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) + g.Expect(utils.Run(cmd)).To(Equal("Succeeded"), fmt.Sprintf("curl pod in %s status", status)) } Eventually(verifyCurlUp).WithTimeout(5 * time.Minute).Should(Succeed())