From 0edbe0cf966b13f9c16c43c1d37c200d63b79a88 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 currently takes about 1:30h to 2:30h and running it in parallel will give us big wins in terms of test time. The time is observed to go down to 0:30h to 1h. 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 5950fb28..a2f627cb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,5 +33,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 031a4d90..f5843a1b 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