Skip to content

Commit

Permalink
Add test for targets
Browse files Browse the repository at this point in the history
Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka committed Sep 23, 2024
1 parent 8d9de47 commit 8c0cd12
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 25 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/image-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ jobs:
needs:
- core-ubuntu-24-lts

install-target:
uses: ./.github/workflows/reusable-install-test-target.yaml
with:
flavor: ubuntu
flavor_release: "24.04"
secureboot: false
needs:
- core-ubuntu-24-lts

install-secureboot:
uses: ./.github/workflows/reusable-install-test.yaml
with:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ jobs:
- flavor: opensuse
flavorRelease: leap-15.6
secureboot: false
install-target:
uses: ./.github/workflows/reusable-install-test-target.yaml
with:
flavor: ${{ matrix.flavor }}
flavor_release: ${{ matrix.flavorRelease }}
needs:
- core
strategy:
fail-fast: true
matrix:
include:
- flavor: "ubuntu"
flavorRelease: "24.04"
install-secureboot:
uses: ./.github/workflows/reusable-install-test.yaml
with:
Expand Down Expand Up @@ -414,6 +427,8 @@ jobs:
- core
- standard
- install
- install-target
- install-secureboot
- zfs
- acceptance
- bundles
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-build-flavor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
--FLAVOR_RELEASE=${{ inputs.flavor_release }} \
--BASE_IMAGE=${{ inputs.base_image }} \
--MODEL=${{ inputs.model }} \
--FAMILY=${{ inputs.family }} --KAIROS_AGENT_DEV_BRANCH=accept_devices
--FAMILY=${{ inputs.family }}
sudo mv build/* .
sudo rm -rf build
- name: Install kairos-agent (for versioneer)
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/reusable-install-test-target.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Reusable workflow - install test target

on:
workflow_call:
inputs:
flavor:
required: true
type: string
flavor_release:
required: true
type: string
secureboot:
required: false
type: boolean

permissions: read-all
jobs:
test:
runs-on: kvm
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- run: |
git fetch --prune --unshallow
- name: Download ISO
id: iso
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: kairos-${{ inputs.flavor }}-${{ inputs.flavor_release}}.iso.zip
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
with:
go-version-file: tests/go.mod
cache-dependency-path: tests/go.sum
- name: Block all traffic to metadata ip # For cloud runners, the metadata ip can interact with our test machines
run: |
sudo iptables -I INPUT -s 169.254.169.254 -j DROP
sudo iptables -I OUTPUT -d 169.254.169.254 -j DROP
- name: Enable KVM group perms
run: |
sudo apt-get update
sudo apt-get install -y libvirt-clients libvirt-daemon-system libvirt-daemon virtinst bridge-utils qemu qemu-system-x86 qemu-system-x86 qemu-utils qemu-kvm acl udev
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
# sudo udevadm control --reload-rules
# sudo udevadm trigger --name-match=kvm
# sudo usermod -a -G kvm,libvirt $USER
#
# TODO: Switch back to the above solution when we switch to the github runners
# https://askubuntu.com/a/1081326
sudo setfacl -m u:runner:rwx /dev/kvm
- name: Tests
env:
USE_QEMU: true
KVM: true
MEMORY: 4000
CPUS: 2
DRIVE_SIZE: 30000
CREATE_VM: true
FLAVOR: ${{ inputs.flavor }}
run: |
if [ "${{ inputs.secureboot }}" = "true" ]; then
export FIRMWARE=/usr/share/OVMF/OVMF_CODE.fd
fi
ls *.iso
export ISO=$PWD/$(ls *.iso)
echo "ISO is: $ISO"
cp tests/go.* .
go run github.com/onsi/ginkgo/v2/ginkgo -v --label-filter "install-test-target" --fail-fast -r ./tests
- uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4
if: failure()
with:
name: ${{ inputs.flavor }}.logs.zip
path: tests/**/logs/*
if-no-files-found: warn
48 changes: 24 additions & 24 deletions tests/install_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ var _ = Describe("kairos install test different targets", Label("install-test-ta
uuid, err := vm.Sudo("lsblk /dev/vda -o UUID -n")

cc := fmt.Sprintf(`#cloud-config
install:
auto: true
reboot: true
device: /dev/disk/by-uuid/%s
stages:
initramfs:
- name: "Set user and password"
users:
kairos:
passwd: "kairos"
hostname: kairos-{{ trunc 4 .Random }}
install:
auto: true
reboot: true
device: /dev/disk/by-uuid/%s
stages:
initramfs:
- name: "Set user and password"
users:
kairos:
passwd: "kairos"
hostname: kairos-{{ trunc 4 .Random }}
`, uuid)

By("Using the following config")
Expand Down Expand Up @@ -74,18 +74,18 @@ var _ = Describe("kairos install test different targets", Label("install-test-ta
label, err := vm.Sudo("lsblk /dev/vda -o LABEL -n")

cc := fmt.Sprintf(`#cloud-config
install:
auto: true
reboot: true
device: /dev/disk/by-label/%s
stages:
initramfs:
- name: "Set user and password"
users:
kairos:
passwd: "kairos"
hostname: kairos-{{ trunc 4 .Random }}
install:
auto: true
reboot: true
device: /dev/disk/by-label/%s
stages:
initramfs:
- name: "Set user and password"
users:
kairos:
passwd: "kairos"
hostname: kairos-{{ trunc 4 .Random }}
`, label)

By("Using the following config")
Expand Down

0 comments on commit 8c0cd12

Please sign in to comment.