From 62d5c9a2a2dfe67def549cbfcd9da4221c49960e Mon Sep 17 00:00:00 2001 From: "Jason N." <33561705+JasonN3@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:37:03 -0400 Subject: [PATCH] don't call repeatedly --- .github/workflows/test_deployment.yml | 19 ++-------- test/vm/Makefile | 51 ++++++++------------------- 2 files changed, 18 insertions(+), 52 deletions(-) diff --git a/.github/workflows/test_deployment.yml b/.github/workflows/test_deployment.yml index 0a420ea..1cbdb01 100644 --- a/.github/workflows/test_deployment.yml +++ b/.github/workflows/test_deployment.yml @@ -85,28 +85,15 @@ jobs: with: name: ${{ format('{0}-{1}', needs.load_vars.outputs.IMAGE_NAME, matrix.version) }} - - name: Add Kickstart and Grub options to ISO - run: | - make test/vm/files/install.iso ISO_NAME=${{ format('{0}-{1}', needs.load_vars.outputs.IMAGE_NAME, matrix.version) }}.iso - - - name: Create VM disk - run: | - make test/vm/files/disk.qcow2 - - - name: Install the test VM - run: | - make test/vm/install_os - - - name: Start the test VM + - name: Run VM Tests env: VM_USER: core VM_PASS: foobar VM_IP: "127.0.0.1" VM_PORT: "5555" run: | - make test/vm/start_vm - - make test/vm VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS} \ + make test/vm ISO_NAME=${{ format('{0}-{1}', needs.load_vars.outputs.IMAGE_NAME, matrix.version) }}.iso \ + VM_IP=${VM_IP} VM_PORT=${VM_PORT} VM_USER=${VM_USER} VM_PASS=${VM_PASS} \ ARCH=${{ needs.load_vars.outputs.ARCH}} \ IMAGE_NAME=${{ needs.load_vars.outputs.IMAGE_NAME}} \ IMAGE_REPO=${{ needs.load_vars.outputs.IMAGE_REPO}} \ diff --git a/test/vm/Makefile b/test/vm/Makefile index 8bb5204..7f0eb5a 100644 --- a/test/vm/Makefile +++ b/test/vm/Makefile @@ -1,38 +1,14 @@ -VM_TESTS=$(filter-out README.md Makefile files,$(wildcard *)) +VM_TESTS=$(wildcard install_*) $(if $(FLATPAK_REMOTE_REFS),$(wildcard flatpak_*))$(if $(FLATPAK_DIR),$(wildcard flatpak_*)) -# Get a list of tests for the feature -# $1 = test type -# $2 = feature -define run_tests - tests="$(shell ls tests/$(1)/$(2)_*)"; \ - if [ -n "$$tests" ]; \ - then \ - chmod +x $$tests; \ - for test in $$tests; \ - do \ - $(foreach var,$(_VARS),$(var)=$($(var))) ./$${test}; \ - RC=$$?; \ - if [ $$RC != 0 ]; \ - then \ - exit $$RC; \ - fi; \ - done; \ - fi -endef +all: $(ISO_TESTS) clean -$(VM_TESTS): start_vm ansible_inventory +$(ISO_TESTS): start_vm ansible_inventory $(eval _VARS = IMAGE_REPO IMAGE_NAME IMAGE_TAG) ansible -i ansible_inventory -m ansible.builtin.wait_for_connection vm - # install tests - $(call run_tests,vm,install) - - # flapak tests - if [ -n "$(FLATPAK_REMOTE_REFS)" ]; \ - then \ - $(call run_tests,vm,flatpak); \ - fi + chmod +x $@ + $(foreach var,$(_VARS),$(var)=$($(var))) ./$@ ansible_inventory: echo "ungrouped:" > ansible_inventory @@ -63,9 +39,13 @@ files/grub.cfg: files/mnt/iso .PHONY: clean clean: files/mnt/iso - sudo umount files/mnt/iso - rmdir files/mnt/iso - + $(if $(wildcard files/mnt/iso),sudo umount files/mnt/iso) + $(if $(wildcard files/mnt/iso),rmdir files/mnt/iso) + $(if $(wildcard ansible_inventory),rm ansible_inventory) + $(if $(wildcard files/install.iso),rm files/install.iso) + $(if $(wildcard files/disk.qcow2),rm files/disk.qcow2) + $(if $(wildcard install_os),rm install_os) + $(if $(wildcard start_vm),rm start_vm) files/install.iso: files/grub.cfg xorriso -dialog on << EOF @@ -83,18 +63,17 @@ files/install.iso: files/grub.cfg files/disk.qcow2: qemu-img create -f qcow2 files/disk.qcow2 50G -.PHONY: install_os install_os: files/install.iso files/disk.qcow2 timeout 1h qemu-system-x86_64 -name "Anaconda" -boot d -m 4096 -cpu qemu64 -display none -cdrom files/install.iso -smp 2 -hda files/disk.qcow2 -serial telnet:localhost:4321,server=on,wait=off & QEMU_PID=$$! echo "PID: $$QEMU_PID" timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done" (nc localhost 4321 | tee vm.stdout) & wait $$QEMU_PID + touch install_os .ONESHELL: -.PHONY: start_vm -start_vm: +start_vm: install_os mkfifo vm.stdin qemu-system-x86_64 -name "Anaconda" \ -m 4096 -cpu qemu64 -display none -smp 2 \ @@ -117,4 +96,4 @@ start_vm: fi echo "VM ready for tests at IP $(VM_IP):$(VM_PORT)" - $(MAKE) ansible_inventory VM_IP=$(VM_IP) VM_PORT=$(VM_PORT) VM_USER=core VM_PASS=foobar \ No newline at end of file + touch start_vm \ No newline at end of file