Skip to content

Commit

Permalink
Replace e2e.ParseNodes function with general ParseNodes and NodesRead…
Browse files Browse the repository at this point in the history
…y test functions

Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Feb 28, 2025
1 parent f2f3c93 commit 9865ab1
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 222 deletions.
8 changes: 2 additions & 6 deletions tests/e2e/btrfs/btrfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ var _ = Describe("Verify that btrfs based servers work", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
e2e.DumpPods(tc.KubeconfigFile)

Expand Down
11 changes: 3 additions & 8 deletions tests/e2e/dualstack/dualstack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,10 @@ var _ = Describe("Verify DualStack Configuration", Ordered, func() {
})

It("Checks Node Status", func() {
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true)
Expect(err).NotTo(HaveOccurred())
e2e.DumpNodes(tc.KubeconfigFile)
})

It("Checks pod status", func() {
Expand Down
8 changes: 2 additions & 6 deletions tests/e2e/embeddedmirror/embeddedmirror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,8 @@ var _ = Describe("Verify Create", Ordered, func() {
})
It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())

By("Fetching pod status")
Expand Down
11 changes: 3 additions & 8 deletions tests/e2e/externalip/externalip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,10 @@ var _ = Describe("Verify External-IP config", Ordered, func() {
})

It("Checks Node Status", func() {
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
_, err := e2e.ParseNodes(tc.KubeconfigFile, true)
Expect(err).NotTo(HaveOccurred())
e2e.DumpNodes(tc.KubeconfigFile)
})

It("Checks pod status", func() {
Expand Down
8 changes: 2 additions & 6 deletions tests/e2e/privateregistry/privateregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ var _ = Describe("Verify Create", Ordered, func() {
})
It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
e2e.DumpPods(tc.KubeconfigFile)

Expand Down
10 changes: 3 additions & 7 deletions tests/e2e/rootless/rootless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,10 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(tc.KubeconfigFile, false)
e2e.DumpNodes(tc.KubeconfigFile)

Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down
20 changes: 6 additions & 14 deletions tests/e2e/rotateca/rotateca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,10 @@ var _ = Describe("Verify Custom CA Rotation", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true)
e2e.DumpNodes(tc.KubeconfigFile)

Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down Expand Up @@ -92,13 +88,9 @@ var _ = Describe("Verify Custom CA Rotation", Ordered, func() {
})

It("Checks node and pod status", func() {
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "420s", "5s").Should(Succeed())
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())

Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down
10 changes: 3 additions & 7 deletions tests/e2e/s3/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,10 @@ var _ = Describe("Verify Create", Ordered, func() {
})
It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true)
e2e.DumpNodes(tc.KubeconfigFile)

Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down
10 changes: 3 additions & 7 deletions tests/e2e/secretsencryption/secretsencryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,10 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())
e2e.ParseNodes(tc.KubeconfigFile, true)
e2e.DumpNodes(tc.KubeconfigFile)

Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down
18 changes: 5 additions & 13 deletions tests/e2e/secretsencryption_old/secretsencryption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "620s", "5s").Should(Succeed())

Eventually(func() error {
Expand Down Expand Up @@ -103,13 +99,9 @@ var _ = Describe("Verify Secrets Encryption Rotation", Ordered, func() {
})

It("Checks node and pod status", func() {
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
}, "420s", "5s").Should(Succeed())
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())

Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down
15 changes: 6 additions & 9 deletions tests/e2e/splitserver/splitserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var (
etcdNodes []e2e.VagrantNode
cpNodes []e2e.VagrantNode
agentNodes []e2e.VagrantNode
allNodes []e2e.VagrantNode
)

var _ = ReportAfterEach(e2e.GenReport)
Expand All @@ -150,13 +151,11 @@ var _ = Describe("Verify Create", Ordered, func() {
})

It("Checks node and pod status", func() {
allNodes = append(cpNodes, etcdNodes...)
allNodes = append(allNodes, agentNodes...)
By("Fetching Nodes status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(allNodes))
}, "620s", "5s").Should(Succeed())

Eventually(func() error {
Expand Down Expand Up @@ -248,7 +247,7 @@ var _ = Describe("Verify Create", Ordered, func() {
Eventually(func(g Gomega) {
count, err := e2e.GetDaemonsetReady("test-daemonset", tc.KubeconfigFile)
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())
})

Expand All @@ -275,8 +274,6 @@ var _ = AfterEach(func() {
})

var _ = AfterSuite(func() {
allNodes := append(cpNodes, etcdNodes...)
allNodes = append(allNodes, agentNodes...)
if failed {
AddReportEntry("journald-logs", e2e.TailJournalLogs(1000, allNodes))
} else {
Expand Down
40 changes: 10 additions & 30 deletions tests/e2e/startup/startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())
Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down Expand Up @@ -186,12 +182,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())
Eventually(func() error {
return tests.AllPodsUp(tc.KubeconfigFile)
Expand Down Expand Up @@ -229,12 +221,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())

Eventually(func() error {
Expand Down Expand Up @@ -265,12 +253,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())

Eventually(func() error {
Expand Down Expand Up @@ -301,12 +285,8 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {

It("Checks node and pod status", func() {
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, node := range nodes {
g.Expect(node.Status).Should(Equal("Ready"))
}
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.Agents))
}, "360s", "5s").Should(Succeed())

Eventually(func() error {
Expand Down
14 changes: 4 additions & 10 deletions tests/e2e/svcpoliciesandfirewall/svcpoliciesandfirewall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,10 @@ var _ = Describe("Verify Services Traffic policies and firewall config", Ordered
})

It("Checks Node Status", func() {
Eventually(func(g Gomega) {
var err error
nodes, err = e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
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())
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())
e2e.DumpNodes(tc.KubeconfigFile)
})

It("Checks Pod Status", func() {
Expand Down
30 changes: 10 additions & 20 deletions tests/e2e/tailscale/tailscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"testing"

"github.com/k3s-io/k3s/tests"
"github.com/k3s-io/k3s/tests/e2e"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -46,16 +47,11 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() {
})

// Server node needs to be ready before we continue
It("Checks Node Status", func() {
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
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 Server Status", func() {
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.Servers))
}, "360s", "5s").Should(Succeed())
e2e.DumpNodes(tc.KubeconfigFile)
})

It("Change agent's config", func() {
Expand All @@ -73,16 +69,10 @@ var _ = Describe("Verify Tailscale Configuration", Ordered, func() {
})

It("Checks Node Status", func() {
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(tc.KubeconfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
g.Expect(len(nodes)).To(Equal(*agentCount + *serverCount))
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())
Eventually(func() error {
return tests.NodesReady(tc.KubeconfigFile, e2e.VagrantSlice(tc.AllNodes()))
}, "360s", "5s").Should(Succeed())
e2e.DumpNodes(tc.KubeconfigFile)
})

It("Verifies that server and agent have a tailscale IP as nodeIP", func() {
Expand Down
Loading

0 comments on commit 9865ab1

Please sign in to comment.