Skip to content

Commit

Permalink
Add test for kubelet config-dir
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <[email protected]>
  • Loading branch information
brandond committed Dec 20, 2024
1 parent 6381ae9 commit f83cce9
Showing 1 changed file with 88 additions and 29 deletions.
117 changes: 88 additions & 29 deletions tests/e2e/startup/startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), supervisorPortYAML, "")
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))

fmt.Println("CLUSTER CONFIG")
fmt.Println("OS:", *nodeOS)
fmt.Println("Server Nodes:", serverNodeNames)
fmt.Println("Agent Nodes:", agentNodeNames)
By("CLUSTER CONFIG")
By("OS:" + *nodeOS)
By("Server Nodes:" + strings.Join(serverNodeNames, ","))
By("Agent Nodes:" + strings.Join(agentNodeNames, ","))
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
})

It("Checks node and pod status", func() {
fmt.Printf("\nFetching node status\n")
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -130,7 +130,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
}, "360s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(kubeConfigFile, true)

fmt.Printf("\nFetching pods status\n")
By("Fetching pods status")
Eventually(func(g Gomega) {
pods, err := e2e.ParsePods(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -176,22 +176,81 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
Expect(err).NotTo(HaveOccurred())
})
})
Context("Verify CRI-Dockerd :", func() {
Context("Verify kubelet config file", func() {
It("Starts K3s with no issues", func() {
for _, node := range append(serverNodeNames, agentNodeNames...) {
cmd := "mkdir -p --mode=0777 /tmp/kubelet.conf.d; echo 'apiVersion: kubelet.config.k8s.io/v1beta1\nkind: KubeletConfiguration\nshutdownGracePeriod: 19s\nshutdownGracePeriodCriticalPods: 13s' > /tmp/kubelet.conf.d/99-shutdownGracePeriod.conf"
res, err := e2e.RunCmdOnNode(cmd, node)
By("checking command results: " + res)
Expect(err).NotTo(HaveOccurred())
}

kubeletConfigDirYAML := "kubelet-arg: config-dir=/tmp/kubelet.conf.d"
err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), kubeletConfigDirYAML, kubeletConfigDirYAML)
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))

By("CLUSTER CONFIG")
By("OS:" + *nodeOS)
By("Server Nodes:" + strings.Join(serverNodeNames, ","))
By("Agent Nodes:" + strings.Join(agentNodeNames, ","))
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
})

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

By("Fetching pods status")
Eventually(func(g Gomega) {
pods, err := e2e.ParsePods(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
for _, pod := range pods {
if strings.Contains(pod.Name, "helm-install") {
g.Expect(pod.Status).Should(Equal("Completed"), pod.Name)
} else {
g.Expect(pod.Status).Should(Equal("Running"), pod.Name)
}
}
}, "360s", "5s").Should(Succeed())
_, _ = e2e.ParsePods(kubeConfigFile, true)
})

It("Returns kubelet configuration", func() {
for _, node := range append(serverNodeNames, agentNodeNames...) {
cmd := "kubectl get --raw /api/v1/nodes/" + node + "/proxy/configz"
Expect(e2e.RunCommand(cmd)).To(ContainSubstring(`"shutdownGracePeriod":"19s","shutdownGracePeriodCriticalPods":"13s"`))
}
})

It("Kills the cluster", func() {
err := KillK3sCluster(append(serverNodeNames, agentNodeNames...))
Expect(err).NotTo(HaveOccurred())
})
})
Context("Verify CRI-Dockerd", func() {
It("Starts K3s with no issues", func() {
dockerYAML := "docker: true"
err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), dockerYAML, dockerYAML)
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))

fmt.Println("CLUSTER CONFIG")
fmt.Println("OS:", *nodeOS)
fmt.Println("Server Nodes:", serverNodeNames)
fmt.Println("Agent Nodes:", agentNodeNames)
By("CLUSTER CONFIG")
By("OS:" + *nodeOS)
By("Server Nodes:" + strings.Join(serverNodeNames, ","))
By("Agent Nodes:" + strings.Join(agentNodeNames, ","))
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
})

It("Checks node and pod status", func() {
fmt.Printf("\nFetching node status\n")
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -201,7 +260,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
}, "360s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(kubeConfigFile, true)

fmt.Printf("\nFetching pods status\n")
By("Fetching pods status")
Eventually(func(g Gomega) {
pods, err := e2e.ParsePods(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -226,16 +285,16 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), preferBundledYAML, preferBundledYAML)
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))

fmt.Println("CLUSTER CONFIG")
fmt.Println("OS:", *nodeOS)
fmt.Println("Server Nodes:", serverNodeNames)
fmt.Println("Agent Nodes:", agentNodeNames)
By("CLUSTER CONFIG")
By("OS:" + *nodeOS)
By("Server Nodes:" + strings.Join(serverNodeNames, ","))
By("Agent Nodes:" + strings.Join(agentNodeNames, ","))
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
})

It("Checks node and pod status", func() {
fmt.Printf("\nFetching node status\n")
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -245,7 +304,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
}, "360s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(kubeConfigFile, true)

fmt.Printf("\nFetching pods status\n")
By("Fetching pods status")
Eventually(func(g Gomega) {
pods, err := e2e.ParsePods(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -270,16 +329,16 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), disableAgentYAML, "")
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))

fmt.Println("CLUSTER CONFIG")
fmt.Println("OS:", *nodeOS)
fmt.Println("Server Nodes:", serverNodeNames)
fmt.Println("Agent Nodes:", agentNodeNames)
By("CLUSTER CONFIG")
By("OS:" + *nodeOS)
By("Server Nodes:" + strings.Join(serverNodeNames, ","))
By("Agent Nodes:" + strings.Join(agentNodeNames, ","))
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
})

It("Checks node and pod status", func() {
fmt.Printf("\nFetching node status\n")
By("Fetching node status")
Eventually(func(g Gomega) {
nodes, err := e2e.ParseNodes(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand All @@ -289,7 +348,7 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
}, "360s", "5s").Should(Succeed())
_, _ = e2e.ParseNodes(kubeConfigFile, true)

fmt.Printf("\nFetching pods status\n")
By("Fetching pods status")
Eventually(func(g Gomega) {
pods, err := e2e.ParsePods(kubeConfigFile, false)
g.Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -350,10 +409,10 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
err := StartK3sCluster(append(serverNodeNames, agentNodeNames...), "", "")
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))

fmt.Println("CLUSTER CONFIG")
fmt.Println("OS:", *nodeOS)
fmt.Println("Server Nodes:", serverNodeNames)
fmt.Println("Agent Nodes:", agentNodeNames)
By("CLUSTER CONFIG")
By("OS:" + *nodeOS)
By("Server Nodes:" + strings.Join(serverNodeNames, ","))
By("Agent Nodes:" + strings.Join(agentNodeNames, ","))
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
Expect(err).NotTo(HaveOccurred())
})
Expand Down

0 comments on commit f83cce9

Please sign in to comment.