Skip to content

Commit

Permalink
Expand skew test to HA
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <derek.nola@suse.com>
  • Loading branch information
dereknola committed Nov 22, 2024
1 parent 9236111 commit 50aeebc
Showing 1 changed file with 64 additions and 24 deletions.
88 changes: 64 additions & 24 deletions tests/docker/skew/skew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,33 @@ func Test_DockerSkew(t *testing.T) {
RunSpecs(t, "Skew Docker Test Suite")
}

var lastMinorVersion string
var _ = BeforeSuite(func() {
// If this test runs on v1.31 commit, we want the latest v1.30 release
// For master and unreleased branches, we want the latest stable release
var upgradeChannel string
var err error
if *branch == "master" {
upgradeChannel = "stable"
} else {
upgradeChannel = strings.Replace(*branch, "release-", "v", 1)
// now that it is in v1.1 format, we want to substract one from the minor version
// to get the previous release
sV, err := semver.Parse(upgradeChannel)
Expect(err).NotTo(HaveOccurred())
sV.Minor--
upgradeChannel = sV.String()
}

lastMinorVersion, err = tester.GetVersionFromChannel(upgradeChannel)
Expect(err).NotTo(HaveOccurred())
Expect(lastMinorVersion).To(ContainSubstring("v1."))
fmt.Println("Using last minor version: ", lastMinorVersion)
})

var _ = Describe("Skew Tests", Ordered, func() {

Context("Setup Cluster with Server newer than Agent", func() {
var lastMinorVersion string
It("should determine last minor version", func() {
// If this test runs on v1.31 commit, we want the latest v1.30 release
// For master and unreleased branches, we want the latest stable release
var upgradeChannel string
var err error
if *branch == "master" {
upgradeChannel = "stable"
} else {
upgradeChannel = strings.Replace(*branch, "release-", "v", 1)
// now that it is in v1.1 format, we want to substract one from the minor version
// to get the previous release
sV, err := semver.Parse(upgradeChannel)
Expect(err).NotTo(HaveOccurred())
sV.Minor--
upgradeChannel = sV.String()
}

lastMinorVersion, err = tester.GetVersionFromChannel(upgradeChannel)
Expect(err).NotTo(HaveOccurred())
Expect(lastMinorVersion).To(ContainSubstring("v1."))
fmt.Println("Using last minor version: ", lastMinorVersion)
})
It("should provision new servers and old agents", func() {
var err error
config, err = tester.NewTestConfig(*k3sImage)
Expand All @@ -64,7 +65,7 @@ var _ = Describe("Skew Tests", Ordered, func() {
return tester.DeploymentsReady([]string{"coredns", "local-path-provisioner", "metrics-server", "traefik"}, config.KubeconfigFile)
}, "60s", "5s").Should(Succeed())
})
It("should confirm respective versions", func() {
It("should match respective versions", func() {
for _, server := range config.Servers {
out, err := tester.RunCmdOnDocker(server.Name, "k3s --version")
Expect(err).NotTo(HaveOccurred())
Expand All @@ -91,6 +92,45 @@ var _ = Describe("Skew Tests", Ordered, func() {
return tester.PodReady("volume-test", "kube-system", config.KubeconfigFile)
}, "20s", "5s").Should(BeTrue())
})
It("should destroy the cluster", func() {
Expect(config.Cleanup()).To(Succeed())
})
})
Context("Test cluster with 1 Server older and 2 Servers newer", func() {
It("should setup the cluster configuration", func() {
var err error
config, err = tester.NewTestConfig("rancher/k3s:" + lastMinorVersion)
Expect(err).NotTo(HaveOccurred())
})
It("should provision servers", func() {
Expect(config.ProvisionServers(1)).To(Succeed())
config.K3sImage = *k3sImage
Expect(config.ProvisionServers(3)).To(Succeed())
Eventually(func() error {
return tester.DeploymentsReady([]string{"coredns", "local-path-provisioner", "metrics-server", "traefik"}, config.KubeconfigFile)
}, "60s", "5s").Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(tester.ParseNodes(config.KubeconfigFile)).To(HaveLen(3))
g.Expect(tester.NodesReady(config.KubeconfigFile)).To(Succeed())
}, "60s", "5s").Should(Succeed())
})
It("should match respective versions", func() {
out, err := tester.RunCmdOnDocker(config.Servers[0].Name, "k3s --version")
Expect(err).NotTo(HaveOccurred())
Expect(out).To(ContainSubstring(strings.Replace(lastMinorVersion, "-", "+", 1)))
for _, server := range config.Servers[1:] {
out, err := tester.RunCmdOnDocker(server.Name, "k3s --version")
Expect(err).NotTo(HaveOccurred())
// The k3s image is in the format rancher/k3s:v1.20.0-k3s1
cVersion := strings.Split(*k3sImage, ":")[1]
cVersion = strings.Replace(cVersion, "-amd64", "", 1)
cVersion = strings.Replace(cVersion, "-", "+", 1)
Expect(out).To(ContainSubstring(cVersion))
}
})
It("should destroy the cluster", func() {
Expect(config.Cleanup()).To(Succeed())
})
})
})

Expand Down

0 comments on commit 50aeebc

Please sign in to comment.