From 6624273a97603bb9355e9c8a124d2c8d4d01aa3a Mon Sep 17 00:00:00 2001 From: Derek Nola Date: Mon, 18 Mar 2024 14:09:20 -0700 Subject: [PATCH] Fix embeddedmirror test Signed-off-by: Derek Nola --- .github/workflows/e2e.yaml | 4 +++ tests/e2e/embeddedmirror/Vagrantfile | 1 - .../e2e/embeddedmirror/embeddedmirror_test.go | 27 ++++++++++--------- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index cc9ed7e542..5479bfd3c6 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -60,6 +60,10 @@ jobs: with: go-version-file: 'go.mod' cache: false + - name: Install Kubectl + run: | + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl - name: "Download k3s binary" uses: actions/download-artifact@v4 with: diff --git a/tests/e2e/embeddedmirror/Vagrantfile b/tests/e2e/embeddedmirror/Vagrantfile index 05acde5b6e..c2c72e732d 100644 --- a/tests/e2e/embeddedmirror/Vagrantfile +++ b/tests/e2e/embeddedmirror/Vagrantfile @@ -38,7 +38,6 @@ def provision(vm, role, role_num, node_num) if role.include?("server") && role_num == 0 vm.provision "private-registry", type: "shell", inline: writePrivateRegistry - dockerInstall(vm) vm.provision 'k3s-primary-server', type: 'k3s', run: 'once' do |k3s| k3s.args = "server " diff --git a/tests/e2e/embeddedmirror/embeddedmirror_test.go b/tests/e2e/embeddedmirror/embeddedmirror_test.go index c054ac5025..6eb0e92844 100644 --- a/tests/e2e/embeddedmirror/embeddedmirror_test.go +++ b/tests/e2e/embeddedmirror/embeddedmirror_test.go @@ -83,56 +83,60 @@ var _ = Describe("Verify Create", Ordered, func() { _, _ = e2e.ParsePods(kubeConfigFile, true) }) It("Should create and validate deployment with embedded registry mirror using image tag", func() { - res, err := e2e.RunCmdOnNode("kubectl create deployment my-webpage-1 --image=docker.io/library/nginx:1.25.3", serverNodeNames[0]) + res, err := e2e.RunCommand("kubectl create deployment my-webpage-1 --image=docker.io/library/nginx:1.25.3") fmt.Println(res) Expect(err).NotTo(HaveOccurred()) patchCmd := fmt.Sprintf(`kubectl patch deployment my-webpage-1 --patch '{"spec":{"replicas":%d,"revisionHistoryLimit":0,"strategy":{"type":"Recreate", "rollingUpdate": null},"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"app","operator":"In","values":["my-webpage-1"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}}}}'`, *serverCount+*agentCount) - res, err = e2e.RunCmdOnNode(patchCmd, serverNodeNames[0]) + res, err = e2e.RunCommand(patchCmd) fmt.Println(res) Expect(err).NotTo(HaveOccurred()) - res, err = e2e.RunCmdOnNode("kubectl rollout status deployment my-webpage-1 --watch=true --timeout=360s", serverNodeNames[0]) + res, err = e2e.RunCommand("kubectl rollout status deployment my-webpage-1 --watch=true --timeout=360s") fmt.Println(res) Expect(err).NotTo(HaveOccurred()) }) It("Should create and validate deployment with embedded registry mirror using image digest for existing tag", func() { - res, err := e2e.RunCmdOnNode("kubectl create deployment my-webpage-2 --image=docker.io/library/nginx:sha256:9784f7985f6fba493ba30fb68419f50484fee8faaf677216cb95826f8491d2e9", serverNodeNames[0]) + res, err := e2e.RunCommand("kubectl create deployment my-webpage-2 --image=docker.io/library/nginx:nginx@sha256:c7a6ad68be85142c7fe1089e48faa1e7c7166a194caa9180ddea66345876b9d2") fmt.Println(res) Expect(err).NotTo(HaveOccurred()) patchCmd := fmt.Sprintf(`kubectl patch deployment my-webpage-2 --patch '{"spec":{"replicas":%d,"revisionHistoryLimit":0,"strategy":{"type":"Recreate", "rollingUpdate": null},"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"app","operator":"In","values":["my-webpage-2"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}}}}'`, *serverCount+*agentCount) - res, err = e2e.RunCmdOnNode(patchCmd, serverNodeNames[0]) + res, err = e2e.RunCommand(patchCmd) fmt.Println(res) Expect(err).NotTo(HaveOccurred()) - res, err = e2e.RunCmdOnNode("kubectl rollout status deployment my-webpage-2 --watch=true --timeout=360s", serverNodeNames[0]) + res, err = e2e.RunCommand("kubectl rollout status deployment my-webpage-2 --watch=true --timeout=360s") fmt.Println(res) Expect(err).NotTo(HaveOccurred()) }) It("Should create and validate deployment with embedded registry mirror using image digest without corresponding tag", func() { - res, err := e2e.RunCmdOnNode("kubectl create deployment my-webpage-3 --image=docker.io/library/nginx:sha256:b4af4f8b6470febf45dc10f564551af682a802eda1743055a7dfc8332dffa595", serverNodeNames[0]) + res, err := e2e.RunCommand("kubectl create deployment my-webpage-3 --image=docker.io/library/nginx@sha256:b4af4f8b6470febf45dc10f564551af682a802eda1743055a7dfc8332dffa595") fmt.Println(res) Expect(err).NotTo(HaveOccurred()) patchCmd := fmt.Sprintf(`kubectl patch deployment my-webpage-3 --patch '{"spec":{"replicas":%d,"revisionHistoryLimit":0,"strategy":{"type":"Recreate", "rollingUpdate": null},"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"app","operator":"In","values":["my-webpage-3"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}}}}'`, *serverCount+*agentCount) - res, err = e2e.RunCmdOnNode(patchCmd, serverNodeNames[0]) + res, err = e2e.RunCommand(patchCmd) fmt.Println(res) Expect(err).NotTo(HaveOccurred()) - res, err = e2e.RunCmdOnNode("kubectl rollout status deployment my-webpage-3 --watch=true --timeout=360s", serverNodeNames[0]) + res, err = e2e.RunCommand("kubectl rollout status deployment my-webpage-3 --watch=true --timeout=360s") fmt.Println(res) Expect(err).NotTo(HaveOccurred()) }) It("Should expose embedded registry metrics", func() { grepCmd := fmt.Sprintf("kubectl get --raw /api/v1/nodes/%s/proxy/metrics | grep -F 'spegel_advertised_images{registry=\"docker.io\"}'", serverNodeNames[0]) - res, err := e2e.RunCmdOnNode(grepCmd, serverNodeNames[0]) + res, err := e2e.RunCommand(grepCmd) fmt.Println(res) Expect(err).NotTo(HaveOccurred()) }) + It("Should cleanup deployments", func() { + _, err := e2e.RunCommand("kubectl delete deployment my-webpage-1 my-webpage-2 my-webpage-3") + Expect(err).NotTo(HaveOccurred()) + }) }) }) @@ -146,9 +150,6 @@ var _ = AfterSuite(func() { Expect(e2e.GetCoverageReport(append(serverNodeNames, agentNodeNames...))).To(Succeed()) } if !failed || *ci { - r2, err := e2e.RunCmdOnNode("kubectl delete deployment my-webpage-1 my-webpage-2 my-webpage-3", serverNodeNames[0]) - Expect(err).NotTo(HaveOccurred(), r2) - Expect(err).NotTo(HaveOccurred()) Expect(e2e.DestroyCluster()).To(Succeed()) Expect(os.Remove(kubeConfigFile)).To(Succeed()) }