-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathconftest.py
More file actions
795 lines (685 loc) · 25.3 KB
/
Copy pathconftest.py
File metadata and controls
795 lines (685 loc) · 25.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
import hashlib
import logging
import os
import re
import subprocess
import sys
from datetime import datetime, timezone
import pytest
from testcontainers.compose import DockerCompose
from redisvl.index.index import AsyncSearchIndex, SearchIndex
from redisvl.redis.connection import RedisConnectionFactory, is_version_gte
from redisvl.redis.utils import array_to_buffer
# Check if we're on Python 3.14+ where sentence-transformers may not work
SKIP_HF = sys.version_info >= (3, 14)
if not SKIP_HF:
from redisvl.utils.vectorize import HFTextVectorizer
logger = logging.getLogger(__name__)
@pytest.fixture(scope="session")
def worker_id(request):
"""
Get the worker ID for the current test.
In pytest-xdist, the config has "workerid" in workerinput.
This fixture abstracts that logic to provide a consistent worker_id
across all tests.
"""
workerinput = getattr(request.config, "workerinput", {})
return workerinput.get("workerid", "master")
@pytest.fixture
def redis_test_name(worker_id, request):
"""Build a per-test Redis resource name stable within a test function."""
node_hash = hashlib.sha1(request.node.nodeid.encode("utf-8")).hexdigest()[:10]
def make_name(base: str) -> str:
slug = re.sub(r"[^0-9A-Za-z]+", "_", base).strip("_").lower()
return f"{slug or 'redis_resource'}_{worker_id}_{node_hash}"
return make_name
@pytest.fixture(autouse=True)
def set_tokenizers_parallelism():
"""Disable tokenizers parallelism in tests to avoid deadlocks"""
os.environ["TOKENIZERS_PARALLELISM"] = "false"
@pytest.fixture(scope="session", autouse=True)
def redis_container(worker_id):
"""
If using xdist, create a unique Compose project for each xdist worker by
setting COMPOSE_PROJECT_NAME. That prevents collisions on container/volume
names.
"""
# Set the Compose project name so containers do not clash across workers
os.environ["COMPOSE_PROJECT_NAME"] = f"redis_test_{worker_id}"
os.environ.setdefault("REDIS_IMAGE", "redis:8.4")
compose = DockerCompose(
context="tests",
compose_file_name="docker-compose.yml",
pull=True,
)
compose.start()
yield compose
compose.stop()
@pytest.fixture(scope="session")
def redis_cluster_container(worker_id):
project_name = f"redis_test_cluster_{worker_id}"
# Use cwd if not running in GitHub Actions
pwd = os.getcwd()
compose_file = os.path.join(
os.environ.get("GITHUB_WORKSPACE", pwd), "tests", "cluster-compose.yml"
)
os.environ["COMPOSE_PROJECT_NAME"] = (
project_name # For docker compose to pick it up if needed
)
# Cluster tests use a pinned Redis 8 image for consistency.
os.environ.setdefault("REDIS_IMAGE", "redis:8.4")
# The DockerCompose helper isn't working with multiple services because the
# subprocess command returns non-zero exit codes even on successful
# completion. Here, we run the commands manually.
# First attempt the docker-compose up command and handle its errors directly
docker_cmd = [
"docker",
"compose",
"-f",
compose_file,
"-p", # Explicitly pass project name
project_name,
"up",
"--wait", # Wait for healthchecks
"-d", # Detach
]
try:
result = subprocess.run(
docker_cmd,
capture_output=True,
check=False, # Don't raise exception, we'll handle it ourselves
)
if result.returncode != 0:
logger.error(f"Docker Compose up failed with exit code {result.returncode}")
if result.stdout:
logger.error(
f"STDOUT: {result.stdout.decode('utf-8', errors='replace')}"
)
if result.stderr:
logger.error(
f"STDERR: {result.stderr.decode('utf-8', errors='replace')}"
)
# Try to get logs for more details
logger.info("Attempting to fetch container logs...")
try:
logs_result = subprocess.run(
[
"docker",
"compose",
"-f",
compose_file,
"-p",
project_name,
"logs",
],
capture_output=True,
text=True,
)
logger.info("Docker Compose logs:\n%s", logs_result.stdout)
if logs_result.stderr:
logger.error("Docker Compose logs stderr: \n%s", logs_result.stderr)
except Exception as log_e:
logger.error(f"Failed to get Docker Compose logs: {repr(log_e)}")
# Now raise the exception with the original result
raise subprocess.CalledProcessError(
result.returncode,
docker_cmd,
output=result.stdout,
stderr=result.stderr,
)
# If we get here, setup was successful
yield
finally:
# Always clean up
try:
subprocess.run(
[
"docker",
"compose",
"-f",
compose_file,
"-p",
project_name,
"down",
"-v", # Remove volumes
],
check=False, # Don't raise on cleanup failure
capture_output=True,
)
except Exception as e:
logger.error(f"Error during cleanup: {repr(e)}")
@pytest.fixture(scope="session")
def redis_url(redis_container):
"""
Use the `DockerCompose` fixture to get host/port of the 'redis' service
on container port 6379 (mapped to an ephemeral port on the host).
"""
host, port = redis_container.get_service_host_and_port("redis", 6379)
return f"redis://{host}:{port}"
@pytest.fixture(scope="session")
def redis_cluster_url(redis_cluster_container):
# Hard-coded due to Docker issues
return "redis://localhost:7001"
@pytest.fixture
async def async_client(redis_url):
"""
An async Redis client that uses the dynamic `redis_url`.
"""
async with await RedisConnectionFactory._get_aredis_connection(redis_url) as client:
yield client
@pytest.fixture
def client(redis_url):
"""
A sync Redis client that uses the dynamic `redis_url`.
"""
conn = RedisConnectionFactory.get_redis_connection(redis_url=redis_url)
yield conn
@pytest.fixture
def cluster_client(redis_cluster_url):
"""
A sync Redis client that uses the dynamic `redis_cluster_url`.
"""
conn = RedisConnectionFactory.get_redis_cluster_connection(
redis_url=redis_cluster_url
)
yield conn
@pytest.fixture(scope="session")
def hf_vectorizer():
if SKIP_HF:
pytest.skip("HFTextVectorizer not supported on Python 3.14+")
return HFTextVectorizer(
model="sentence-transformers/all-mpnet-base-v2",
token=os.getenv("HF_TOKEN"),
cache_folder=os.getenv("SENTENCE_TRANSFORMERS_HOME"),
)
@pytest.fixture(scope="session")
def hf_vectorizer_float16():
if SKIP_HF:
pytest.skip("HFTextVectorizer not supported on Python 3.14+")
return HFTextVectorizer(dtype="float16")
@pytest.fixture(scope="session")
def hf_vectorizer_with_model():
if SKIP_HF:
pytest.skip("HFTextVectorizer not supported on Python 3.14+")
return HFTextVectorizer("sentence-transformers/all-mpnet-base-v2")
@pytest.fixture
def sample_datetimes():
return {
"low": datetime(2025, 1, 16, 13).astimezone(timezone.utc),
"mid": datetime(2025, 2, 16, 13).astimezone(timezone.utc),
"high": datetime(2025, 3, 16, 13).astimezone(timezone.utc),
}
@pytest.fixture
def sample_data(sample_datetimes):
return [
{
"user": "john",
"age": 18,
"job": "engineer",
"description": "engineers conduct trains that ride on train tracks",
"last_updated": sample_datetimes["low"].timestamp(),
"credit_score": "high",
"location": "-122.4194,37.7749",
"user_embedding": [0.1, 0.1, 0.5],
},
{
"user": "mary",
"age": 14,
"job": "doctor",
"description": "a medical professional who treats diseases and helps people stay healthy",
"last_updated": sample_datetimes["low"].timestamp(),
"credit_score": "low",
"location": "-122.4194,37.7749",
"user_embedding": [0.1, 0.1, 0.5],
},
{
"user": "nancy",
"age": 94,
"job": "doctor",
"description": "a research scientist specializing in cancers and diseases of the lungs",
"last_updated": sample_datetimes["mid"].timestamp(),
"credit_score": "high",
"location": "-122.4194,37.7749",
"user_embedding": [0.7, 0.1, 0.5],
},
{
"user": "tyler",
"age": 100,
"job": "engineer",
"description": "a software developer with expertise in mathematics and computer science",
"last_updated": sample_datetimes["mid"].timestamp(),
"credit_score": "high",
"location": "-110.0839,37.3861",
"user_embedding": [0.1, 0.4, 0.5],
},
{
"user": "tim",
"age": 12,
"job": "dermatologist",
"description": "a medical professional specializing in diseases of the skin",
"last_updated": sample_datetimes["mid"].timestamp(),
"credit_score": "high",
"location": "-110.0839,37.3861",
"user_embedding": [0.4, 0.4, 0.5],
},
{
"user": "taimur",
"age": 15,
"job": "CEO",
"description": "high stress, but financially rewarding position at the head of a company",
"last_updated": sample_datetimes["high"].timestamp(),
"credit_score": "low",
"location": "-110.0839,37.3861",
"user_embedding": [0.6, 0.1, 0.5],
},
{
"user": "joe",
"age": 35,
"job": "dentist",
"description": "like the tooth fairy because they'll take your teeth, but you have to pay them!",
"last_updated": sample_datetimes["high"].timestamp(),
"credit_score": "medium",
"location": "-110.0839,37.3861",
"user_embedding": [-0.1, -0.1, -0.5],
},
]
@pytest.fixture
def multi_vector_data(sample_datetimes):
return [
{
"user": "john",
"age": 18,
"job": "engineer",
"description": "engineers conduct trains that ride on train tracks",
"last_updated": sample_datetimes["low"].timestamp(),
"credit_score": "high",
"location": "-122.4194,37.7749",
"user_embedding": [0.1, 0.1, 0.5],
"image_embedding": [0.1, 0.1, 0.1, 0.1, 0.1],
"audio_embedding": [34, 18.5, -6.0, -12, 115, 96.5],
},
{
"user": "mary",
"age": 14,
"job": "doctor",
"description": "a medical professional who treats diseases and helps people stay healthy",
"last_updated": sample_datetimes["low"].timestamp(),
"credit_score": "low",
"location": "-122.4194,37.7749",
"user_embedding": [0.1, 0.1, 0.5],
"image_embedding": [0.1, 0.2, 0.3, 0.4, 0.5],
"audio_embedding": [0.0, -1.06, 4.55, -1.93, 0.0, 1.53],
},
{
"user": "nancy",
"age": 94,
"job": "doctor",
"description": "a research scientist specializing in cancers and diseases of the lungs",
"last_updated": sample_datetimes["mid"].timestamp(),
"credit_score": "high",
"location": "-122.4194,37.7749",
"user_embedding": [0.7, 0.1, 0.5],
"image_embedding": [0.1, 0.1, 0.3, 0.3, 0.5],
"audio_embedding": [2.75, -0.33, -3.01, -0.52, 5.59, -2.30],
},
{
"user": "tyler",
"age": 100,
"job": "engineer",
"description": "a software developer with expertise in mathematics and computer science",
"last_updated": sample_datetimes["mid"].timestamp(),
"credit_score": "high",
"location": "-110.0839,37.3861",
"user_embedding": [0.1, 0.4, 0.5],
"image_embedding": [-0.1, -0.2, -0.3, -0.4, -0.5],
"audio_embedding": [1.11, -6.73, 5.41, 1.04, 3.92, 0.73],
},
{
"user": "tim",
"age": 12,
"job": "dermatologist",
"description": "a medical professional specializing in diseases of the skin",
"last_updated": sample_datetimes["mid"].timestamp(),
"credit_score": "high",
"location": "-110.0839,37.3861",
"user_embedding": [0.4, 0.4, 0.5],
"image_embedding": [-0.1, 0.0, 0.6, 0.0, -0.9],
"audio_embedding": [0.03, -2.67, -2.08, 4.57, -2.33, 0.0],
},
{
"user": "taimur",
"age": 15,
"job": "CEO",
"description": "high stress, but financially rewarding position at the head of a company",
"last_updated": sample_datetimes["high"].timestamp(),
"credit_score": "low",
"location": "-110.0839,37.3861",
"user_embedding": [0.6, 0.1, 0.5],
"image_embedding": [1.1, 1.2, -0.3, -4.1, 5.0],
"audio_embedding": [0.68, 0.26, 2.08, 2.96, 0.01, 5.13],
},
{
"user": "joe",
"age": 35,
"job": "dentist",
"description": "like the tooth fairy because they'll take your teeth, but you have to pay them!",
"last_updated": sample_datetimes["high"].timestamp(),
"credit_score": "medium",
"location": "-110.0839,37.3861",
"user_embedding": [-0.1, -0.1, -0.5],
"image_embedding": [-0.8, 2.0, 3.1, 1.5, -1.6],
"audio_embedding": [0.91, 7.10, -2.14, -0.52, -6.08, -5.53],
},
]
def pytest_addoption(parser: pytest.Parser) -> None:
parser.addoption(
"--run-api-tests",
action="store_true",
default=False,
help="Run tests that require API keys",
)
parser.addoption(
"--run-cluster-tests",
action="store_true",
default=False,
help="Run tests that require a Redis cluster",
)
def pytest_configure(config: pytest.Config) -> None:
config.addinivalue_line(
"markers", "requires_api_keys: mark test as requiring API keys"
)
config.addinivalue_line(
"markers", "requires_cluster: mark test as requiring a Redis cluster"
)
config.addinivalue_line(
"markers",
"requires_hf: mark test as requiring HuggingFace/sentence-transformers",
)
def pytest_collection_modifyitems(
config: pytest.Config, items: list[pytest.Item]
) -> None:
# Check each flag independently
run_api_tests = config.getoption("--run-api-tests")
run_cluster_tests = config.getoption("--run-cluster-tests")
# Create skip markers
skip_api = pytest.mark.skip(
reason="Skipping test because API keys are not provided. Use --run-api-tests to run these tests."
)
skip_cluster = pytest.mark.skip(
reason="Skipping test because Redis cluster is not available. Use --run-cluster-tests to run these tests."
)
skip_hf = pytest.mark.skip(
reason="Skipping test because sentence-transformers is not supported on Python 3.14+"
)
# Apply skip markers independently based on flags
for item in items:
if item.get_closest_marker("requires_api_keys") and not run_api_tests:
item.add_marker(skip_api)
if item.get_closest_marker("requires_cluster") and not run_cluster_tests:
item.add_marker(skip_cluster)
if item.get_closest_marker("requires_hf") and SKIP_HF:
item.add_marker(skip_hf)
@pytest.fixture
def flat_index(sample_data, redis_url, redis_test_name):
"""
A fixture that uses the "flag" algorithm for its vector field.
"""
# construct a search index from the schema
index_name = redis_test_name("user_index")
index_prefix = redis_test_name("v1")
index = SearchIndex.from_dict(
{
"index": {
"name": index_name,
"prefix": index_prefix,
"storage_type": "hash",
},
"fields": [
{"name": "description", "type": "text"},
{"name": "credit_score", "type": "tag"},
{"name": "job", "type": "text"},
{"name": "age", "type": "numeric"},
{"name": "last_updated", "type": "numeric"},
{"name": "location", "type": "geo"},
{
"name": "user_embedding",
"type": "vector",
"attrs": {
"dims": 3,
"distance_metric": "cosine",
"algorithm": "flat",
"datatype": "float32",
},
},
],
},
redis_url=redis_url,
)
# create the index (no data yet)
index.create(overwrite=True, drop=True)
# Prepare and load the data
def hash_preprocess(item: dict) -> dict:
return {
**item,
"user_embedding": array_to_buffer(item["user_embedding"], "float32"),
}
index.load(sample_data, preprocess=hash_preprocess)
# run the test
yield index
# clean up
index.delete(drop=True)
@pytest.fixture
async def async_flat_index(sample_data, redis_url, redis_test_name):
"""
A fixture that uses the "flag" algorithm for its vector field.
"""
# construct a search index from the schema
index_name = redis_test_name("user_index")
index_prefix = redis_test_name("v1")
index = AsyncSearchIndex.from_dict(
{
"index": {
"name": index_name,
"prefix": index_prefix,
"storage_type": "hash",
},
"fields": [
{"name": "description", "type": "text"},
{"name": "credit_score", "type": "tag"},
{"name": "job", "type": "text"},
{"name": "age", "type": "numeric"},
{"name": "last_updated", "type": "numeric"},
{"name": "location", "type": "geo"},
{
"name": "user_embedding",
"type": "vector",
"attrs": {
"dims": 3,
"distance_metric": "cosine",
"algorithm": "flat",
"datatype": "float32",
},
},
],
},
redis_url=redis_url,
)
# create the index (no data yet)
await index.create(overwrite=True, drop=True)
# Prepare and load the data
def hash_preprocess(item: dict) -> dict:
return {
**item,
"user_embedding": array_to_buffer(item["user_embedding"], "float32"),
}
await index.load(sample_data, preprocess=hash_preprocess)
# run the test
yield index
# clean up
await index.delete(drop=True)
@pytest.fixture
async def async_hnsw_index(sample_data, redis_url, redis_test_name):
"""
A fixture that uses the "hnsw" algorithm for its vector field.
"""
index_name = redis_test_name("user_index")
index_prefix = redis_test_name("v1")
index = AsyncSearchIndex.from_dict(
{
"index": {
"name": index_name,
"prefix": index_prefix,
"storage_type": "hash",
},
"fields": [
{"name": "description", "type": "text"},
{"name": "credit_score", "type": "tag"},
{"name": "job", "type": "text"},
{"name": "age", "type": "numeric"},
{"name": "last_updated", "type": "numeric"},
{"name": "location", "type": "geo"},
{
"name": "user_embedding",
"type": "vector",
"attrs": {
"dims": 3,
"distance_metric": "cosine",
"algorithm": "hnsw",
"datatype": "float32",
},
},
],
},
redis_url=redis_url,
)
# create the index (no data yet)
await index.create(overwrite=True, drop=True)
# Prepare and load the data
def hash_preprocess(item: dict) -> dict:
return {
**item,
"user_embedding": array_to_buffer(item["user_embedding"], "float32"),
}
await index.load(sample_data, preprocess=hash_preprocess)
# run the test
yield index
# clean up
await index.delete(drop=True)
@pytest.fixture
def hnsw_index(sample_data, redis_url, redis_test_name):
"""
A fixture that uses the "hnsw" algorithm for its vector field.
"""
index_name = redis_test_name("user_index")
index_prefix = redis_test_name("v1")
index = SearchIndex.from_dict(
{
"index": {
"name": index_name,
"prefix": index_prefix,
"storage_type": "hash",
},
"fields": [
{"name": "description", "type": "text"},
{"name": "credit_score", "type": "tag"},
{"name": "job", "type": "text"},
{"name": "age", "type": "numeric"},
{"name": "last_updated", "type": "numeric"},
{"name": "location", "type": "geo"},
{
"name": "user_embedding",
"type": "vector",
"attrs": {
"dims": 3,
"distance_metric": "cosine",
"algorithm": "hnsw",
"datatype": "float32",
},
},
],
},
redis_url=redis_url,
)
# create the index (no data yet)
index.create(overwrite=True, drop=True)
# Prepare and load the data
def hash_preprocess(item: dict) -> dict:
return {
**item,
"user_embedding": array_to_buffer(item["user_embedding"], "float32"),
}
index.load(sample_data, preprocess=hash_preprocess)
# run the test
yield index
# clean up
index.delete(drop=True)
# Version checking utilities
def get_redis_version(client):
"""Get Redis version from client info."""
return client.info()["redis_version"]
async def get_redis_version_async(client):
"""Get Redis version from async client info."""
info = await client.info()
return info["redis_version"]
def has_redis_search_module(client):
"""Check if Redis Search module is available."""
try:
# Try to list indices - this is a Redis Search command
client.execute_command("FT._LIST")
return True
except Exception:
return False
async def has_redis_search_module_async(client):
"""Check if Redis Search module is available (async)."""
try:
# Try to list indices - this is a Redis Search command
await client.execute_command("FT._LIST")
return True
except Exception:
return False
def skip_if_redis_version_below(client, min_version: str, message: str = None):
"""
Skip test if Redis version is below minimum required.
Args:
client: Redis client instance
min_version: Minimum required Redis version
message: Custom skip message
"""
redis_version = get_redis_version(client)
if not is_version_gte(redis_version, min_version):
skip_msg = message or f"Redis version {redis_version} < {min_version} required"
pytest.skip(skip_msg)
async def skip_if_redis_version_below_async(
client, min_version: str, message: str = None
):
"""
Skip test if Redis version is below minimum required (async version).
Args:
client: Async Redis client instance
min_version: Minimum required Redis version
message: Custom skip message
"""
redis_version = await get_redis_version_async(client)
if not is_version_gte(redis_version, min_version):
skip_msg = message or f"Redis version {redis_version} < {min_version} required"
pytest.skip(skip_msg)
def skip_if_no_redis_search(client, message: str = None):
"""
Skip test if Redis Search module is not available.
Args:
client: Redis client instance
message: Custom skip message
"""
if not has_redis_search_module(client):
skip_msg = message or "Redis Search module not available"
pytest.skip(skip_msg)
async def skip_if_no_redis_search_async(client, message: str = None):
"""
Skip test if Redis Search module is not available (async version).
Args:
client: Async Redis client instance
message: Custom skip message
"""
if not await has_redis_search_module_async(client):
skip_msg = message or "Redis Search module not available"
pytest.skip(skip_msg)