wip(sync): add Redis to CI and configure tests settings

This commit is contained in:
Yohan Boniface 2025-01-20 19:04:03 +01:00
parent a07ee482ce
commit 7e42331533
3 changed files with 19 additions and 1 deletions

View file

@ -20,7 +20,9 @@ jobs:
POSTGRES_PASSWORD: postgres POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres POSTGRES_DB: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:

View file

@ -1,6 +1,8 @@
import re import re
import pytest import pytest
import redis
from django.conf import settings
from playwright.sync_api import expect from playwright.sync_api import expect
from umap.models import DataLayer, Map from umap.models import DataLayer, Map
@ -9,6 +11,18 @@ from ..base import DataLayerFactory, MapFactory
DATALAYER_UPDATE = re.compile(r".*/datalayer/update/.*") DATALAYER_UPDATE = re.compile(r".*/datalayer/update/.*")
pytestmark = pytest.mark.django_db
def setup_function():
# Sync client to prevent headache with pytest / pytest-asyncio and async
client = redis.from_url(settings.REDIS_URL)
# Make sure there are no dead peers in the Redis hash, otherwise asking for
# operations from another peer may never be answered
# FIXME this should not happen in an ideal world
assert client.connection_pool.connection_kwargs["db"] == 15
client.flushdb()
@pytest.mark.xdist_group(name="websockets") @pytest.mark.xdist_group(name="websockets")
def test_websocket_connection_can_sync_markers(new_page, asgi_live_server, tilelayer): def test_websocket_connection_can_sync_markers(new_page, asgi_live_server, tilelayer):

View file

@ -29,3 +29,5 @@ PASSWORD_HASHERS = [
WEBSOCKET_ENABLED = True WEBSOCKET_ENABLED = True
WEBSOCKET_BACK_PORT = "8010" WEBSOCKET_BACK_PORT = "8010"
WEBSOCKET_FRONT_URI = "ws://localhost:8010" WEBSOCKET_FRONT_URI = "ws://localhost:8010"
REDIS_URL = "redis://localhost:6379/15"