diff --git a/tests/e2e/autoimport/autoimport_test.go b/tests/e2e/autoimport/autoimport_test.go index 98f506fed9..f530d7c91a 100644 --- a/tests/e2e/autoimport/autoimport_test.go +++ b/tests/e2e/autoimport/autoimport_test.go @@ -91,12 +91,12 @@ var _ = Describe("Verify Create", Ordered, func() { }) It("Create file for auto import and search in the image store", func() { - cmd := `echo docker.io/library/hello-world:latest | sudo tee /var/lib/rancher/k3s/agent/images/testautoimport.txt` + cmd := `echo docker.io/library/redis:latest | sudo tee /var/lib/rancher/k3s/agent/images/testautoimport.txt` _, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) Eventually(func(g Gomega) { - cmd := `k3s ctr images list | grep 'library/hello-world'` + cmd := `k3s ctr images list | grep library/redis` g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.import=testautoimport.txt")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.pinned=pinned")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cri-containerd.pinned=pinned")) @@ -109,7 +109,7 @@ var _ = Describe("Verify Create", Ordered, func() { Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) Eventually(func(g Gomega) { - cmd := `k3s ctr images list | grep 'library/hello-world'` + cmd := `k3s ctr images list | grep library/redis` g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.import=testautoimportrename.txt")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.pinned=pinned")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cri-containerd.pinned=pinned")) @@ -122,7 +122,7 @@ var _ = Describe("Verify Create", Ordered, func() { Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) Eventually(func(g Gomega) { - cmd := `k3s ctr images list | grep 'k3s'` + cmd := `k3s ctr images list | grep library/busybox` g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.import=bb.txt")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.pinned=pinned")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cri-containerd.pinned=pinned")) @@ -133,7 +133,7 @@ var _ = Describe("Verify Create", Ordered, func() { Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) Eventually(func(g Gomega) { - cmd := `k3s ctr images list | grep 'k3s'` + cmd := `k3s ctr images list | grep library/busybox` g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).ShouldNot(ContainSubstring("io.cattle.k3s.import=bb.txt")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.pinned=pinned")) g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cri-containerd.pinned=pinned")) @@ -182,16 +182,6 @@ var _ = Describe("Verify Create", Ordered, func() { for _, node := range nodes { g.Expect(node.Status).Should(Equal("Ready")) } - pods, _ := e2e.ParsePods(kubeConfigFile, false) - count := e2e.CountOfStringInSlice("test-daemonset", pods) - g.Expect(len(nodes)).Should((Equal(count)), "Daemonset pod count does not match node count") - podsRunningAr := 0 - for _, pod := range pods { - if strings.Contains(pod.Name, "test-daemonset") && pod.Status == "Running" && pod.Ready == "1/1" { - podsRunningAr++ - } - } - g.Expect(len(nodes)).Should((Equal(podsRunningAr)), "Daemonset pods are not running after the restart") }, "620s", "5s").Should(Succeed()) }) @@ -208,6 +198,13 @@ var _ = Describe("Verify Create", Ordered, func() { cmd := `rm /var/lib/rancher/k3s/agent/images/bb.txt` _, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) Expect(err).NotTo(HaveOccurred(), "failed: "+cmd) + + Eventually(func(g Gomega) { + cmd := `k3s ctr images list | grep library/busybox` + g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).ShouldNot(ContainSubstring("io.cattle.k3s.import=bb.txt")) + g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cattle.k3s.pinned=pinned")) + g.Expect(e2e.RunCmdOnNode(cmd, serverNodeNames[0])).Should(ContainSubstring("io.cri-containerd.pinned=pinned")) + }, "620s", "5s").Should(Succeed()) }) It("Restarts normally", func() { @@ -220,16 +217,6 @@ var _ = Describe("Verify Create", Ordered, func() { for _, node := range nodes { g.Expect(node.Status).Should(Equal("Ready")) } - pods, _ := e2e.ParsePods(kubeConfigFile, false) - count := e2e.CountOfStringInSlice("test-daemonset", pods) - g.Expect(len(nodes)).Should((Equal(count)), "Daemonset pod count does not match node count") - podsRunningAr := 0 - for _, pod := range pods { - if strings.Contains(pod.Name, "test-daemonset") && pod.Status == "Running" && pod.Ready == "1/1" { - podsRunningAr++ - } - } - g.Expect(len(nodes)).Should((Equal(podsRunningAr)), "Daemonset pods are not running after the restart") }, "620s", "5s").Should(Succeed()) })