Commit 99f58452 authored by Derek Nola's avatar Derek Nola

Replace e2e.ParseNodes function with general ParseNodes and NodesReady test functions

parent 9fb13250
...@@ -45,12 +45,8 @@ var _ = Describe("Verify that btrfs based servers work", Ordered, func() { ...@@ -45,12 +45,8 @@ var _ = Describe("Verify that btrfs based servers work", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
e2e.DumpPods(tc.KubeconfigFile) e2e.DumpPods(tc.KubeconfigFile)
......
...@@ -49,15 +49,10 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() { ...@@ -49,15 +49,10 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
}) })
It("Checks Node Status", func() { It("Checks Node Status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true) e2e.DumpNodes(tc.KubeconfigFile)
Expect(err).NotTo(HaveOccurred())
}) })
It("Checks pod status", func() { It("Checks pod status", func() {
......
...@@ -53,12 +53,8 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -53,12 +53,8 @@ var _ = Describe("Verify Create", Ordered, func() {
}) })
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
By("Fetching pod status") By("Fetching pod status")
......
...@@ -74,15 +74,10 @@ var _ = Describe("Verify External-IP config", Ordered, func() { ...@@ -74,15 +74,10 @@ var _ = Describe("Verify External-IP config", Ordered, func() {
}) })
It("Checks Node Status", func() { It("Checks Node Status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true) e2e.DumpNodes(tc.KubeconfigFile)
Expect(err).NotTo(HaveOccurred())
}) })
It("Checks pod status", func() { It("Checks pod status", func() {
......
...@@ -55,12 +55,8 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -55,12 +55,8 @@ var _ = Describe("Verify Create", Ordered, func() {
}) })
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
e2e.DumpPods(tc.KubeconfigFile) e2e.DumpPods(tc.KubeconfigFile)
......
...@@ -101,14 +101,10 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { ...@@ -101,14 +101,10 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "360s", "5s").Should(Succeed()) }, "360s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(tc.KubeconfigFile, false) e2e.DumpNodes(tc.KubeconfigFile)
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
......
...@@ -50,14 +50,10 @@ var _ = Describe("Verify Custom CA Rotation", Ordered, func() { ...@@ -50,14 +50,10 @@ var _ = Describe("Verify Custom CA Rotation", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true) e2e.DumpNodes(tc.KubeconfigFile)
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
...@@ -92,13 +88,9 @@ var _ = Describe("Verify Custom CA Rotation", Ordered, func() { ...@@ -92,13 +88,9 @@ var _ = Describe("Verify Custom CA Rotation", Ordered, func() {
}) })
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred()) }, "360s", "5s").Should(Succeed())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "420s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
......
...@@ -52,14 +52,10 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -52,14 +52,10 @@ var _ = Describe("Verify Create", Ordered, func() {
}) })
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true) e2e.DumpNodes(tc.KubeconfigFile)
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
......
...@@ -54,14 +54,10 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() { ...@@ -54,14 +54,10 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true) e2e.DumpNodes(tc.KubeconfigFile)
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
......
...@@ -51,12 +51,8 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() { ...@@ -51,12 +51,8 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
...@@ -103,13 +99,9 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() { ...@@ -103,13 +99,9 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() {
}) })
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred()) }, "360s", "5s").Should(Succeed())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "420s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
......
...@@ -126,6 +126,7 @@ var ( ...@@ -126,6 +126,7 @@ var (
etcdNodes []e2e.VagrantNode etcdNodes []e2e.VagrantNode
cpNodes []e2e.VagrantNode cpNodes []e2e.VagrantNode
agentNodes []e2e.VagrantNode agentNodes []e2e.VagrantNode
allNodes []e2e.VagrantNode
) )
var _ = ReportAfterEach(e2e.GenReport) var _ = ReportAfterEach(e2e.GenReport)
...@@ -150,13 +151,11 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -150,13 +151,11 @@ var _ = Describe("Verify Create", Ordered, func() {
}) })
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
allNodes = append(cpNodes, etcdNodes...)
allNodes = append(allNodes, agentNodes...)
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(allNodes))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
...@@ -248,7 +247,7 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -248,7 +247,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile) count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
g.Expect(cpNodes).To(HaveLen(count), "Daemonset pod count does not match cp node count") g.Expect(cpNodes).To(HaveLen(count), "Daemonset pod count does not match node count")
}, "240s", "10s").Should(Succeed()) }, "240s", "10s").Should(Succeed())
}) })
...@@ -275,8 +274,6 @@ var _ = AfterEach(func() { ...@@ -275,8 +274,6 @@ var _ = AfterEach(func() {
}) })
var _ = AfterSuite(func() { var _ = AfterSuite(func() {
allNodes := append(cpNodes, etcdNodes...)
allNodes = append(allNodes, agentNodes...)
if failed { if failed {
AddReportEntry("journald-logs", e2e.TailJournalLogs(1000, allNodes)) AddReportEntry("journald-logs", e2e.TailJournalLogs(1000, allNodes))
} else { } else {
......
...@@ -117,12 +117,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { ...@@ -117,12 +117,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching node status") By("Fetching node status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "360s", "5s").Should(Succeed()) }, "360s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
...@@ -186,12 +182,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { ...@@ -186,12 +182,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching node status") By("Fetching node status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "360s", "5s").Should(Succeed()) }, "360s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile) return tests.AllPodsUp(tc.KubeconfigFile)
...@@ -229,12 +221,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { ...@@ -229,12 +221,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching node status") By("Fetching node status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "360s", "5s").Should(Succeed()) }, "360s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
...@@ -265,12 +253,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { ...@@ -265,12 +253,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching node status") By("Fetching node status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "360s", "5s").Should(Succeed()) }, "360s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
...@@ -301,12 +285,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() { ...@@ -301,12 +285,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching node status") By("Fetching node status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.Agents))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "360s", "5s").Should(Succeed()) }, "360s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
......
...@@ -57,16 +57,10 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered ...@@ -57,16 +57,10 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered
}) })
It("Checks Node Status", func() { It("Checks Node Status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
var err error return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
nodes, err = e2e.ParseNodes(tc.KubeconfigFile, false) }, "360s", "5s").Should(Succeed())
g.Expect(err).NotTo(HaveOccurred()) e2e.DumpNodes(tc.KubeconfigFile)
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "300s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true)
Expect(err).NotTo(HaveOccurred())
}) })
It("Checks Pod Status", func() { It("Checks Pod Status", func() {
......
...@@ -6,6 +6,7 @@ import ( ...@@ -6,6 +6,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/k3s-io/k3s/tests"
"github.com/k3s-io/k3s/tests/e2e" "github.com/k3s-io/k3s/tests/e2e"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
...@@ -46,16 +47,11 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() { ...@@ -46,16 +47,11 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() {
}) })
// Server node needs to be ready before we continue // Server node needs to be ready before we continue
It("Checks Node Status", func() { It("Checks Server Status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.Servers))
g.Expect(err).NotTo(HaveOccurred()) }, "360s", "5s").Should(Succeed())
for _, node := range nodes { e2e.DumpNodes(tc.KubeconfigFile)
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "300s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true)
Expect(err).NotTo(HaveOccurred())
}) })
It("Change agent's config", func() { It("Change agent's config", func() {
...@@ -73,16 +69,10 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() { ...@@ -73,16 +69,10 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() {
}) })
It("Checks Node Status", func() { It("Checks Node Status", func() {
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred()) }, "360s", "5s").Should(Succeed())
g.Expect(len(nodes)).To(Equal(*agentCount + *serverCount)) e2e.DumpNodes(tc.KubeconfigFile)
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "300s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true)
Expect(err).NotTo(HaveOccurred())
}) })
It("Verifies that server and agent have a tailscale IP as nodeIP", func() { It("Verifies that server and agent have a tailscale IP as nodeIP", func() {
......
...@@ -161,13 +161,12 @@ func CreateCluster(nodeOS string, serverCount, agentCount int) (*TestConfig, err ...@@ -161,13 +161,12 @@ func CreateCluster(nodeOS string, serverCount, agentCount int) (*TestConfig, err
return nil, err return nil, err
} }
// For startup test, we don't start the cluster, so check first before // For startup test, we don't start the cluster, so check first before generating the kubeconfig file.
// generating the kubeconfig file // Systemctl returns a exit code of 3 when the service is inactive, so we don't check for errors
// on the command itself.
var kubeConfigFile string var kubeConfigFile string
res, err := serverNodes[0].RunCmdOnNode("systemctl is-active k3s") var err error
if err != nil { res, _ := serverNodes[0].RunCmdOnNode("systemctl is-active k3s")
return nil, err
}
if !strings.Contains(res, "inactive") && strings.Contains(res, "active") { if !strings.Contains(res, "inactive") && strings.Contains(res, "active") {
kubeConfigFile, err = GenKubeconfigFile(serverNodes[0].String()) kubeConfigFile, err = GenKubeconfigFile(serverNodes[0].String())
if err != nil { if err != nil {
...@@ -491,37 +490,10 @@ func GetVagrantLog(cErr error) string { ...@@ -491,37 +490,10 @@ func GetVagrantLog(cErr error) string {
return string(bytes) + nodeJournal return string(bytes) + nodeJournal
} }
func ParseNodes(kubeConfig string, print bool) ([]Node, error) { func DumpNodes(kubeConfig string) {
nodes := make([]Node, 0, 10)
nodeList := ""
cmd := "kubectl get nodes --no-headers -o wide -A --kubeconfig=" + kubeConfig cmd := "kubectl get nodes --no-headers -o wide -A --kubeconfig=" + kubeConfig
res, err := RunCommand(cmd) res, _ := RunCommand(cmd)
fmt.Println(strings.TrimSpace(res))
if err != nil {
return nil, fmt.Errorf("unable to get nodes: %s: %v", res, err)
}
nodeList = strings.TrimSpace(res)
split := strings.Split(nodeList, "\n")
for _, rec := range split {
if strings.TrimSpace(rec) != "" {
fields := strings.Fields(rec)
node := Node{
Name: fields[0],
Status: fields[1],
Roles: fields[2],
InternalIP: fields[5],
}
if len(fields) > 6 {
node.ExternalIP = fields[6]
}
nodes = append(nodes, node)
}
}
if print {
fmt.Println(nodeList)
}
return nodes, nil
} }
func DumpPods(kubeConfig string) { func DumpPods(kubeConfig string) {
......
...@@ -55,12 +55,8 @@ var _ = Describe("Verify Upgrade", Ordered, func() { ...@@ -55,12 +55,8 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
Eventually(func() error { Eventually(func() error {
...@@ -149,8 +145,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() { ...@@ -149,8 +145,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
_, err := tc.DeployWorkload("daemonset.yaml") _, err := tc.DeployWorkload("daemonset.yaml")
Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed") Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed")
nodes, _ := e2e.ParseNodes(tc.KubeconfigFile, false) nodes, _ := tests.ParseNodes(tc.KubeconfigFile)
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile) count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
...@@ -239,14 +234,10 @@ var _ = Describe("Verify Upgrade", Ordered, func() { ...@@ -239,14 +234,10 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
It("After upgrade Checks Node and Pod Status", func() { It("After upgrade Checks Node and Pod Status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred()) }, "360s", "5s").Should(Succeed())
for _, node := range nodes { e2e.DumpNodes(tc.KubeconfigFile)
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "420s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true)
By("Fetching Pod status") By("Fetching Pod status")
tests.AllPodsUp(tc.KubeconfigFile) tests.AllPodsUp(tc.KubeconfigFile)
...@@ -321,8 +312,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() { ...@@ -321,8 +312,7 @@ var _ = Describe("Verify Upgrade", Ordered, func() {
}) })
It("After upgrade verifies Daemonset", func() { It("After upgrade verifies Daemonset", func() {
nodes, _ := e2e.ParseNodes(tc.KubeconfigFile, false) nodes, _ := tests.ParseNodes(tc.KubeconfigFile)
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile) count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
......
...@@ -12,6 +12,7 @@ import ( ...@@ -12,6 +12,7 @@ import (
"github.com/k3s-io/k3s/tests/e2e" "github.com/k3s-io/k3s/tests/e2e"
. "github.com/onsi/ginkgo/v2" . "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
) )
// Valid nodeOS: // Valid nodeOS:
...@@ -58,14 +59,10 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -58,14 +59,10 @@ var _ = Describe("Verify Create", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
fmt.Printf("\nFetching node status\n") fmt.Printf("\nFetching node status\n")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(tc.KubeconfigFile, true) e2e.DumpNodes(tc.KubeconfigFile)
fmt.Printf("\nFetching Pods status\n") fmt.Printf("\nFetching Pods status\n")
Eventually(func() error { Eventually(func() error {
...@@ -171,8 +168,7 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -171,8 +168,7 @@ var _ = Describe("Verify Create", Ordered, func() {
_, err := tc.DeployWorkload("daemonset.yaml") _, err := tc.DeployWorkload("daemonset.yaml")
Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed") Expect(err).NotTo(HaveOccurred(), "Daemonset manifest not deployed")
nodes, _ := e2e.ParseNodes(tc.KubeconfigFile, false) nodes, _ := tests.ParseNodes(tc.KubeconfigFile)
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile) count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
...@@ -262,10 +258,14 @@ var _ = Describe("Verify Create", Ordered, func() { ...@@ -262,10 +258,14 @@ var _ = Describe("Verify Create", Ordered, func() {
Expect(errRestart).NotTo(HaveOccurred(), "Restart Nodes not happened correctly") Expect(errRestart).NotTo(HaveOccurred(), "Restart Nodes not happened correctly")
Eventually(func(g Gomega) { Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) nodes, err := tests.ParseNodes(tc.KubeconfigFile)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes { for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready")) for _, condition := range node.Status.Conditions {
if condition.Type == corev1.NodeReady {
g.Expect(condition.Status).Should(Equal(corev1.ConditionTrue))
}
}
} }
count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile) count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile)
g.Expect(err).NotTo(HaveOccurred()) g.Expect(err).NotTo(HaveOccurred())
......
...@@ -47,12 +47,8 @@ var _ = Describe("Verify K3s can run Wasm workloads", Ordered, func() { ...@@ -47,12 +47,8 @@ var _ = Describe("Verify K3s can run Wasm workloads", Ordered, func() {
It("Checks node and pod status", func() { It("Checks node and pod status", func() {
By("Fetching Nodes status") By("Fetching Nodes status")
Eventually(func(g Gomega) { Eventually(func() error {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false) return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "620s", "5s").Should(Succeed()) }, "620s", "5s").Should(Succeed())
By("Fetching pod status") By("Fetching pod status")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment