From ef6f51d97710a79efaae2af6806c9d060716584a Mon Sep 17 00:00:00 2001 From: Ratish jain <43003421+ratishjain12@users.noreply.github.com> Date: Fri, 14 Aug 2026 17:00:56 +0530 Subject: [PATCH] fix(tests): check for RediSearch module availability in Redis tests (#6687) --- tests/vector_stores/test_e2e_threshold.py | 18 ++++++++++++++++-- .../vector_stores/test_score_normalization.py | 18 ++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/vector_stores/test_e2e_threshold.py b/tests/vector_stores/test_e2e_threshold.py index dd1ffc4e1..96588fb0c 100644 --- a/tests/vector_stores/test_e2e_threshold.py +++ b/tests/vector_stores/test_e2e_threshold.py @@ -249,9 +249,23 @@ REDIS_HOST = os.environ.get("REDIS_HOST", "localhost") REDIS_PORT = int(os.environ.get("REDIS_PORT", "6379")) +def _redis_search_available(host, port, timeout=2): + """RediSearch (the FT.* command family) is an optional module, not part of vanilla Redis.""" + if not _tcp_reachable(host, port, timeout=timeout): + return False + try: + import redis + + client = redis.Redis(host=host, port=port, socket_connect_timeout=timeout, socket_timeout=timeout) + modules = {m["name"].lower() for m in client.module_list()} + return "search" in modules + except Exception: + return False + + @pytest.mark.skipif( - not _tcp_reachable(REDIS_HOST, REDIS_PORT), - reason=f"Redis not reachable at {REDIS_HOST}:{REDIS_PORT}", + not _redis_search_available(REDIS_HOST, REDIS_PORT), + reason=f"RediSearch module not available at {REDIS_HOST}:{REDIS_PORT} (requires Redis Stack, not vanilla Redis)", ) class TestRedisThreshold: def test_threshold_filtering(self): diff --git a/tests/vector_stores/test_score_normalization.py b/tests/vector_stores/test_score_normalization.py index 72c5a2d2e..bbd726076 100644 --- a/tests/vector_stores/test_score_normalization.py +++ b/tests/vector_stores/test_score_normalization.py @@ -239,9 +239,23 @@ REDIS_HOST = os.environ.get("REDIS_HOST", "localhost") REDIS_PORT = int(os.environ.get("REDIS_PORT", "6379")) +def _redis_search_available(host, port, timeout=2): + """RediSearch (the FT.* command family) is an optional module, not part of vanilla Redis.""" + if not _tcp_reachable(host, port, timeout=timeout): + return False + try: + import redis + + client = redis.Redis(host=host, port=port, socket_connect_timeout=timeout, socket_timeout=timeout) + modules = {m["name"].lower() for m in client.module_list()} + return "search" in modules + except Exception: + return False + + @pytest.mark.skipif( - not _tcp_reachable(REDIS_HOST, REDIS_PORT), - reason=f"Redis not reachable at {REDIS_HOST}:{REDIS_PORT}", + not _redis_search_available(REDIS_HOST, REDIS_PORT), + reason=f"RediSearch module not available at {REDIS_HOST}:{REDIS_PORT} (requires Redis Stack, not vanilla Redis)", ) class TestRedis: """Redis returns cosine distance [0,2]. Conversion: score = max(0, 1 - dist)."""