From a94e0d6c2da1627761e6307276503eb7425c414c Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 9 Jun 2026 09:57:29 -0300 Subject: [PATCH] [chores] Separated session redis bucket from cache bucket --- tests/openwisp2/settings.py | 45 +++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/tests/openwisp2/settings.py b/tests/openwisp2/settings.py index 45f33ef..48df9d4 100644 --- a/tests/openwisp2/settings.py +++ b/tests/openwisp2/settings.py @@ -85,11 +85,12 @@ CORS_ORIGIN_ALLOW_ALL = True ASGI_APPLICATION = "openwisp2.routing.application" + if not TESTING: CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", - "CONFIG": {"hosts": ["redis://localhost/7"]}, + "CONFIG": {"hosts": ["redis://localhost/3"]}, } } else: @@ -121,21 +122,41 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" -CACHES = { - "default": { - "BACKEND": "django_redis.cache.RedisCache", - "LOCATION": "redis://localhost/0", - "OPTIONS": { - "CLIENT_CLASS": "django_redis.client.DefaultClient", +SESSION_ENGINE = "django.contrib.sessions.backends.cache" + +if not TESTING: + CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://localhost/0", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, + }, + "sessions": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://localhost/1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + }, }, } -} - -SESSION_ENGINE = "django.contrib.sessions.backends.cache" -SESSION_CACHE_ALIAS = "default" + SESSION_CACHE_ALIAS = "sessions" +else: + CACHES = { + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + "LOCATION": "owm-legacy", + }, + "sessions": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + "LOCATION": "owm-legacy-sessions", + }, + } + SESSION_CACHE_ALIAS = "sessions" if not TESTING: - CELERY_BROKER_URL = os.getenv("REDIS_URL", "redis://localhost/1") + CELERY_BROKER_URL = os.getenv("REDIS_URL", "redis://localhost/2") else: CELERY_TASK_ALWAYS_EAGER = True CELERY_TASK_EAGER_PROPAGATES = True