Compare commits

..

1 Commits

Author SHA1 Message Date
Raphael Michel
90a34b3382 CI: Try to run with 4 threads 2024-10-25 17:23:33 +02:00
7 changed files with 8 additions and 47 deletions

View File

@@ -22,10 +22,9 @@ jobs:
runs-on: ubuntu-22.04
name: Tests
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
database: [ postgres]
database: [sqlite, postgres]
exclude:
- database: sqlite
python-version: "3.9"
@@ -71,16 +70,10 @@ jobs:
run: make all compress
- name: Run tests
working-directory: ./src
run: PRETIX_CONFIG_FILE=tests/ci_${{ matrix.database }}.cfg py.test -n 3 -p no:sugar --cov=./ --cov-report=xml --reruns 0 tests --maxfail=100 || true
# XXXXXXXXXXXXXX for test only
- name: print debug output
working-directory: ./src
run: cat /tmp/test.txt
run: PRETIX_CONFIG_FILE=tests/travis_${{ matrix.database }}.cfg py.test -n 4 -p no:sugar --cov=./ --cov-report=xml --reruns 3 tests --maxfail=100
- name: Run concurrency tests
working-directory: ./src
run: PRETIX_CONFIG_FILE=tests/ci_${{ matrix.database }}.cfg py.test tests/concurrency_tests/ --reruns 0 --reuse-db
run: PRETIX_CONFIG_FILE=tests/travis_${{ matrix.database }}.cfg py.test tests/concurrency_tests/ --reruns 0 --reuse-db
if: matrix.database == 'postgres'
- name: Upload coverage
uses: codecov/codecov-action@v1

View File

@@ -10,7 +10,7 @@ tests:
- cd src
- python manage.py check
- make all compress
- PRETIX_CONFIG_FILE=tests/ci_sqlite.cfg py.test --reruns 3 -n 3 tests --maxfail=100
- PRETIX_CONFIG_FILE=tests/travis_sqlite.cfg py.test --reruns 3 -n 3 tests --maxfail=100
except:
- pypi
pypi:

View File

@@ -95,5 +95,5 @@ class DisableMigrations(object):
return None
if not os.environ.get("GITHUB_WORKFLOW", ""):
if not os.environ.get("TRAVIS", "") and not os.environ.get("GITHUB_WORKFLOW", ""):
MIGRATION_MODULES = DisableMigrations()

View File

@@ -21,10 +21,8 @@
#
import inspect
import os
import time
import pytest
from django.db import connection
from django.test import override_settings
from django.utils import translation
from django_scopes import scopes_disabled
@@ -39,8 +37,8 @@ CRASHED_ITEMS = set()
@pytest.hookimpl(trylast=True)
def pytest_configure(config):
"""
Somehow, somewhere, our test suite causes a segfault in SQLite in the past, but only when run
on CI in full. Therefore, we monkeypatch pytest-xdist to retry segfaulted
Somehow, somewhere, our test suite causes a segfault in SQLite, but only when run
on Travis CI in full. Therefore, we monkeypatch pytest-xdist to retry segfaulted
tests and keep fingers crossed that this doesn't turn into an infinite loop.
"""
@@ -121,33 +119,3 @@ def fakeredis_client(monkeypatch):
redis.flushall()
monkeypatch.setattr('django_redis.get_redis_connection', get_redis_connection, raising=False)
yield redis
# XXXXXXXXXXXXXXXXXXX for test only
f = open("/tmp/test.txt","w")
if os.environ.get("GITHUB_WORKFLOW", ""):
@pytest.fixture(autouse=True)
def ensure_healthy_connection(request, worker_id):
# We have no idea why this is neccessary. It shouldn't be, and it costs some performance.
# However, in ~August 2024 our tests became really flake on GitHub Actions (failing more than 80% of the time)
# for no apparent reason with some error messages related to PostgreSQL connection issues. This appears to
# work around it...
# Check if the test even has DB access
marker = request.node.get_closest_marker("django_db")
f.write(str(time.time())+"\t"+ str(worker_id)+"\t"+str(request.path)+"\t"+ str(request.module.__name__)+"\t"+ str(request.function.__name__)+"\tstart\n")
f.flush()
# Run actual test
yield
f.write(str(time.time())+"\t"+ str(worker_id)+"\t"+str(request.path)+"\t"+ str(request.module.__name__)+"\t"+ str(request.function.__name__)+"\tend\n")
f.flush()
# If yes, do a dummy query at the end of the test
#if marker:
# with connection.cursor() as cursor:
# cursor.execute("SELECT 1")

View File

@@ -29,7 +29,7 @@ def test_crash():
"""
This is a test that crashes with SIGKILL every (n+1)-th time it runs (n = 0, 1, 2, …).
This is useful for debugging our pytest-xdist monkeypatch that we apply in conftest.py
to deal with random test crashes on CI using SQLite. Usually, this test is
to deal with random test crashes on Travis CI using SQLite. Usually, this test is
skipped to avoid causing additional crashes in real runs.
"""
if os.path.exists('crashed.tmp'):