Skip to content

Commit b9ce3d5

Browse files
committed
Disable cluster tests by default
1 parent e676c8a commit b9ce3d5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,27 +315,43 @@ def pytest_addoption(parser: pytest.Parser) -> None:
315315
default=False,
316316
help="Run tests that require API keys",
317317
)
318+
parser.addoption(
319+
"--run-cluster-tests",
320+
action="store_true",
321+
default=False,
322+
help="Run tests that require a Redis cluster",
323+
)
318324

319325

320326
def pytest_configure(config: pytest.Config) -> None:
321327
config.addinivalue_line(
322328
"markers", "requires_api_keys: mark test as requiring API keys"
323329
)
330+
config.addinivalue_line(
331+
"markers", "requires_cluster: mark test as requiring a Redis cluster"
332+
)
324333

325334

326335
def pytest_collection_modifyitems(
327336
config: pytest.Config, items: list[pytest.Item]
328337
) -> None:
329338
if config.getoption("--run-api-tests"):
330339
return
340+
if config.getoption("--run-cluster-tests"):
341+
return
331342

332343
# Otherwise skip all tests requiring an API key
333344
skip_api = pytest.mark.skip(
334345
reason="Skipping test because API keys are not provided. Use --run-api-tests to run these tests."
335346
)
347+
skip_cluster = pytest.mark.skip(
348+
reason="Skipping test because Redis cluster is not available. Use --run-cluster-tests to run these tests."
349+
)
336350
for item in items:
337351
if item.get_closest_marker("requires_api_keys"):
338352
item.add_marker(skip_api)
353+
if item.get_closest_marker("requires_cluster"):
354+
item.add_marker(skip_cluster)
339355

340356

341357
@pytest.fixture

tests/integration/test_redis_cluster_support.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from redisvl.schema import IndexSchema
1515

1616

17+
@pytest.mark.requires_cluster
1718
def test_sync_client_validation(redis_url, redis_cluster_url):
1819
"""Test validation of sync Redis client types."""
1920
# Test regular Redis client
@@ -25,6 +26,7 @@ def test_sync_client_validation(redis_url, redis_cluster_url):
2526
RedisConnectionFactory.validate_sync_redis(cluster_client)
2627

2728

29+
@pytest.mark.requires_cluster
2830
@pytest.mark.asyncio
2931
async def test_async_client_validation(redis_cluster_url):
3032
"""Test validation of async Redis client types."""
@@ -34,6 +36,7 @@ async def test_async_client_validation(redis_cluster_url):
3436
await RedisConnectionFactory.validate_async_redis(async_cluster_client)
3537

3638

39+
@pytest.mark.requires_cluster
3740
@pytest.mark.asyncio
3841
async def test_sync_to_async_conversion_rejects_cluster_client(redis_cluster_url):
3942
"""Test that sync-to-async conversion rejects RedisCluster clients."""
@@ -44,6 +47,7 @@ async def test_sync_to_async_conversion_rejects_cluster_client(redis_cluster_url
4447
RedisConnectionFactory.sync_to_async_redis(cluster_client)
4548

4649

50+
@pytest.mark.requires_cluster
4751
def test_search_index_cluster_client(redis_cluster_url):
4852
"""Test that SearchIndex correctly accepts RedisCluster clients."""
4953
# Create a simple schema
@@ -66,6 +70,7 @@ def test_search_index_cluster_client(redis_cluster_url):
6670
index.delete(drop=True)
6771

6872

73+
@pytest.mark.requires_cluster
6974
@pytest.mark.asyncio
7075
async def test_async_search_index_client(redis_cluster_url):
7176
"""Test that AsyncSearchIndex correctly handles AsyncRedis clients."""
@@ -94,6 +99,7 @@ async def test_async_search_index_client(redis_cluster_url):
9499
await cluster_client.aclose()
95100

96101

102+
@pytest.mark.requires_cluster
97103
@pytest.mark.asyncio
98104
async def test_embeddings_cache_cluster_async(redis_cluster_url):
99105
"""Test that EmbeddingsCache correctly handles AsyncRedisCluster clients."""
@@ -117,6 +123,7 @@ async def test_embeddings_cache_cluster_async(redis_cluster_url):
117123
await cluster_client.aclose()
118124

119125

126+
@pytest.mark.requires_cluster
120127
def test_embeddings_cache_cluster_sync(redis_cluster_url):
121128
"""Test that EmbeddingsCache correctly handles RedisCluster clients."""
122129
cluster_client = RedisCluster.from_url(redis_cluster_url)
@@ -147,6 +154,7 @@ def test_embeddings_cache_cluster_sync(redis_cluster_url):
147154
cache.clear()
148155

149156

157+
@pytest.mark.requires_cluster
150158
def test_semantic_router_cluster_client(redis_cluster_url, hf_vectorizer):
151159
"""Test that SemanticRouter works correctly with RedisCluster clients."""
152160
routes = [

0 commit comments

Comments
 (0)