Skip to content

Commit

Permalink
Parallel tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Cassany <dcassany@suse.com>
  • Loading branch information
davidcassany committed Oct 31, 2023
1 parent fd31ea1 commit c0f8fc2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 36 deletions.
82 changes: 59 additions & 23 deletions .github/workflows/build_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ jobs:
x86_64)
echo "buildon='ubuntu-latest'" >> $GITHUB_OUTPUT
echo "testson='macos-latest'" >> $GITHUB_OUTPUT
echo "tests=['test-upgrade', 'test-recovery', 'test-fallback', 'test-fsck', 'test-grubfallback']" >> $GITHUB_OUTPUT ;;
echo "tests=['testsA', 'testsB']" >> $GITHUB_OUTPUT
echo "testsA='test-upgrade test-fallback'" >> $GITHUB_OUTPUT
echo "testsB='test-recovery test-fsck test-grubfallback'" >> $GITHUB_OUTPUT ;;
aarch64)
echo "buildon=['self-hosted', 'arm64']" >> $GITHUB_OUTPUT
echo "testson=['self-hosted', 'arm64']" >> $GITHUB_OUTPUT
echo "tests=['test-smoke']" >> $GITHUB_OUTPUT ;;
echo "tests=['testsA']" >> $GITHUB_OUTPUT
echo "testsA='test-smoke'" >> $GITHUB_OUTPUT ;;
esac
build-iso:
Expand Down Expand Up @@ -75,7 +78,7 @@ jobs:
path: /tmp/*.iso
key: ${{ env.cache-name }}-${{ hashFiles('Dockerfile', '**/go.sum', '**/pkg/**', '**/examples/**', '**/cmd/**', '**/vendor/**', '**/Makefile', '**/main.go') }}
enableCrossOsArchive: true

build-disk:
needs: detect
runs-on: ${{ fromJson(needs.detect.outputs.build-runs-on) }}
Expand Down Expand Up @@ -121,7 +124,7 @@ jobs:
enableCrossOsArchive: true

tests-matrix:
needs:
needs:
- build-disk
- detect
runs-on: ${{ fromJson(needs.detect.outputs.tests-runs-on) }}
Expand Down Expand Up @@ -154,45 +157,80 @@ jobs:
key: ${{ env.cache-name }}-${{ hashFiles('Dockerfile', '**/go.sum', '**/pkg/**', '**/examples/**', '**/cmd/**', '**/vendor/**', '**/Makefile', '**/main.go') }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- if: ${{ env.ARCH == 'x86_64' }}
- if: ${{ env.ARCH == 'x86_64' }}
name: Run VM script dependencies
run: |
brew install bash coreutils
- if: ${{ env.ARCH == 'x86_64' }}
name: Prepare test (x86_64)
- if: ${{ env.ARCH == 'x86_64' }}
name: Prepare tests (x86_64)
env:
DIS: $${{ matrix.test }}
EXPLORE: $${{ needs.detect.outputs }}
# TESTS: $${{ fromJson(needs.detect.outputs[matrix.test]) }}
run: |
qemu-system-x86_64 -cpu help
sysctl -n machdep.cpu.brand_string
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 ELMNTL_ACCEL=hvf ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_FIRMWARE=$(find /usr/local/Cellar/qemu -name edk2-${{ env.ARCH }}-code.fd -print -quit) prepare-test
- if: ${{ env.ARCH == 'aarch64' }}
name: Prepare test (aarch64)
echo $DIS
echo $EXPLORE
prefix="expanded."
firmware=$(find /usr/local/Cellar/qemu -name edk2-${{ env.ARCH }}-code.fd -print -quit)
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 \
ELMNTL_ACCEL=hvf ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_PREFIX=${prefix} \
ELMNTL_FIRMWARE=${firmware} prepare-test
# To wait until disk expands
make DISK=$(pwd)/tests/expanded.testdisk.qcow2 test-active
# stop VM but not clean
make ELMNTL_PREFIX=${prefix} test-stop
- if: ${{ env.ARCH == 'aarch64' }}
name: Prepare tests (aarch64)
run: |
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 ELMNTL_ACCEL=none ELMNTL_MACHINETYPE=virt ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_FIRMWARE=/usr/share/AAVMF/AAVMF_CODE.fd prepare-test
prefix="expanded."
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 ELMNTL_PREFIX=${prefix} \
ELMNTL_ACCEL=none ELMNTL_MACHINETYPE=virt ELMNTL_TARGETARCH=${{ env.ARCH }} \
ELMNTL_FIRMWARE=/usr/share/AAVMF/AAVMF_CODE.fd prepare-test
# To wait until disk expands
make DISK=$(pwd)/tests/expanded.testdisk.qcow2 test-active
# stop VM but not clean
make ELMNTL_PREFIX=${prefix} test-stop
- name: Run ${{ matrix.test }}
env:
TESTS: $${{ fromJson(needs.detect.outputs[matrix.test]) }}
run: |
make DISK=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.qcow2 ${{ matrix.test }}
echo $TESTS
firmware=$(find /usr/local/Cellar/qemu -name edk2-${{ env.ARCH }}-code.fd -print -quit)
for t in $TESTS; do
prefix="${t}."
(make DISK=$(pwd)/tests/expanded.testdisk.qcow2 \
ELMNTL_ACCEL=hvf ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_PREFIX=${prefix} \
ELMNTL_FIRMWARE=${firmware} ${t} && \
make ELMNTL_PREFIX=${prefix} test-stop) &
done
wait
# TODO include other logs SUT collects on failure
- name: Upload serial console for ${{ matrix.test }}
uses: actions/upload-artifact@v3
if: always()
with:
name: serial-${{ env.ARCH }}-${{ env.FLAVOR }}-${{ matrix.test }}.log
path: tests/serial.log
path: tests/*serial.log
if-no-files-found: error
- name: Upload qemu stdout for ${{ matrix.test }}
uses: actions/upload-artifact@v3
if: failure()
with:
name: vmstdout-${{ env.ARCH }}-${{ env.FLAVOR }}-${{ matrix.test }}.log
path: tests/vmstdout
path: tests/*vmstdout
if-no-files-found: error
- name: Stop test VM
if: always()
env:
TESTS: $${{ fromJson(needs.detect.outputs[matrix.test]) }}
run: |
make test-clean
for t in $TESTS; do
prefix="${t}."
make ELMNTL_PREFIX=${prefix} test-clean
done
test-installer:
needs:
needs:
- build-iso
- detect
runs-on: ${{ fromJson(needs.detect.outputs.tests-runs-on) }}
Expand Down Expand Up @@ -221,17 +259,15 @@ jobs:
key: ${{ env.cache-name }}-${{ hashFiles('Dockerfile', '**/go.sum', '**/pkg/**', '**/examples/**', '**/cmd/**', '**/vendor/**', '**/Makefile', '**/main.go') }}
enableCrossOsArchive: true
fail-on-cache-miss: true
- if: ${{ env.ARCH == 'x86_64' }}
- if: ${{ env.ARCH == 'x86_64' }}
name: Run VM script dependencies
run: |
brew install bash coreutils
- if: ${{ env.ARCH == 'x86_64' }}
- if: ${{ env.ARCH == 'x86_64' }}
name: Prepare test (x86_64)
run: |
qemu-system-x86_64 -cpu help
sysctl -n machdep.cpu.brand_string
make ISO=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.iso ELMNTL_ACCEL=hvf ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_FIRMWARE=$(find /usr/local/Cellar/qemu -name edk2-${{ env.ARCH }}-code.fd -print -quit) prepare-installer-test
- if: ${{ env.ARCH == 'aarch64' }}
- if: ${{ env.ARCH == 'aarch64' }}
name: Prepare test (aarch64)
run: |
make ISO=/tmp/elemental-${{ env.FLAVOR }}.${{ env.ARCH}}.iso ELMNTL_ACCEL=none ELMNTL_MACHINETYPE=virt ELMNTL_TARGETARCH=${{ env.ARCH }} ELMNTL_FIRMWARE=/usr/share/AAVMF/AAVMF_CODE.fd prepare-installer-test
Expand Down
7 changes: 5 additions & 2 deletions make/Makefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ endif
@echo "VM started from $(ISO)"

.PHONY: test-clean
test-clean:
@scripts/run_vm.sh stop
test-clean: test-stop
@scripts/run_vm.sh clean

.PHONY: test-stop
test-stop:
@scripts/run_vm.sh stop

.PHONY: test-installer
test-installer: prepare-installer-test
VM_PID=$$(scripts/run_vm.sh vmpid) go run $(GINKGO) $(GINKGO_ARGS) ./tests/installer
Expand Down
18 changes: 9 additions & 9 deletions scripts/run_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ SCRIPT=$(realpath -s "${0}")
SCRIPTS_PATH=$(dirname "${SCRIPT}")
TESTS_PATH=$(realpath -s "${SCRIPTS_PATH}/../tests")

: "${ELMNTL_PREFIX:=}"
: "${ELMNTL_FIRMWARE:=/usr/share/qemu/ovmf-x86_64.bin}"
: "${ELMNTL_FWDIP:=127.0.0.1}"
: "${ELMNTL_FWDPORT:=2222}"
: "${ELMNTL_MEMORY:=4096}"
: "${ELMNTL_LOGFILE:=${TESTS_PATH}/serial.log}"
: "${ELMNTL_PIDFILE:=${TESTS_PATH}/testvm.pid}"
: "${ELMNTL_TESTDISK:=${TESTS_PATH}/testdisk.qcow2}"
: "${ELMNTL_VMSTDOUT:=${TESTS_PATH}/vmstdout}"
: "${ELMNTL_DISKSIZE:=20G}"
: "${ELMNTL_MEMORY:=2048}"
: "${ELMNTL_LOGFILE:=${TESTS_PATH}/${ELMNTL_PREFIX}serial.log}"
: "${ELMNTL_PIDFILE:=${TESTS_PATH}/${ELMNTL_PREFIX}testvm.pid}"
: "${ELMNTL_TESTDISK:=${TESTS_PATH}/${ELMNTL_PREFIX}testdisk.qcow2}"
: "${ELMNTL_VMSTDOUT:=${TESTS_PATH}/${ELMNTL_PREFIX}vmstdout}"
: "${ELMNTL_DISKSIZE:=16G}"
: "${ELMNTL_DISPLAY:=none}"
: "${ELMNTL_ACCEL:=kvm}"
: "${ELMNTL_TARGETARCH:=$(uname -p)}"
: "${ELMNTL_MACHINETYPE:=q35}"
: "${ELMNTL_CPU:=Skylake-Client-v4}"

function _abort {
echo "$@" && exit 1
Expand All @@ -38,7 +38,7 @@ function start {
local daemon_arg="-daemonize"
local machine_arg="-machine type=${ELMNTL_MACHINETYPE}"
local cdrom_arg
local cpu_arg="-cpu ${ELMNTL_CPU},-pdpe1gb"
local cpu_arg
local vmpid
local kvm_arg

Expand Down Expand Up @@ -68,7 +68,7 @@ function start {
;;
esac

[ "hvf" == "${ELMNTL_ACCEL}" ] && accel_arg="-accel ${ELMNTL_ACCEL}" && firmware_arg="-bios ${ELMNTL_FIRMWARE} ${firmware_arg}"
[ "hvf" == "${ELMNTL_ACCEL}" ] && accel_arg="-accel ${ELMNTL_ACCEL}" && firmware_arg="-bios ${ELMNTL_FIRMWARE} ${firmware_arg}" && cpu_arg="-cpu max,-pdpe1gb"
[ "kvm" == "${ELMNTL_ACCEL}" ] && cpu_arg="-cpu host" && kvm_arg="-enable-kvm"

qemu-system-${ELMNTL_TARGETARCH} ${kvm_arg} ${disk_arg} ${cdrom_arg} ${firmware_arg} ${usrnet_arg} \
Expand Down
2 changes: 1 addition & 1 deletion tests/assets/custom_partitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ install:
size: 4096
fs: ext2
persistent:
size: 8192
size: 128
fs: ext2
oem:
size: 128
2 changes: 1 addition & 1 deletion tests/installer/installer_efi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var _ = Describe("Elemental Installer EFI tests", func() {
},
{
Label: "COS_PERSISTENT",
Size: 8192,
Size: 128,
FsType: sut.Ext2,
},
} {
Expand Down

0 comments on commit c0f8fc2

Please sign in to comment.