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
This commit is contained in:
Stephan Kulow 2022-03-07 17:10:37 +01:00
parent b93adbd9c1
commit c412dada22
8 changed files with 35 additions and 1 deletions

View File

@ -12,6 +12,10 @@ jobs:
tests: tests:
timeout-minutes: 40 timeout-minutes: 40
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_node_index: [Long1,Long2,Rest]
steps: steps:
- name: Checkout - name: Checkout
@ -22,6 +26,12 @@ jobs:
- name: Run tests - name: Run tests
run: docker-compose -f dist/ci/docker-compose.yml run test 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 - name: Submit coverage report to Codecov
uses: codecov/codecov-action@v1.5.2 uses: codecov/codecov-action@v1.5.2

View File

@ -13,7 +13,22 @@ until curl http://api:3000/about 2>/dev/null ; do
done done
cd /code cd /code
ci_node=$1
for file in tests/*_tests.py; do 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 if ! test -f /code/.without-coverage; then
COVER_ARGS="--cov=. --cov-append --cov-report=xml" COVER_ARGS="--cov=. --cov-append --cov-report=xml"
else else

View File

@ -48,7 +48,7 @@ services:
depends_on: depends_on:
- api - api
- smtp - smtp
command: /code/dist/ci/docker-compose-test.sh command: /code/dist/ci/docker-compose-test.sh ${CI_NODE_INDEX}
cap_add: cap_add:
- SYS_PTRACE - SYS_PTRACE
flaker: flaker:

View File

@ -8,6 +8,8 @@ from osclib.core import package_list
from mock import MagicMock from mock import MagicMock
from . import OBSLocal from . import OBSLocal
# CI-Node: Long2
class TestAccept(unittest.TestCase): class TestAccept(unittest.TestCase):

View File

@ -2,6 +2,8 @@ import osc.core
from osclib.core import attribute_value_delete, attribute_value_save from osclib.core import attribute_value_delete, attribute_value_save
from . import OBSLocal from . import OBSLocal
# CI-Node: Long1
class TestApiCalls(OBSLocal.TestCase): class TestApiCalls(OBSLocal.TestCase):
""" """

View File

@ -18,6 +18,7 @@ FACTORY_MAINTAINERS = 'group:factory-maintainers'
# Inherit from OBSLocal.Testcase since it provides many commodity methods for testing against # Inherit from OBSLocal.Testcase since it provides many commodity methods for testing against
# a local testing instance of OBS # a local testing instance of OBS
# CI-Node: Long1
class TestCheckSource(OBSLocal.TestCase): class TestCheckSource(OBSLocal.TestCase):

View File

@ -20,6 +20,8 @@ import time
import yaml import yaml
from . import OBSLocal from . import OBSLocal
# CI-Node: Long2
class TestOrigin(OBSLocal.TestCase): class TestOrigin(OBSLocal.TestCase):
script = './origin-manager.py' script = './origin-manager.py'

View File

@ -11,6 +11,8 @@ from lxml import etree as ET
from mock import MagicMock from mock import MagicMock
from . import OBSLocal from . import OBSLocal
# CI-Node: Long1
class TestSelect(OBSLocal.TestCase): class TestSelect(OBSLocal.TestCase):