diff --git a/.github/actions/test/integration/build/action.yml b/.github/actions/test/integration/build/action.yml index c4e1e97d..786b5210 100644 --- a/.github/actions/test/integration/build/action.yml +++ b/.github/actions/test/integration/build/action.yml @@ -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 diff --git a/.github/actions/test/integration/setup/action.yml b/.github/actions/test/integration/setup/action.yml index 9b321cdc..915b282b 100644 --- a/.github/actions/test/integration/setup/action.yml +++ b/.github/actions/test/integration/setup/action.yml @@ -39,7 +39,7 @@ 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 @@ -47,6 +47,44 @@ runs: 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" @@ -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 @@ -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 diff --git a/.github/actions/test/integration/test/action.yml b/.github/actions/test/integration/test/action.yml index f4ea05b8..7b58e416 100644 --- a/.github/actions/test/integration/test/action.yml +++ b/.github/actions/test/integration/test/action.yml @@ -20,35 +20,40 @@ 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 @@ -56,35 +61,40 @@ 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 - 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." @@ -92,7 +102,7 @@ runs: 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 @@ -100,10 +110,10 @@ runs: 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 @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 28d78595..9348a66d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,5 @@ name: test hypervisor capabilities on: - push: - branches: - - ci-test-virtualization workflow_run: workflows: - nightly