forked from CGM_Public/pretix_original
Tests: Add separation of database lock indices by pytest worker (#4553)
* Add separation of database lock indices by pytest worker * Fix ID derivation * Update conftest.py
This commit is contained in:
@@ -84,7 +84,7 @@ def reset_locale():
|
||||
@pytest.fixture
|
||||
def fakeredis_client(monkeypatch):
|
||||
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
|
||||
if worker_id.startswith("gw"):
|
||||
if worker_id and worker_id.startswith("gw"):
|
||||
redis_port = 1000 + int(worker_id.replace("gw", ""))
|
||||
else:
|
||||
redis_port = 1000
|
||||
@@ -119,3 +119,13 @@ def fakeredis_client(monkeypatch):
|
||||
redis.flushall()
|
||||
monkeypatch.setattr('django_redis.get_redis_connection', get_redis_connection, raising=False)
|
||||
yield redis
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def set_lock_namespaces(request):
|
||||
worker_id = os.environ.get("PYTEST_XDIST_WORKER")
|
||||
if worker_id and worker_id.startswith("gw"):
|
||||
with override_settings(DATABASE_ADVISORY_LOCK_INDEX=int(worker_id.replace("gw", ""))):
|
||||
yield
|
||||
else:
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user