diff --git a/.drone.yml b/.drone.yml index e70cb33582f7..4010cf009fa9 100644 --- a/.drone.yml +++ b/.drone.yml @@ -622,6 +622,7 @@ steps: - vagrant destroy -f - go test -v -timeout=30m ./secretsencryption_test.go -ci -local - cd ../upgradecluster + - vagrant destroy -f - E2E_RELEASE_CHANNEL="v1.25" go test -v -timeout=45m ./upgradecluster_test.go -ci -local - docker stop registry && docker rm registry diff --git a/tests/e2e/startup/startup_test.go b/tests/e2e/startup/startup_test.go index 0ea4187b8d61..226e39b11d23 100644 --- a/tests/e2e/startup/startup_test.go +++ b/tests/e2e/startup/startup_test.go @@ -77,17 +77,18 @@ func KillK3sCluster(nodes []string) error { var _ = ReportAfterEach(e2e.GenReport) +var _ = BeforeSuite(func() { + var err error + if *local { + serverNodeNames, agentNodeNames, err = e2e.CreateLocalCluster(*nodeOS, 1, 1) + } else { + serverNodeNames, agentNodeNames, err = e2e.CreateCluster(*nodeOS, 1, 1) + } + Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err)) +}) + var _ = Describe("Various Startup Configurations", Ordered, func() { Context("Verify CRI-Dockerd :", func() { - It("Stands up the nodes", func() { - var err error - if *local { - serverNodeNames, agentNodeNames, err = e2e.CreateLocalCluster(*nodeOS, 1, 1) - } else { - serverNodeNames, agentNodeNames, err = e2e.CreateCluster(*nodeOS, 1, 1) - } - Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err)) - }) It("Starts K3s with no issues", func() { dockerYAML := "docker: true" err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), dockerYAML, dockerYAML) @@ -109,7 +110,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { for _, node := range nodes { g.Expect(node.Status).Should(Equal("Ready")) } - }, "620s", "5s").Should(Succeed()) + }, "360s", "5s").Should(Succeed()) _, _ = e2e.ParseNodes(kubeConfigFile, true) fmt.Printf("\nFetching pods status\n") @@ -123,7 +124,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { g.Expect(pod.Status).Should(Equal("Running"), pod.Name) } } - }, "620s", "5s").Should(Succeed()) + }, "360s", "5s").Should(Succeed()) _, _ = e2e.ParsePods(kubeConfigFile, true) }) It("Kills the cluster", func() { @@ -153,7 +154,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { for _, node := range nodes { g.Expect(node.Status).Should(Equal("Ready")) } - }, "620s", "5s").Should(Succeed()) + }, "360s", "5s").Should(Succeed()) _, _ = e2e.ParseNodes(kubeConfigFile, true) fmt.Printf("\nFetching pods status\n") @@ -167,7 +168,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { g.Expect(pod.Status).Should(Equal("Running"), pod.Name) } } - }, "620s", "5s").Should(Succeed()) + }, "360s", "5s").Should(Succeed()) _, _ = e2e.ParsePods(kubeConfigFile, true) }) It("Kills the cluster", func() { @@ -197,7 +198,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { for _, node := range nodes { g.Expect(node.Status).Should(Equal("Ready")) } - }, "620s", "5s").Should(Succeed()) + }, "360s", "5s").Should(Succeed()) _, _ = e2e.ParseNodes(kubeConfigFile, true) fmt.Printf("\nFetching pods status\n") @@ -211,21 +212,21 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { g.Expect(pod.Status).Should(Equal("Running"), pod.Name) } } - }, "620s", "5s").Should(Succeed()) + }, "360s", "5s").Should(Succeed()) _, _ = e2e.ParsePods(kubeConfigFile, true) }) It("Returns pod metrics", func() { cmd := "kubectl top pod -A" Eventually(func() error { - _, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) + _, err := e2e.RunCommand(cmd) return err - }, "620s", "5s").Should(Succeed()) + }, "600s", "5s").Should(Succeed()) }) It("Returns node metrics", func() { cmd := "kubectl top node" - _, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) + _, err := e2e.RunCommand(cmd) Expect(err).NotTo(HaveOccurred()) }) @@ -237,7 +238,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { It("Collects logs from a pod", func() { cmd := "kubectl logs -n kube-system -l app.kubernetes.io/name=traefik -c traefik" - _, err := e2e.RunCmdOnNode(cmd, serverNodeNames[0]) + _, err := e2e.RunCommand(cmd) Expect(err).NotTo(HaveOccurred()) }) diff --git a/tests/e2e/testutils.go b/tests/e2e/testutils.go index 9c9ec8a96b56..ac642698920c 100644 --- a/tests/e2e/testutils.go +++ b/tests/e2e/testutils.go @@ -303,6 +303,9 @@ func GenKubeConfigFile(serverName string) (string, error) { if err := os.WriteFile(kubeConfigFile, []byte(kubeConfig), 0644); err != nil { return "", err } + if err := os.Setenv("E2E_KUBECONFIG", kubeConfigFile); err != nil { + return "", err + } return kubeConfigFile, nil } @@ -453,9 +456,11 @@ func RunCmdOnNode(cmd string, nodename string) (string, error) { return out, nil } -// RunCommand executes a command on the host func RunCommand(cmd string) (string, error) { c := exec.Command("bash", "-c", cmd) + if kc, ok := os.LookupEnv("E2E_KUBECONFIG"); ok { + c.Env = append(os.Environ(), "KUBECONFIG="+kc) + } out, err := c.CombinedOutput() return string(out), err }