From d0abe79886fb1e30382e9fcdbfaa954bef8659bb Mon Sep 17 00:00:00 2001 From: "Jason N." <33561705+JasonN3@users.noreply.github.com> Date: Thu, 14 Mar 2024 10:52:21 -0400 Subject: [PATCH] just wait for ssh to be open --- .github/workflows/build-and-test.yml | 20 +++++--------------- Makefile | 28 +++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 07c688d..5e3f418 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -161,10 +161,11 @@ jobs: with: submodules: recursive - - name: Ensure qemu is installed + - name: Install test tools run: | sudo apt-get update - sudo apt-get install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils + sudo apt-get install -y make + make install-test-deps - name: Create disk run: | @@ -253,7 +254,7 @@ jobs: timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done" (tail -f vm.stdin | nc localhost 4321 | tee vm.stdout) & - timeout 30m bash -c "while ! (grep 'login:' vm.stdout); do sleep 1; done" + timeout 30m bash -c "while ! (echo > /dev/tcp/${VM_IP}/${VM_PORT}); do sleep 1; done" if ! (echo > /dev/tcp/${VM_IP}/${VM_PORT}) then @@ -261,17 +262,6 @@ jobs: fi echo "VM ready for tests at IP ${VM_IP}:${VM_PORT}" - echo "Creating Ansible inventory" - cat << EOF > ansible_inventory - ungrouped: - hosts: - vm: - ansible_host: ${VM_IP} - ansible_port: ${VM_PORT} - ansible_user: ${VM_USER} - ansible_password: ${VM_PASS} - ansible_ssh_common_args: '-o StrictHostKeyChecking=no' - EOF - #make test-vm + make test-vm VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS} kill $QEMU_PID diff --git a/Makefile b/Makefile index 9749bd1..04b8c50 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,8 @@ SECURE_BOOT_KEY_URL = # Cache DNF_CACHE = +PACKAGE_MANAGER = dnf + # Functions ## Formatting = lowercase # Get a list of templates for the feature @@ -205,7 +207,13 @@ clean: rm -f $(_BASE_DIR)/*.log || true install-deps: - dnf install -y lorax xorriso skopeo flatpak dbus-daemon ostree coreutils gettext git + if [[ "$(PACKAGE_MANAGER)" =~ apt.* ]]; then $(PACKAGE_MANAGER) update; fi + $(PACKAGE_MANAGER) install -y lorax xorriso skopeo flatpak dbus-daemon ostree coreutils gettext git + +install-test-deps: + if [[ "$(PACKAGE_MANAGER)" =~ apt.* ]]; then $(PACKAGE_MANAGER) update; fi + $(PACKAGE_MANAGER) install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat socat jq isomd5sum ansible make coreutils squashfs-tools + test: test-iso test-vm @@ -213,8 +221,6 @@ test-iso: $(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso))) $(eval _VARS = VERSION FLATPAK_REMOTE_NAME _FLATPAK_REPO_URL) - sudo apt-get update - sudo apt-get install -y squashfs-tools sudo modprobe loop sudo mkdir /mnt/iso /mnt/install sudo mount -o loop deploy.iso /mnt/iso @@ -241,9 +247,21 @@ test-iso: sudo umount /mnt/install sudo umount /mnt/iso -test-vm: +ansible_inventory: + cat << EOF > ansible_inventory + ungrouped: + hosts: + vm: + ansible_host: ${VM_IP} + ansible_port: ${VM_PORT} + ansible_user: ${VM_USER} + ansible_password: ${VM_PASS} + ansible_ssh_common_args: '-o StrictHostKeyChecking=no' + EOF + +test-vm: ansible_inventory $(eval _TESTS = $(filter-out README.md,$(shell ls tests/vm))) chmod +x $(foreach test,$(_TESTS),tests/vm/$(test)) for test in $(_TESTS); do ./tests/vm/$${test} deploy.iso; done -.PHONY: clean install-deps test test-iso test-vm +.PHONY: clean install-deps install-test-deps test test-iso test-vm