2022-07-29 21:56:02 +00:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/k3s-io/k3s/tests/e2e"
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
2023-01-27 17:01:13 +00:00
|
|
|
// Valid nodeOS: generic/ubuntu2004, opensuse/Leap-15.3.x86_64
|
2022-07-29 21:56:02 +00:00
|
|
|
var nodeOS = flag.String("nodeOS", "generic/ubuntu2004", "VM operating system")
|
|
|
|
var serverCount = flag.Int("serverCount", 1, "number of server nodes")
|
|
|
|
var agentCount = flag.Int("agentCount", 1, "number of agent nodes")
|
2023-01-12 00:09:45 +00:00
|
|
|
var ci = flag.Bool("ci", false, "running on CI")
|
2022-07-29 21:56:02 +00:00
|
|
|
|
|
|
|
// Environment Variables Info:
|
|
|
|
// E2E_RELEASE_VERSION=v1.23.1+k3s2 or nil for latest commit from master
|
|
|
|
|
2022-11-04 23:07:12 +00:00
|
|
|
func Test_E2EDockerCRIValidation(t *testing.T) {
|
2022-07-29 21:56:02 +00:00
|
|
|
RegisterFailHandler(Fail)
|
|
|
|
flag.Parse()
|
2022-11-04 23:07:12 +00:00
|
|
|
suiteConfig, reporterConfig := GinkgoConfiguration()
|
|
|
|
RunSpecs(t, "Docker CRI Test Suite", suiteConfig, reporterConfig)
|
2022-07-29 21:56:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
kubeConfigFile string
|
|
|
|
serverNodeNames []string
|
|
|
|
agentNodeNames []string
|
|
|
|
)
|
|
|
|
|
2022-11-04 23:07:12 +00:00
|
|
|
var _ = ReportAfterEach(e2e.GenReport)
|
|
|
|
|
2022-09-06 19:56:37 +00:00
|
|
|
var _ = Describe("Verify CRI-Dockerd", Ordered, func() {
|
2022-07-29 21:56:02 +00:00
|
|
|
Context("Cluster :", func() {
|
|
|
|
It("Starts up with no issues", func() {
|
|
|
|
var err error
|
|
|
|
serverNodeNames, agentNodeNames, err = e2e.CreateCluster(*nodeOS, *serverCount, *agentCount)
|
2022-10-06 19:27:44 +00:00
|
|
|
Expect(err).NotTo(HaveOccurred(), e2e.GetVagrantLog(err))
|
2022-07-29 21:56:02 +00:00
|
|
|
fmt.Println("CLUSTER CONFIG")
|
|
|
|
fmt.Println("OS:", *nodeOS)
|
|
|
|
fmt.Println("Server Nodes:", serverNodeNames)
|
|
|
|
fmt.Println("Agent Nodes:", agentNodeNames)
|
|
|
|
kubeConfigFile, err = e2e.GenKubeConfigFile(serverNodeNames[0])
|
|
|
|
Expect(err).NotTo(HaveOccurred())
|
|
|
|
})
|
|
|
|
|
|
|
|
It("Checks node and pod status", func() {
|
|
|
|
fmt.Printf("\nFetching node status\n")
|
|
|
|
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"))
|
|
|
|
}
|
2023-01-12 00:09:45 +00:00
|
|
|
}, "620s", "5s").Should(Succeed())
|
2022-07-29 21:56:02 +00:00
|
|
|
_, _ = e2e.ParseNodes(kubeConfigFile, true)
|
|
|
|
|
|
|
|
fmt.Printf("\nFetching pods status\n")
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2023-01-12 00:09:45 +00:00
|
|
|
}, "620s", "5s").Should(Succeed())
|
2022-07-29 21:56:02 +00:00
|
|
|
_, _ = e2e.ParsePods(kubeConfigFile, true)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-11-04 23:07:12 +00:00
|
|
|
var failed bool
|
2022-07-29 21:56:02 +00:00
|
|
|
var _ = AfterEach(func() {
|
|
|
|
failed = failed || CurrentSpecReport().Failed()
|
|
|
|
})
|
|
|
|
|
|
|
|
var _ = AfterSuite(func() {
|
2023-01-12 00:09:45 +00:00
|
|
|
if failed && !*ci {
|
2022-07-29 21:56:02 +00:00
|
|
|
fmt.Println("FAILED!")
|
|
|
|
} else {
|
|
|
|
Expect(e2e.DestroyCluster()).To(Succeed())
|
|
|
|
Expect(os.Remove(kubeConfigFile)).To(Succeed())
|
|
|
|
}
|
|
|
|
})
|