Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/actions/test/integration/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ runs:
env:
REPO: ghcr.io/gardenlinux/gardenlinux-ccloud
TAG: ${{ inputs.image_tag }}
ESP_SIZE: 4 # GiB
DISK_SIZE: 8 # GiB
ESP_SIZE: 2 # GiB
DISK_SIZE: 8 # GiB
run: |
echo "REPO=$REPO" >> $GITHUB_ENV
echo "TAG=$TAG" >> $GITHUB_ENV
Expand Down
83 changes: 40 additions & 43 deletions .github/actions/test/integration/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,52 @@ runs:
sudo virsh define ./.github/actions/test/integration/setup/hv2.xml
sudo virsh start HV2

- name: Wait for HyperVisors to be ready
- name: Configure SSH and libvirt on HyperVisors
shell: bash
run: |
KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"
MAX_ITER=30

setup_hv() {
local IP="$1"

# Configure SSH between HyperVisors
scp $SSH_OPTS /opt/ssh_host_ed25519_key "$USER@$IP:/opt/ssh_host_ed25519_key"
ssh $SSH_OPTS "$USER@$IP" << EOF
chmod 700 /root/.ssh
echo "" > /root/.ssh/config
echo "Host 192.168.122.*" >> /root/.ssh/config
echo " StrictHostKeyChecking no" >> /root/.ssh/config
echo " UserKnownHostsFile /dev/null" >> /root/.ssh/config
echo " IdentityFile /opt/ssh_host_ed25519_key" >> /root/.ssh/config
echo " IdentitiesOnly yes" >> /root/.ssh/config
echo " User root" >> /root/.ssh/config
chmod 600 /root/.ssh/config
chmod 600 /opt/ssh_host_ed25519_key
EOF

# Set up libvirt storage pool and network
scp $SSH_OPTS ./.github/actions/test/integration/setup/virbr-vm.xml "$USER@$IP:/opt/virbr-vm.xml"
ssh $SSH_OPTS "$USER@$IP" << EOF
systemctl start libvirtd

virsh pool-destroy default || true
virsh pool-undefine default || true
virsh pool-define-as default dir --target /var/lib/libvirt/images
virsh pool-build default
virsh pool-start default
virsh pool-autostart default

virsh net-destroy default || true
virsh net-undefine default || true
virsh net-define /opt/virbr-vm.xml
virsh net-start default
virsh net-autostart default
EOF
}

wait_for_ssh() {
local VM_NAME="$1"

Expand All @@ -56,8 +94,7 @@ runs:
echo "No IP address found for $VM_NAME. Retrying..."
elif ssh $SSH_OPTS "$USER@$IP" 'exit' 2>/dev/null; then
echo "$VM_NAME is up at IP: $IP"
scp $SSH_OPTS ./.github/actions/test/integration/setup/virbr-vm.xml "$USER@$IP:/opt/virbr-vm.xml"
scp $SSH_OPTS /opt/ssh_host_ed25519_key "$USER@$IP:/opt/ssh_host_ed25519_key"
setup_hv "$IP"
break
fi
if (( i == MAX_ITER )); then
Expand All @@ -72,43 +109,3 @@ runs:

wait_for_ssh HV1
wait_for_ssh HV2

- name: Configure SSH between HyperVisors
uses: appleboy/ssh-action@v1
with:
host: "192.168.122.2,192.168.122.3"
username: root
key_path: /opt/ssh_host_ed25519_key
script: |
chmod 700 /root/.ssh
echo "" > /root/.ssh/config
echo "Host 192.168.122.*" >> /root/.ssh/config
echo " StrictHostKeyChecking no" >> /root/.ssh/config
echo " UserKnownHostsFile /dev/null" >> /root/.ssh/config
echo " IdentityFile /opt/ssh_host_ed25519_key" >> /root/.ssh/config
echo " IdentitiesOnly yes" >> /root/.ssh/config
echo " User root" >> /root/.ssh/config
chmod 600 /root/.ssh/config
chmod 600 /opt/ssh_host_ed25519_key

- name: Set up network and storage configuration on HyperVisors
uses: appleboy/ssh-action@v1
with:
host: "192.168.122.2,192.168.122.3"
username: root
key_path: /opt/ssh_host_ed25519_key
script: |
systemctl start libvirtd

virsh pool-destroy default || true
virsh pool-undefine default || true
virsh pool-define-as default dir --target /var/lib/libvirt/images
virsh pool-build default
virsh pool-start default
virsh pool-autostart default

virsh net-destroy default || true
virsh net-undefine default || true
virsh net-define /opt/virbr-vm.xml
virsh net-start default
virsh net-autostart default
91 changes: 51 additions & 40 deletions .github/actions/test/integration/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,90 +20,100 @@ runs:
scp $SSH_OPTS /opt/ubuntu-cloud-init-ds.iso "$USER@$IP_HV2:/var/lib/libvirt/images/ubuntu-cloud-init-ds.iso"

- name: Start VM on HyperVisor 1
uses: appleboy/ssh-action@v1
with:
host: 192.168.122.2
username: root
key_path: /opt/ssh_host_ed25519_key
script: |
shell: bash
run: |
KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"
IP_HV1="192.168.122.2"

ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
virsh define /opt/vm.xml
virsh start VM
EOF

- name: Wait for VM to be ready
uses: appleboy/ssh-action@v1
with:
host: 192.168.122.2
username: root
key_path: /opt/ssh_host_ed25519_key
script: |
shell: bash
run: |
KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"
IP_HV1="192.168.122.2"

ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"

MAX_ITER=40
for ((i=1; i<=MAX_ITER; i++)); do
IP=$(virsh domifaddr VM | awk '/ipv4/ {print $4}' | cut -d'/' -f1)
if [ -z "$IP" ]; then
IP=\$(virsh domifaddr VM | awk '/ipv4/ {print \$4}' | cut -d'/' -f1)
if [ -z "\$IP" ]; then
echo "No IP address found for VM. Retrying..."
elif ssh $SSH_OPTS "$USER@$IP" 'exit' 2>/dev/null; then
echo "VM is up at IP: $IP"
elif ssh \$SSH_OPTS "\$USER@\$IP" 'exit' 2>/dev/null; then
echo "VM is up at IP: \$IP"
# create a dummy file for verification later
ssh $SSH_OPTS "$USER@$IP" 'echo "Hello, World!" > /opt/hello.txt'
ssh \$SSH_OPTS "\$USER@\$IP" 'echo "Hello, World!" > /opt/hello.txt'
break
fi
if (( i == MAX_ITER )); then
echo "Timeout waiting for VM to respond to SSH."
cat /var/log/VM.log
exit 1
fi
echo "Waiting for VM to respond to SSH... ($i/$MAX_ITER)"
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
sleep 10
done
EOF

- name: Mirgrate the VM to HyperVisor 2
uses: appleboy/ssh-action@v1
with:
host: 192.168.122.2
username: root
key_path: /opt/ssh_host_ed25519_key
script: |
shell: bash
run: |
KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"
IP_HV1="192.168.122.2"

ssh $SSH_OPTS "$USER@$IP_HV1" << EOF
USER="root"
HV2_IP="192.168.122.3"
IP_HV2="192.168.122.3"

virsh migrate --persistent --undefinesource --copy-storage-all --live VM qemu+ssh://$USER@$HV2_IP/system
virsh migrate --persistent --undefinesource --copy-storage-all --live VM qemu+ssh://\$USER@\$IP_HV2/system
if virsh dominfo VM &>/dev/null; then
echo "VM is still present on HV1 after migration!"
exit 1
fi
EOF

- name: Verify VM status on HyperVisor 2
uses: appleboy/ssh-action@v1
with:
host: 192.168.122.3
username: root
key_path: /opt/ssh_host_ed25519_key
command_timeout: 30m
script: |
if virsh dominfo VM | awk '/State:/ {print $2}' | grep -q "running"; then
shell: bash
run: |
KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"
IP_HV2="192.168.122.3"

ssh $SSH_OPTS "$USER@$IP_HV2" << EOF
if virsh dominfo VM | awk '/State:/ {print \$2}' | grep -q "running"; then
echo "VM is running on HV2."
else
echo "VM is not running on HV2."
exit 1
fi

KEY=/opt/ssh_host_ed25519_key
SSH_OPTS="-i $KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
SSH_OPTS="-i \$KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
USER="root"
# waiting for the IP to be visible to the new HyperVisor via DHCP takes WAYYYYYYY too long
# the IP is static, so we can just use it directly
IP="192.168.222.2"

MAX_ITER=40
for ((i=1; i<=MAX_ITER; i++)); do
if ssh $SSH_OPTS "$USER@$IP" 'exit' 2>/dev/null; then
echo "VM is up at IP: $IP"
if ssh \$SSH_OPTS "\$USER@\$IP" 'exit' 2>/dev/null; then
echo "VM is up at IP: \$IP"
# verify the migration by checking the dummy file
if ssh $SSH_OPTS "$USER@$IP" 'test -f /opt/hello.txt'; then
if ssh \$SSH_OPTS "\$USER@\$IP" 'test -f /opt/hello.txt'; then
echo "Dummy file exists on VM, migration successful."
break
else
Expand All @@ -116,6 +126,7 @@ runs:
cat /var/log/VM.log
exit 1
fi
echo "Waiting for VM to respond to SSH... ($i/$MAX_ITER)"
echo "Waiting for VM to respond to SSH... (\$i/\$MAX_ITER)"
sleep 10
done
EOF
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: test hypervisor capabilities
on:
push:
branches:
- ci-test-virtualization
workflow_run:
workflows:
- nightly
Expand Down