Skip to content

Commit

Permalink
fix AfterSuite
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Cardoso <[email protected]>
  • Loading branch information
osodracnai committed Jun 1, 2023
1 parent 35bfd6f commit 49b1da3
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions tests/e2e/privateregistry/privateregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,40 +86,34 @@ 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() {
cmd := "sudo docker pull nginx"
_, 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) {
Expand Down Expand Up @@ -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())
}
Expand Down

0 comments on commit 49b1da3

Please sign in to comment.