diff --git a/.github/actions/test/integration/guest/action.yml b/.github/actions/test/integration/guest/action.yml index bc2001b3..ea912acf 100644 --- a/.github/actions/test/integration/guest/action.yml +++ b/.github/actions/test/integration/guest/action.yml @@ -1,38 +1,40 @@ name: guest -description: Build the Ubuntu test guest and the shared test SSH identity +description: Build the CirrOS test guest and the shared test SSH identity runs: using: "composite" steps: - - name: Generate test SSH key and password + - name: Generate the test SSH key shell: bash run: | ssh-keygen -t ed25519 -f "/opt/ssh_host_ed25519_key" -N "" -C "user" -q chmod 600 /opt/ssh_host_ed25519_key SSH_KEY=$(cat /opt/ssh_host_ed25519_key.pub) echo "SSH_KEY=$SSH_KEY" >> $GITHUB_ENV - PASSWORD=$(openssl passwd "password") - echo "PASSWORD=$PASSWORD" >> $GITHUB_ENV - - name: Download ubuntu cloud image + - name: Download the CirrOS test image shell: bash run: | - wget -q "https://cloud-images.ubuntu.com/minimal/releases/noble/release/ubuntu-24.04-minimal-cloudimg-amd64.img" -O /opt/ubuntu.qcow2 + set -Eeuo pipefail + URL="https://download.cirros-cloud.net/0.6.3/cirros-0.6.3-x86_64-disk.img" + SHA256="7d6355852aeb6dbcd191bcda7cd74f1536cfe5cbf8a10495a7283a8396e4b75b" + + wget -q "$URL" -O /opt/cirros.qcow2 + echo "$SHA256 /opt/cirros.qcow2" | sha256sum -c - - - name: Generate raw ubuntu image for CHV + - name: Generate raw CirrOS image for CHV shell: bash run: | - qemu-img convert -p -f qcow2 -O raw /opt/ubuntu.qcow2 /opt/ubuntu.raw + qemu-img convert -p -f qcow2 -O raw /opt/cirros.qcow2 /opt/cirros.raw - - name: Generate ubuntu cloud-init + - name: Generate the CirrOS cloud-init seed shell: bash run: | set -Eeuo pipefail : "${SSH_KEY:?the shared test SSH key is not set}" - : "${PASSWORD:?the guest password is not set}" RENDER_DIR=$(mktemp -d) trap 'rm -rf "$RENDER_DIR"' EXIT - envsubst '${SSH_KEY} ${PASSWORD}' \ + envsubst '${SSH_KEY}' \ < ./.github/actions/test/integration/guest/user-data \ > "$RENDER_DIR/user-data" - genisoimage -output /opt/ubuntu-cloud-init-ds.iso -volid cidata -joliet -rock ./.github/actions/test/integration/guest/meta-data "$RENDER_DIR/user-data" + genisoimage -output /opt/cirros-cloud-init-ds.iso -volid cidata -joliet -rock ./.github/actions/test/integration/guest/meta-data "$RENDER_DIR/user-data" diff --git a/.github/actions/test/integration/guest/meta-data b/.github/actions/test/integration/guest/meta-data index 2162682c..690df252 100644 --- a/.github/actions/test/integration/guest/meta-data +++ b/.github/actions/test/integration/guest/meta-data @@ -1,2 +1,4 @@ -instance-id: test-instance -local-hostname: VM +{ + "instance-id": "test-instance", + "local-hostname": "VM" +} diff --git a/.github/actions/test/integration/guest/user-data b/.github/actions/test/integration/guest/user-data index 9a76afaf..ae5c88e2 100644 --- a/.github/actions/test/integration/guest/user-data +++ b/.github/actions/test/integration/guest/user-data @@ -1,18 +1,11 @@ -#cloud-config -users: - - name: root - shell: /bin/bash - ssh_authorized_keys: - - "${SSH_KEY}" - hashed_passwd: "${PASSWORD}" +#!/bin/sh +set -eu -disable_root: false - -network: - version: 2 - ethernets: - all-interfaces: - match: - name: "*" - dhcp4: true - dhcp6: true +# CirrOS' NoCloud datasource executes user-data as a shell script; it does not +# run cloud-init. Install the shared test key for the default cirros user. +home=/home/cirros +mkdir -p "$home/.ssh" +printf '%s\n' '${SSH_KEY}' > "$home/.ssh/authorized_keys" +chown -R cirros:cirros "$home/.ssh" +chmod 700 "$home/.ssh" +chmod 600 "$home/.ssh/authorized_keys" diff --git a/.github/actions/test/integration/setup/action.yml b/.github/actions/test/integration/setup/action.yml index bfc816ef..3505fb4b 100644 --- a/.github/actions/test/integration/setup/action.yml +++ b/.github/actions/test/integration/setup/action.yml @@ -11,7 +11,7 @@ runs: mkdir -p ~/.ssh chmod 700 ~/.ssh cat > ~/.ssh/config <<'EOF' - Host 192.168.122.* 192.168.222.* + Host 192.168.122.* IdentityFile /opt/ssh_host_ed25519_key IdentitiesOnly yes StrictHostKeyChecking no @@ -20,6 +20,16 @@ runs: ServerAliveInterval 15 ServerAliveCountMax 4 User root + + Host 192.168.222.* + IdentityFile /opt/ssh_host_ed25519_key + IdentitiesOnly yes + StrictHostKeyChecking no + UserKnownHostsFile /dev/null + ConnectTimeout 10 + ServerAliveInterval 15 + ServerAliveCountMax 4 + User cirros EOF chmod 600 ~/.ssh/config diff --git a/.github/actions/test/integration/test/cloudhypervisor/action.yml b/.github/actions/test/integration/test/cloudhypervisor/action.yml index 49e427f3..a9599994 100644 --- a/.github/actions/test/integration/test/cloudhypervisor/action.yml +++ b/.github/actions/test/integration/test/cloudhypervisor/action.yml @@ -13,13 +13,13 @@ runs: IP_HV2="192.168.122.3" scp ./.github/actions/test/integration/test/cloudhypervisor/vm.xml "$IP_HV1:/opt/vm-chv.xml" - scp /opt/ubuntu.raw "$IP_HV1:/var/lib/libvirt/images/ubuntu.raw" - scp /opt/ubuntu-cloud-init-ds.iso "$IP_HV1:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso" + scp /opt/cirros.raw "$IP_HV1:/var/lib/libvirt/images/cirros.raw" + scp /opt/cirros-cloud-init-ds.iso "$IP_HV1:/var/lib/libvirt/images/cirros-cloud-init-ds.iso" # libvirt migration between cloudhypervisor instances does not support storage migration yet - scp /opt/ubuntu.raw "$IP_HV2:/var/lib/libvirt/images/ubuntu.raw" + scp /opt/cirros.raw "$IP_HV2:/var/lib/libvirt/images/cirros.raw" # the cloud-init data is not migrated from source to destination, but needed for the VM to run at the destination - scp /opt/ubuntu-cloud-init-ds.iso "$IP_HV2:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso" + scp /opt/cirros-cloud-init-ds.iso "$IP_HV2:/var/lib/libvirt/images/cirros-cloud-init-ds.iso" - name: Start VM on HyperVisor 1 shell: bash @@ -46,13 +46,13 @@ runs: # Show SSH errors on last 3 attempts for debugging if ssh "\$IP" 'exit'; then echo "VM is up at IP: \$IP" - ssh "\$IP" 'echo "Hello, World!" > /opt/hello.txt' + ssh "\$IP" 'echo "Hello, World!" > /home/cirros/hello.txt' break fi elif ssh "\$IP" 'exit' 2>/dev/null; then echo "VM is up at IP: \$IP" # create a dummy file for verification later - ssh "\$IP" 'echo "Hello, World!" > /opt/hello.txt' + ssh "\$IP" 'echo "Hello, World!" > /home/cirros/hello.txt' break fi if (( i == MAX_ITER )); then @@ -113,7 +113,7 @@ runs: if ssh "\$IP" 'exit' 2>/dev/null; then echo "VM is up at IP: \$IP" # verify the migration by checking the dummy file - if ssh "\$IP" 'test -f /opt/hello.txt'; then + if ssh "\$IP" 'test -f /home/cirros/hello.txt'; then echo "Dummy file exists on VM, migration successful." break else diff --git a/.github/actions/test/integration/test/cloudhypervisor/vm.xml b/.github/actions/test/integration/test/cloudhypervisor/vm.xml index a51e6593..090b7b87 100644 --- a/.github/actions/test/integration/test/cloudhypervisor/vm.xml +++ b/.github/actions/test/integration/test/cloudhypervisor/vm.xml @@ -10,11 +10,11 @@ - + - + diff --git a/.github/actions/test/integration/test/qemu/action.yml b/.github/actions/test/integration/test/qemu/action.yml index 0f229fee..4c1b4b9b 100644 --- a/.github/actions/test/integration/test/qemu/action.yml +++ b/.github/actions/test/integration/test/qemu/action.yml @@ -13,11 +13,11 @@ runs: IP_HV2="192.168.122.3" scp ./.github/actions/test/integration/test/qemu/vm.xml "$IP_HV1:/opt/vm-qemu.xml" - scp /opt/ubuntu.qcow2 "$IP_HV1:/var/lib/libvirt/images/ubuntu.qcow2" - scp /opt/ubuntu-cloud-init-ds.iso "$IP_HV1:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso" + scp /opt/cirros.qcow2 "$IP_HV1:/var/lib/libvirt/images/cirros.qcow2" + scp /opt/cirros-cloud-init-ds.iso "$IP_HV1:/var/lib/libvirt/images/cirros-cloud-init-ds.iso" # the cloud-init data is not migrated from source to destination, but needed for the VM to run at the destination - scp /opt/ubuntu-cloud-init-ds.iso "$IP_HV2:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso" + scp /opt/cirros-cloud-init-ds.iso "$IP_HV2:/var/lib/libvirt/images/cirros-cloud-init-ds.iso" - name: Start VM on HyperVisor 1 shell: bash @@ -44,13 +44,13 @@ runs: # Show SSH errors on last 3 attempts for debugging if ssh "\$IP" 'exit'; then echo "VM is up at IP: \$IP" - ssh "\$IP" 'echo "Hello, World!" > /opt/hello.txt' + ssh "\$IP" 'echo "Hello, World!" > /home/cirros/hello.txt' break fi elif ssh "\$IP" 'exit' 2>/dev/null; then echo "VM is up at IP: \$IP" # create a dummy file for verification later - ssh "\$IP" 'echo "Hello, World!" > /opt/hello.txt' + ssh "\$IP" 'echo "Hello, World!" > /home/cirros/hello.txt' break fi if (( i == MAX_ITER )); then @@ -111,7 +111,7 @@ runs: if ssh "\$IP" 'exit' 2>/dev/null; then echo "VM is up at IP: \$IP" # verify the migration by checking the dummy file - if ssh "\$IP" 'test -f /opt/hello.txt'; then + if ssh "\$IP" 'test -f /home/cirros/hello.txt'; then echo "Dummy file exists on VM, migration successful." break else diff --git a/.github/actions/test/integration/test/qemu/vm.xml b/.github/actions/test/integration/test/qemu/vm.xml index 1fe453b8..8ab1a2da 100644 --- a/.github/actions/test/integration/test/qemu/vm.xml +++ b/.github/actions/test/integration/test/qemu/vm.xml @@ -14,12 +14,12 @@ - + - +