2022-09-16 15:42:45 +00:00
|
|
|
// nolint
|
2022-08-12 13:55:47 +00:00
|
|
|
package mos_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
|
. "github.com/onsi/gomega"
|
2022-10-13 09:12:51 +00:00
|
|
|
. "github.com/spectrocloud/peg/matcher"
|
2022-08-12 13:55:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("k3s upgrade test", Label("upgrade-k8s"), func() {
|
|
|
|
BeforeEach(func() {
|
2022-10-13 09:12:51 +00:00
|
|
|
EventuallyConnects()
|
2022-08-12 13:55:47 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
if CurrentGinkgoTestDescription().Failed {
|
|
|
|
gatherLogs()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
Context("live cd", func() {
|
|
|
|
It("has default service active", func() {
|
2022-11-26 14:05:00 +00:00
|
|
|
if isFlavor("alpine") {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("rc-status")
|
2022-09-16 15:42:45 +00:00
|
|
|
Expect(out).Should(ContainSubstring("kairos"))
|
|
|
|
Expect(out).Should(ContainSubstring("kairos-agent"))
|
2022-11-28 15:09:37 +00:00
|
|
|
out, _ = Sudo("ps aux")
|
|
|
|
Expect(out).Should(ContainSubstring("/usr/sbin/crond"))
|
2022-08-12 13:55:47 +00:00
|
|
|
} else {
|
|
|
|
// Eventually(func() string {
|
2022-09-16 15:42:45 +00:00
|
|
|
// out, _ := machine.SSHCommand("sudo systemctl status kairos-agent")
|
2022-08-12 13:55:47 +00:00
|
|
|
// return out
|
|
|
|
// }, 30*time.Second, 10*time.Second).Should(ContainSubstring("no network token"))
|
|
|
|
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("systemctl status kairos")
|
2022-09-16 15:42:45 +00:00
|
|
|
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos.service; enabled; vendor preset: disabled)"))
|
2022-08-12 13:55:47 +00:00
|
|
|
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ = Sudo("systemctl status logrotate.timer")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(out).Should(ContainSubstring("active (waiting)"))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Context("install", func() {
|
|
|
|
It("to disk with custom config", func() {
|
2022-10-13 09:12:51 +00:00
|
|
|
err := Machine.SendFile("assets/single.yaml", "/tmp/config.yaml", "0770")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("elemental install --cloud-init /tmp/config.yaml /dev/sda")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(out).Should(ContainSubstring("Running after-install hook"))
|
|
|
|
fmt.Println(out)
|
2022-10-13 09:12:51 +00:00
|
|
|
Sudo("sync")
|
|
|
|
detachAndReboot()
|
2022-08-12 13:55:47 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
Context("first-boot", func() {
|
|
|
|
|
|
|
|
It("has default services on", func() {
|
2022-11-26 14:05:00 +00:00
|
|
|
if isFlavor("alpine") {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("rc-status")
|
2022-09-16 15:42:45 +00:00
|
|
|
Expect(out).Should(ContainSubstring("kairos"))
|
|
|
|
Expect(out).Should(ContainSubstring("kairos-agent"))
|
2022-08-12 13:55:47 +00:00
|
|
|
} else {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("systemctl status kairos-agent")
|
2022-09-16 15:42:45 +00:00
|
|
|
Expect(out).Should(ContainSubstring("loaded (/etc/systemd/system/kairos-agent.service; enabled; vendor preset: disabled)"))
|
2022-08-12 13:55:47 +00:00
|
|
|
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ = Sudo("systemctl status systemd-timesyncd")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(out).Should(ContainSubstring("loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: disabled)"))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
It("has kubeconfig", func() {
|
|
|
|
Eventually(func() string {
|
|
|
|
var out string
|
2022-11-26 14:05:00 +00:00
|
|
|
if isFlavor("alpine") {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ = Sudo("cat /var/log/kairos/agent.log;cat /var/log/kairos-agent.log")
|
2022-08-12 13:55:47 +00:00
|
|
|
} else {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ = Sudo("systemctl status kairos-agent")
|
2022-08-12 13:55:47 +00:00
|
|
|
}
|
|
|
|
return out
|
|
|
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("One time bootstrap starting"))
|
|
|
|
|
|
|
|
Eventually(func() string {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("cat /var/log/kairos/agent-provider.log")
|
2022-08-12 13:55:47 +00:00
|
|
|
return out
|
|
|
|
}, 900*time.Second, 10*time.Second).Should(Or(ContainSubstring("One time bootstrap starting"), ContainSubstring("Sentinel exists")))
|
|
|
|
|
|
|
|
Eventually(func() string {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, _ := Sudo("cat /etc/rancher/k3s/k3s.yaml")
|
2022-08-12 13:55:47 +00:00
|
|
|
return out
|
|
|
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("https:"))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("rotates logs", func() {
|
2022-10-13 09:12:51 +00:00
|
|
|
out, err := Sudo("logrotate -vf /etc/logrotate.d/kairos")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
Expect(out).To(ContainSubstring("log needs rotating"))
|
2022-10-13 09:12:51 +00:00
|
|
|
_, err = Sudo("ls /var/log/kairos/agent-provider.log.1.gz")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
})
|
|
|
|
|
|
|
|
It("upgrades", func() {
|
2022-11-30 11:31:41 +00:00
|
|
|
By("wait system-upgrade-controller", func() {
|
2022-08-12 13:55:47 +00:00
|
|
|
Eventually(func() string {
|
2022-11-30 11:31:41 +00:00
|
|
|
out, _ := kubectl("get pods -A")
|
2022-08-12 13:55:47 +00:00
|
|
|
return out
|
2022-11-30 11:31:41 +00:00
|
|
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("system-upgrade-controller"))
|
|
|
|
})
|
|
|
|
By("applying plan", func() {
|
2022-08-12 13:55:47 +00:00
|
|
|
|
2022-11-30 11:31:41 +00:00
|
|
|
err := Machine.SendFile("assets/suc.yaml", "./suc.yaml", "0770")
|
2022-08-12 13:55:47 +00:00
|
|
|
Expect(err).ToNot(HaveOccurred())
|
|
|
|
|
|
|
|
Eventually(func() string {
|
|
|
|
out, _ := kubectl("apply -f suc.yaml")
|
|
|
|
return out
|
|
|
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("unchanged"))
|
|
|
|
|
|
|
|
Eventually(func() string {
|
|
|
|
out, _ := kubectl("get pods -A")
|
|
|
|
fmt.Println(out)
|
|
|
|
return out
|
|
|
|
}, 900*time.Second, 10*time.Second).Should(ContainSubstring("apply-os-upgrade-on-"))
|
|
|
|
|
|
|
|
Eventually(func() string {
|
|
|
|
out, _ := kubectl("get pods -A")
|
|
|
|
fmt.Println(out)
|
2022-10-13 09:12:51 +00:00
|
|
|
version, _ := Machine.Command("source /etc/os-release; echo $VERSION")
|
2022-08-12 13:55:47 +00:00
|
|
|
return version
|
2022-09-23 13:16:48 +00:00
|
|
|
}, 30*time.Minute, 10*time.Second).Should(ContainSubstring("v"))
|
2022-08-12 13:55:47 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|