Skip to content

Commit

Permalink
🤖 Enhance test coverage (kairos-io#256)
Browse files Browse the repository at this point in the history
* 🤖 Enhance tests to check we boot with dracut modules

* 🤖 Check boot assessment was installed
  • Loading branch information
mudler authored Oct 21, 2022
1 parent 995306d commit 889e6c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion overlay/files/etc/cos/bootargs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if [ -n "$recoverylabel" ]; then
set kernelcmd="console=tty1 console=ttyS0 root=live:LABEL=$recoverylabel rd.live.dir=/ rd.live.squashimg=$img panic=5 rd.cos.oemlabel=COS_OEM"
else
# Boot arguments when the image is used as active/passive
set kernelcmd="console=tty1 console=ttyS0 root=LABEL=$label net.ifnames=1 cos-img/filename=$img panic=5 security=selinux rd.cos.oemlabel=COS_OEM selinux=1 fsck.mode=force fsck.repair=yes systemd.crash_reboot=yes"
set kernelcmd="console=tty1 console=ttyS0 root=LABEL=$label net.ifnames=1 cos-img/filename=$img rd.emergency=reboot rd.shell=0 panic=5 security=selinux rd.cos.oemlabel=COS_OEM selinux=1 fsck.mode=force fsck.repair=yes systemd.crash_reboot=yes"
fi

set initramfs=/boot/initrd
20 changes: 19 additions & 1 deletion tests/autoinstall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,26 @@ var _ = Describe("kairos autoinstall test", Label("autoinstall-test"), func() {
))
})

It("uses the dracut immutable module", func() {
out, err := Sudo("cat /proc/cmdline")
Expect(err).ToNot(HaveOccurred())
Expect(out).To(ContainSubstring("cos-img/filename="))
})

It("installs Auto assessment", func() {
// Auto assessment was installed
out, _ := Sudo("cat /run/initramfs/cos-state/grubcustom")
Expect(out).To(ContainSubstring("bootfile_loc"))

out, _ = Sudo("cat /run/initramfs/cos-state/grub_boot_assessment")
Expect(out).To(ContainSubstring("boot_assessment_blk"))

cmdline, _ := Sudo("cat /proc/cmdline")
Expect(cmdline).To(ContainSubstring("rd.emergency=reboot rd.shell=0 panic=5"))
})

It("has writeable tmp", func() {
_, err := Machine.Command("sudo echo 'foo' > /tmp/bar")
_, err := Sudo("echo 'foo' > /tmp/bar")
Expect(err).ToNot(HaveOccurred())

out, err := Machine.Command("sudo cat /tmp/bar")
Expand Down

0 comments on commit 889e6c2

Please sign in to comment.