Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/actions/test/integration/guest/action.yml
Original file line number Diff line number Diff line change
@@ -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"
6 changes: 4 additions & 2 deletions .github/actions/test/integration/guest/meta-data
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
instance-id: test-instance
local-hostname: VM
{
"instance-id": "test-instance",
"local-hostname": "VM"
}
27 changes: 10 additions & 17 deletions .github/actions/test/integration/guest/user-data
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 11 additions & 1 deletion .github/actions/test/integration/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<cpu mode='host-passthrough' check='none' migratable='on' />
<devices>
<disk type='file' device='disk'>
<source file='/var/lib/libvirt/images/ubuntu.raw' />
<source file='/var/lib/libvirt/images/cirros.raw' />
<target dev='hda' bus='virtio' />
</disk>
<disk type='file' device='cdrom'>
<source file='/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso' />
<source file='/var/lib/libvirt/images/cirros-cloud-init-ds.iso' />
<target dev='hdb' bus='virtio' />
<readonly />
</disk>
Expand Down
12 changes: 6 additions & 6 deletions .github/actions/test/integration/test/qemu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/test/integration/test/qemu/vm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' />
<source file='/var/lib/libvirt/images/ubuntu.qcow2' />
<source file='/var/lib/libvirt/images/cirros.qcow2' />
<target dev='vda' bus='virtio' />
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' />
<source file='/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso' />
<source file='/var/lib/libvirt/images/cirros-cloud-init-ds.iso' />
<target dev='vdb' bus='virtio' />
<readonly />
</disk>
Expand Down