forked from CGM_Public/pretix_original
Compare commits
20 Commits
actions-fi
...
hacky-debu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b23fdf2000 | ||
|
|
80d1dd16f4 | ||
|
|
82ed8abecc | ||
|
|
54f077665c | ||
|
|
c0849c9d9c | ||
|
|
e3f6b3f70a | ||
|
|
482a66c546 | ||
|
|
67934e51fc | ||
|
|
e4cef6e46b | ||
|
|
cbee1b71fe | ||
|
|
0cd1290624 | ||
|
|
d4ea0990b3 | ||
|
|
9b4506d5e5 | ||
|
|
f559cd2618 | ||
|
|
565f5e2ea7 | ||
|
|
33991cfb77 | ||
|
|
fe12eea591 | ||
|
|
7000d4897d | ||
|
|
e6337e07e1 | ||
|
|
b46c0eba0c |
4
.github/workflows/strings.yml
vendored
4
.github/workflows/strings.yml
vendored
@@ -35,7 +35,7 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
- name: Install system packages
|
- name: Install system packages
|
||||||
run: sudo apt update && sudo apt install -y gettext
|
run: sudo apt update && sudo apt -y install gettext
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: pip3 install uv && uv pip install --system -e ".[dev]"
|
run: pip3 install uv && uv pip install --system -e ".[dev]"
|
||||||
- name: Compile messages
|
- name: Compile messages
|
||||||
@@ -60,7 +60,7 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
- name: Install system packages
|
- name: Install system packages
|
||||||
run: sudo apt update && sudo apt install -y enchant-2 hunspell hunspell-de-de aspell-en aspell-de
|
run: sudo apt update && sudo apt install enchant-2 hunspell hunspell-de-de aspell-en aspell-de
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: pip3 install uv && uv pip install --system -e ".[dev]"
|
run: pip3 install uv && uv pip install --system -e ".[dev]"
|
||||||
- name: Spellcheck translations
|
- name: Spellcheck translations
|
||||||
|
|||||||
10
.github/workflows/tests.yml
vendored
10
.github/workflows/tests.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
python-version: ["3.9", "3.10", "3.11"]
|
python-version: ["3.9", "3.10", "3.11"]
|
||||||
database: [sqlite, postgres]
|
database: [ postgres]
|
||||||
exclude:
|
exclude:
|
||||||
- database: sqlite
|
- database: sqlite
|
||||||
python-version: "3.9"
|
python-version: "3.9"
|
||||||
@@ -71,7 +71,13 @@ jobs:
|
|||||||
run: make all compress
|
run: make all compress
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
working-directory: ./src
|
working-directory: ./src
|
||||||
run: PRETIX_CONFIG_FILE=tests/ci_${{ matrix.database }}.cfg py.test -n 3 --stepwise -vv -p no:sugar --cov=./ --cov-report=xml --reruns 0 tests
|
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
|
||||||
|
|
||||||
- name: Run concurrency tests
|
- name: Run concurrency tests
|
||||||
working-directory: ./src
|
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/ci_${{ matrix.database }}.cfg py.test tests/concurrency_tests/ --reruns 0 --reuse-db
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||||
# <https://www.gnu.org/licenses/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import os
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
import fakeredis
|
import fakeredis
|
||||||
@@ -38,4 +39,9 @@ def mocker_context():
|
|||||||
|
|
||||||
|
|
||||||
def get_redis_connection(alias="default", write=True):
|
def get_redis_connection(alias="default", write=True):
|
||||||
return fakeredis.FakeStrictRedis(server=fakeredis.FakeServer.get_server("127.0.0.1:None:v(7, 0)", (7, 0), server_type="redis"))
|
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
|
||||||
|
if worker_id.startswith("gw"):
|
||||||
|
redis_port = 1000 + int(worker_id.replace("gw", ""))
|
||||||
|
else:
|
||||||
|
redis_port = 1000
|
||||||
|
return fakeredis.FakeStrictRedis(server=fakeredis.FakeServer.get_server(f"127.0.0.1:{redis_port}:redis:v(7, 0)", (7, 0), server_type="redis"))
|
||||||
|
|||||||
@@ -95,5 +95,5 @@ class DisableMigrations(object):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
if not os.environ.get("TRAVIS", "") and not os.environ.get("GITHUB_WORKFLOW", ""):
|
if not os.environ.get("GITHUB_WORKFLOW", ""):
|
||||||
MIGRATION_MODULES = DisableMigrations()
|
MIGRATION_MODULES = DisableMigrations()
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#
|
#
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
@@ -38,8 +39,8 @@ CRASHED_ITEMS = set()
|
|||||||
@pytest.hookimpl(trylast=True)
|
@pytest.hookimpl(trylast=True)
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
"""
|
"""
|
||||||
Somehow, somewhere, our test suite causes a segfault in SQLite, but only when run
|
Somehow, somewhere, our test suite causes a segfault in SQLite in the past, but only when run
|
||||||
on Travis CI in full. Therefore, we monkeypatch pytest-xdist to retry segfaulted
|
on 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.
|
tests and keep fingers crossed that this doesn't turn into an infinite loop.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -84,27 +85,32 @@ def reset_locale():
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fakeredis_client(monkeypatch):
|
def fakeredis_client(monkeypatch):
|
||||||
|
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
|
||||||
|
if worker_id.startswith("gw"):
|
||||||
|
redis_port = 1000 + int(worker_id.replace("gw", ""))
|
||||||
|
else:
|
||||||
|
redis_port = 1000
|
||||||
with override_settings(
|
with override_settings(
|
||||||
HAS_REDIS=True,
|
HAS_REDIS=True,
|
||||||
REAL_CACHE_USED=True,
|
REAL_CACHE_USED=True,
|
||||||
CACHES={
|
CACHES={
|
||||||
'redis': {
|
'redis': {
|
||||||
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
||||||
'LOCATION': 'redis://127.0.0.1',
|
'LOCATION': f'redis://127.0.0.1:{redis_port}',
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'connection_class': FakeConnection
|
'connection_class': FakeConnection
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'redis_session': {
|
'redis_session': {
|
||||||
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
||||||
'LOCATION': 'redis://127.0.0.1',
|
'LOCATION': f'redis://127.0.0.1:{redis_port}',
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'connection_class': FakeConnection
|
'connection_class': FakeConnection
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'default': {
|
'default': {
|
||||||
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
'BACKEND': 'django.core.cache.backends.redis.RedisCache',
|
||||||
'LOCATION': 'redis://127.0.0.1',
|
'LOCATION': f'redis://127.0.0.1:{redis_port}',
|
||||||
'OPTIONS': {
|
'OPTIONS': {
|
||||||
'connection_class': FakeConnection
|
'connection_class': FakeConnection
|
||||||
}
|
}
|
||||||
@@ -117,9 +123,15 @@ def fakeredis_client(monkeypatch):
|
|||||||
yield redis
|
yield redis
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# XXXXXXXXXXXXXXXXXXX for test only
|
||||||
|
|
||||||
|
f = open("/tmp/test.txt","w")
|
||||||
|
|
||||||
if os.environ.get("GITHUB_WORKFLOW", ""):
|
if os.environ.get("GITHUB_WORKFLOW", ""):
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def ensure_healthy_connection(request):
|
def ensure_healthy_connection(request, worker_id):
|
||||||
# We have no idea why this is neccessary. It shouldn't be, and it costs some performance.
|
# 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)
|
# 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
|
# for no apparent reason with some error messages related to PostgreSQL connection issues. This appears to
|
||||||
@@ -127,11 +139,15 @@ if os.environ.get("GITHUB_WORKFLOW", ""):
|
|||||||
|
|
||||||
# Check if the test even has DB access
|
# Check if the test even has DB access
|
||||||
marker = request.node.get_closest_marker("django_db")
|
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
|
# Run actual test
|
||||||
yield
|
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 yes, do a dummy query at the end of the test
|
||||||
if marker:
|
#if marker:
|
||||||
with connection.cursor() as cursor:
|
# with connection.cursor() as cursor:
|
||||||
cursor.execute("SELECT 1")
|
# cursor.execute("SELECT 1")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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 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
|
This is useful for debugging our pytest-xdist monkeypatch that we apply in conftest.py
|
||||||
to deal with random test crashes on Travis CI using SQLite. Usually, this test is
|
to deal with random test crashes on CI using SQLite. Usually, this test is
|
||||||
skipped to avoid causing additional crashes in real runs.
|
skipped to avoid causing additional crashes in real runs.
|
||||||
"""
|
"""
|
||||||
if os.path.exists('crashed.tmp'):
|
if os.path.exists('crashed.tmp'):
|
||||||
|
|||||||
Reference in New Issue
Block a user