diff --git a/.github/workflows/uki.yaml b/.github/workflows/uki.yaml index 1621c78b1..58796c687 100644 --- a/.github/workflows/uki.yaml +++ b/.github/workflows/uki.yaml @@ -162,7 +162,7 @@ jobs: earthly +uki-iso --BASE_IMAGE=ttl.sh/ubuntu-2310-${{ github.head_ref || github.ref }}:24h - name: Create datasource iso 🔧 run: | - earthly +datasource-iso --CLOUD_CONFIG=tests/assets/autoinstall.yaml + earthly +datasource-iso --CLOUD_CONFIG=tests/assets/uki-install.yaml - name: Run tests 🔧 env: USE_QEMU: true @@ -234,7 +234,7 @@ jobs: --BASE_IMAGE=ttl.sh/fedora-38-${{ github.head_ref || github.ref }}:24h - name: Create datasource iso 🔧 run: | - earthly +datasource-iso --CLOUD_CONFIG=tests/assets/autoinstall.yaml + earthly +datasource-iso --CLOUD_CONFIG=tests/assets/uki-install.yaml - name: Run tests 🔧 env: USE_QEMU: true diff --git a/.github/workflows/uki_branches.yaml b/.github/workflows/uki_branches.yaml index 8f390864e..4000e1cee 100644 --- a/.github/workflows/uki_branches.yaml +++ b/.github/workflows/uki_branches.yaml @@ -72,7 +72,7 @@ jobs: earthly +uki-iso --BASE_IMAGE=ttl.sh/ubuntu-2310-${{ github.sha }}:24h - name: Create datasource iso 🔧 run: | - earthly +datasource-iso --CLOUD_CONFIG=tests/assets/autoinstall.yaml + earthly +datasource-iso --CLOUD_CONFIG=tests/assets/uki-install.yaml - name: Run tests 🔧 env: USE_QEMU: true diff --git a/tests/assets/uki-install.yaml b/tests/assets/uki-install.yaml new file mode 100644 index 000000000..0247e91c3 --- /dev/null +++ b/tests/assets/uki-install.yaml @@ -0,0 +1,36 @@ +#cloud-config + +install: + auto: true + reboot: true + device: /dev/vda + grub_options: + extra_cmdline: "rd.immucore.debug foobarzz" + +debug: true +strict: true + +stages: + initramfs: + - name: "Set user and password" + users: + kairos: + passwd: "kairos" + hostname: kairos-{{ trunc 4 .Random }} + after-reset: + - commands: + - | + /bin/bash <<'EOF' + #!/bin/bash + + set -e + echo "Creating a file in COS_PERSISTENT" + umount /oem || true + # Close all encrypted partitions + for p in $(ls /dev/mapper/vda*); do cryptsetup close $p; done + /usr/lib/systemd/systemd-cryptsetup attach persistent $(findfs PARTLABEL=persistent) - tpm2-device=auto + mount /dev/mapper/persistent /usr/local + touch /usr/local/after-reset-file + umount /dev/mapper/persistent + cryptsetup close /dev/mapper/persistent + EOF diff --git a/tests/keys/DB.auth b/tests/keys/db.auth similarity index 100% rename from tests/keys/DB.auth rename to tests/keys/db.auth diff --git a/tests/keys/DB.der b/tests/keys/db.der similarity index 100% rename from tests/keys/DB.der rename to tests/keys/db.der diff --git a/tests/keys/DB.esl b/tests/keys/db.esl similarity index 100% rename from tests/keys/DB.esl rename to tests/keys/db.esl diff --git a/tests/keys/DB.key b/tests/keys/db.key similarity index 100% rename from tests/keys/DB.key rename to tests/keys/db.key diff --git a/tests/keys/DB.pem b/tests/keys/db.pem similarity index 100% rename from tests/keys/DB.pem rename to tests/keys/db.pem diff --git a/tests/uki_test.go b/tests/uki_test.go index 60a304f86..276e48a27 100644 --- a/tests/uki_test.go +++ b/tests/uki_test.go @@ -153,5 +153,22 @@ var _ = Describe("kairos UKI test", Label("uki"), Ordered, func() { stateContains(vm, "system.os.name", "alpine", "opensuse", "ubuntu", "debian", "fedora") stateContains(vm, "kairos.flavor", "alpine", "opensuse", "ubuntu", "debian", "fedora") }) + + By("rebooting to recovery") + out, err := vm.Sudo("kairos-agent bootentry --select recovery") + Expect(err).ToNot(HaveOccurred(), out) + vm.Reboot() + vm.EventuallyConnects(1200) + + By("resetting") + out, err = vm.Sudo("kairos-agent --debug reset --unattended") + Expect(err).ToNot(HaveOccurred(), out) + vm.Reboot() + vm.EventuallyConnects(1200) + + By("checking if after-reset was run") + out, err = vm.Sudo("ls /usr/local/after-reset-file") + Expect(err).ToNot(HaveOccurred(), out) + Expect(out).ToNot(MatchRegexp("No such file or directory")) }) })