From 49b1da3ae9fd5f49269b8e5486fd1823978a5e9a Mon Sep 17 00:00:00 2001 From: Ian Cardoso Date: Thu, 1 Jun 2023 11:50:32 -0300 Subject: [PATCH] fix AfterSuite Signed-off-by: Ian Cardoso --- .../privateregistry/privateregistry_test.go | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/tests/e2e/privateregistry/privateregistry_test.go b/tests/e2e/privateregistry/privateregistry_test.go index 2b779de00882..1018ffa0a2d9 100644 --- a/tests/e2e/privateregistry/privateregistry_test.go +++ b/tests/e2e/privateregistry/privateregistry_test.go @@ -86,14 +86,12 @@ var _ = Describe("Verify Create", Ordered, func() { It("Create new private registry", func() { registry, err := e2e.RunCmdOnNode("sudo docker run -d -p 5000:5000 --restart=always --name registry registry:2 ", serverNodeNames[0]) - fmt.Println(registry) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), registry) }) It("ensures registry is working", func() { a, err := e2e.RunCmdOnNode("sudo docker ps -a | grep registry\n", serverNodeNames[0]) - fmt.Println(a) - Expect(err).NotTo(HaveOccurred()) + Expect(err).NotTo(HaveOccurred(), a) }) It("Should pull and image from dockerhub and send it to private registry", func() { @@ -101,25 +99,21 @@ var _ = Describe("Verify Create", Ordered, func() { _, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) - nodeIP, err := e2e.FetchNodeExternalIP(serverNodeNames[0]) - Expect(err).NotTo(HaveOccurred()) - - cmd = "sudo docker tag nginx " + nodeIP + ":5000/my-webpage" + cmd = "sudo docker tag nginx server-0.local:5000/my-webpage" _, err = e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) - cmd = "sudo docker push " + nodeIP + ":5000/my-webpage" + cmd = "sudo docker push server-0.local:5000/my-webpage" _, err = e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) - cmd = "sudo docker image remove nginx " + nodeIP + ":5000/my-webpage" + cmd = "sudo docker image remove nginx server-0.local:5000/my-webpage" _, err = e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) }) It("Should create and validate deployment with private registry on", func() { - res, err := e2e.RunCmdOnNode("sudo kubectl create deployment my-webpage --image=my-registry.local/my-webpage", serverNodeNames[0]) - fmt.Println(res) - Expect(err).NotTo(HaveOccurred()) + res, err := e2e.RunCmdOnNode("sudo kubectl create deployment my-webpage --image=server-0.local/my-webpage", serverNodeNames[0]) + Expect(err).NotTo(HaveOccurred(), res) var pod e2e.Pod Eventually(func(g Gomega) { @@ -147,15 +141,13 @@ var _ = AfterEach(func() { }) var _ = AfterSuite(func() { - r1, err := e2e.RunCmdOnNode("sudo docker rm -f registry", serverNodeNames[0]) - fmt.Println(r1) - Expect(err).NotTo(HaveOccurred()) - r2, err := e2e.RunCmdOnNode("sudo kubectl delete deployment my-webpage", serverNodeNames[0]) - fmt.Println(r2) - Expect(err).NotTo(HaveOccurred()) if failed && !*ci { fmt.Println("FAILED!") } else { + rm1, err := e2e.RunCmdOnNode("sudo docker rm -f registry", serverNodeNames[0]) + Expect(err).NotTo(HaveOccurred(), rm1) + rm2, err := e2e.RunCmdOnNode("sudo kubectl delete deployment my-webpage", serverNodeNames[0]) + Expect(err).NotTo(HaveOccurred(), rm2) Expect(e2e.DestroyCluster()).To(Succeed()) Expect(os.Remove(kubeConfigFile)).To(Succeed()) }