Skip to content

Commit

Permalink
Fix uki test (#2302)
Browse files Browse the repository at this point in the history
Itxaka authored Mar 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d97b9d0 commit 551c018
Showing 2 changed files with 21 additions and 12 deletions.
4 changes: 4 additions & 0 deletions tests/tests_suite_test.go
Original file line number Diff line number Diff line change
@@ -77,6 +77,9 @@ func gatherLogs(vm VM) {
vm.Sudo("blkid > /run/blkid")
vm.Sudo("dmesg > /run/dmesg.log")

// zip all files under /var/log/kairos
vm.Sudo("tar -czf /run/kairos-agent-logs.tar.gz /var/log/kairos")

vm.GatherAllLogs(
[]string{
"edgevpn@kairos",
@@ -105,6 +108,7 @@ func gatherLogs(vm VM) {
"/run/immucore/initramfs_stage.log",
"/run/immucore/rootfs_stage.log",
"/tmp/ovmf_debug.log",
"/run/kairos-agent-logs.tar.gz",
})
}

29 changes: 17 additions & 12 deletions tests/uki_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package mos_test

import (
"fmt"
"os"
"strings"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@@ -51,16 +51,22 @@ var _ = Describe("kairos UKI test", Label("uki"), Ordered, func() {
Expect(out).ToNot(ContainSubstring("/dev/disk/by-label/COS_PERSISTENT"))
})
By("installing kairos", func() {
out, err := vm.Sudo(`kairos-agent --debug install`)
fmt.Println(string(out))
Expect(err).ToNot(HaveOccurred(), out)
Expect(out).Should(ContainSubstring("Running after-install hook"))
Expect(out).Should(ContainSubstring("Encrypting COS_OEM"))
Expect(out).Should(ContainSubstring("Encrypting COS_PERSISTENT"))
Expect(out).Should(ContainSubstring("Done encrypting COS_OEM"))
Expect(out).Should(ContainSubstring("Done encrypting COS_PERSISTENT"))
Expect(out).Should(ContainSubstring("New TPM2 token enrolled as key slot 1."))
// Install has already started, so we can use Eventually here to track the logs
Eventually(func() string {
out, err := vm.Sudo("cat /var/log/kairos/agent*.log")
Expect(err).ToNot(HaveOccurred())
return out
}, 5*time.Minute).Should(And(
ContainSubstring("Running after-install hook"),
ContainSubstring("Encrypting COS_OEM"),
ContainSubstring("Encrypting COS_PERSISTENT"),
ContainSubstring("Done encrypting COS_OEM"),
ContainSubstring("Done encrypting COS_PERSISTENT"),
ContainSubstring("Done executing stage 'kairos-uki-install.after.after'"),
ContainSubstring("Unmounting disk partitions"),
))
vm.Sudo("sync")
time.Sleep(10 * time.Second)
})

By("Ejecting Cdrom", func() {
@@ -139,8 +145,7 @@ var _ = Describe("kairos UKI test", Label("uki"), Ordered, func() {
By("checking corresponding state", func() {
out, err := vm.Sudo("kairos-agent state")
Expect(err).ToNot(HaveOccurred())
// TODO: make agent report uki_mode or something?
Expect(out).To(ContainSubstring("boot: unknown"))
Expect(out).To(ContainSubstring("boot: active_boot"))
currentVersion, err := vm.Sudo(getVersionCmd)
Expect(err).ToNot(HaveOccurred(), currentVersion)

0 comments on commit 551c018

Please sign in to comment.