From c412dada22c026736a4a595096ece468b6e5b9e9 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Mon, 7 Mar 2022 17:10:37 +0100 Subject: [PATCH] CI: Split the tests in multiple runs A test run of 40 minutes is just too much to wait for. So tag the long running jobs to run in a special run --- .github/workflows/ci-test.yml | 10 ++++++++++ dist/ci/docker-compose-test.sh | 15 +++++++++++++++ dist/ci/docker-compose.yml | 2 +- tests/accept_tests.py | 2 ++ tests/api_tests.py | 2 ++ tests/check_source_tests.py | 1 + tests/origin_tests.py | 2 ++ tests/select_tests.py | 2 ++ 8 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 091a4470..1b09f5ed 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -12,6 +12,10 @@ jobs: tests: timeout-minutes: 40 runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ci_node_index: [Long1,Long2,Rest] steps: - name: Checkout @@ -22,6 +26,12 @@ jobs: - name: Run tests run: docker-compose -f dist/ci/docker-compose.yml run test + env: + # Specifies how many jobs you would like to run in parallel, + # used for partitioning + CI_NODE_TOTAL: ${{ matrix.ci_node_total }} + # Use the index from matrix as an environment variable + CI_NODE_INDEX: ${{ matrix.ci_node_index }} - name: Submit coverage report to Codecov uses: codecov/codecov-action@v1.5.2 diff --git a/dist/ci/docker-compose-test.sh b/dist/ci/docker-compose-test.sh index 5796fbdb..bf18aafe 100755 --- a/dist/ci/docker-compose-test.sh +++ b/dist/ci/docker-compose-test.sh @@ -13,7 +13,22 @@ until curl http://api:3000/about 2>/dev/null ; do done cd /code + +ci_node=$1 + for file in tests/*_tests.py; do + if test -n "$ci_node"; then + if test "$ci_node" == "Rest"; then + if grep -q '# CI-Node' $file; then + echo "Skipping $file in 'Rest'" + continue + fi + else + if ! grep -q "# CI-Node: $ci_node" $file; then + continue + fi + fi + fi if ! test -f /code/.without-coverage; then COVER_ARGS="--cov=. --cov-append --cov-report=xml" else diff --git a/dist/ci/docker-compose.yml b/dist/ci/docker-compose.yml index 94398648..05cd570f 100644 --- a/dist/ci/docker-compose.yml +++ b/dist/ci/docker-compose.yml @@ -48,7 +48,7 @@ services: depends_on: - api - smtp - command: /code/dist/ci/docker-compose-test.sh + command: /code/dist/ci/docker-compose-test.sh ${CI_NODE_INDEX} cap_add: - SYS_PTRACE flaker: diff --git a/tests/accept_tests.py b/tests/accept_tests.py index 6b4d4caf..6fd29e9c 100644 --- a/tests/accept_tests.py +++ b/tests/accept_tests.py @@ -8,6 +8,8 @@ from osclib.core import package_list from mock import MagicMock from . import OBSLocal +# CI-Node: Long2 + class TestAccept(unittest.TestCase): diff --git a/tests/api_tests.py b/tests/api_tests.py index c5ae5178..75d0584d 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -2,6 +2,8 @@ import osc.core from osclib.core import attribute_value_delete, attribute_value_save from . import OBSLocal +# CI-Node: Long1 + class TestApiCalls(OBSLocal.TestCase): """ diff --git a/tests/check_source_tests.py b/tests/check_source_tests.py index fe1fbbcc..eca230af 100644 --- a/tests/check_source_tests.py +++ b/tests/check_source_tests.py @@ -18,6 +18,7 @@ FACTORY_MAINTAINERS = 'group:factory-maintainers' # Inherit from OBSLocal.Testcase since it provides many commodity methods for testing against # a local testing instance of OBS +# CI-Node: Long1 class TestCheckSource(OBSLocal.TestCase): diff --git a/tests/origin_tests.py b/tests/origin_tests.py index cae8538d..c97a447d 100644 --- a/tests/origin_tests.py +++ b/tests/origin_tests.py @@ -20,6 +20,8 @@ import time import yaml from . import OBSLocal +# CI-Node: Long2 + class TestOrigin(OBSLocal.TestCase): script = './origin-manager.py' diff --git a/tests/select_tests.py b/tests/select_tests.py index 0cbe2fb8..676067f0 100644 --- a/tests/select_tests.py +++ b/tests/select_tests.py @@ -11,6 +11,8 @@ from lxml import etree as ET from mock import MagicMock from . import OBSLocal +# CI-Node: Long1 + class TestSelect(OBSLocal.TestCase):