From 962585f014b818bbee31d0d3874bede976644d76 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Nov 2023 11:43:26 +0100 Subject: [PATCH] tests: run the `test_stages` category in parallel Run the `test_stages` test in parallel in the github runner. This test takes about 1:30h to 2h and running it in parallel will give us massive wins in terms of test time. The time is observed to go down from around 90min to 36min. Note that the other tests are not run in parallel. The reason is that they fail randomly, it looks like insufficient isolation between them. Some are easy to fix, e.g.: https://github.com/mvo5/osbuild/commit/721521220b34e0054d8c89e4e919822fececd2c1 but it's probably not worth it as the other tests run a lot faster. --- .github/workflows/test.yml | 11 +++++++++++ tox.ini | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9987f6f8d3..cd7dafab7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,5 +32,16 @@ jobs: with: image: ghcr.io/osbuild/osbuild-ci:latest-202308241910 run: | + # Note that only "test.run.test_stages" runs in parallel because + # the other tests are not sufficiently isolated and will cause + # random failures. But test_stages is the long running one with + # almost 2h. + if [ "${{ matrix.test }}" = "test.run.test_stages" ]; then + # Using 4 workers is a bit arbitrary, "auto" is probably too + # aggressive. + export TEST_WORKERS="-n 4" + # Share the store between the workers speeds things up further + export OSBUILD_TEST_STORE=/var/tmp/osbuild-test-store + fi TEST_CATEGORY="${{ matrix.test }}" \ tox -e "${{ matrix.environment }}" diff --git a/tox.ini b/tox.ini index 30b1b3b726..04da534e82 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ labels = description = "run osbuild unit tests" deps = pytest + pytest-xdist jsonschema mako iniparse @@ -26,7 +27,7 @@ passenv = TEST_CATEGORY commands = - bash -c 'python -m pytest --pyargs --rootdir=. {env:TEST_CATEGORY}' + bash -c 'python -m pytest --pyargs --rootdir=. {env:TEST_CATEGORY} {env:TEST_WORKERS}' allowlist_externals = bash