The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
tests(vcr): accept REDIS_URL / REDIS_SSL_URL for managed Redis with TLS
mateo-berrif55a710e9241
diff --git a/tests/_flush_vcr_cache.py b/tests/_flush_vcr_cache.pyindex dfaba2367c7..c78958fb016 100644--- a/tests/_flush_vcr_cache.py+++ b/tests/_flush_vcr_cache.py@@ -5,18 +5,20 @@ import sysimport redis+from tests._vcr_redis_persister import _redis_url_from_env+PREFIX = "litellm:vcr:cassette:"SCAN_BATCH = 500def _client() -> redis.Redis:- host = os.environ.get("REDIS_HOST")- if not host:- sys.exit("REDIS_HOST is not set; cannot flush VCR cache")- return redis.Redis(- host=host,- port=int(os.environ.get("REDIS_PORT", 6379)),- password=os.environ.get("REDIS_PASSWORD") or None,+ url = _redis_url_from_env()+ if not url:+ sys.exit(+ "Set REDIS_URL, REDIS_SSL_URL, or REDIS_HOST to flush the VCR cache"+ )+ return redis.Redis.from_url(+ url,socket_timeout=5,socket_connect_timeout=5,decode_responses=False,diff --git a/tests/_vcr_redis_persister.py b/tests/_vcr_redis_persister.pyindex 3b1e456c0a8..32cf5c1c0e7 100644--- a/tests/_vcr_redis_persister.py+++ b/tests/_vcr_redis_persister.py@@ -14,16 +14,33 @@ def redis_key_for(cassette_path: str) -> str:return f"{REDIS_KEY_PREFIX}{os.path.relpath(str(cassette_path))}"+def _redis_url_from_env() -> Optional[str]:+ for var in ("REDIS_URL", "REDIS_SSL_URL"):+ url = os.environ.get(var)+ if url:+ return url+ host = os.environ.get("REDIS_HOST")+ if not host:+ return None+ scheme = "rediss" if os.environ.get("REDIS_SSL", "").lower() == "true" else "redis"+ auth = ""+ if os.environ.get("REDIS_PASSWORD"):+ user = os.environ.get("REDIS_USERNAME", "")+ auth = f"{user}:{os.environ['REDIS_PASSWORD']}@"+ port = os.environ.get("REDIS_PORT", "6379")+ return f"{scheme}://{auth}{host}:{port}"++def _build_default_client():import redis- host = os.environ.get("REDIS_HOST")- if not host:- raise RuntimeError("REDIS_HOST is not set")- return redis.Redis(- host=host,- port=int(os.environ.get("REDIS_PORT", 6379)),- password=os.environ.get("REDIS_PASSWORD") or None,+ url = _redis_url_from_env()+ if not url:+ raise RuntimeError(+ "Set REDIS_URL, REDIS_SSL_URL, or REDIS_HOST to enable the VCR persister"+ )+ return redis.Redis.from_url(+ url,socket_timeout=5,socket_connect_timeout=5,decode_responses=False,diff --git a/tests/llm_responses_api_testing/conftest.py b/tests/llm_responses_api_testing/conftest.pyindex c8d3bb1b10f..87ed6218eab 100644--- a/tests/llm_responses_api_testing/conftest.py+++ b/tests/llm_responses_api_testing/conftest.py@@ -88,7 +88,9 @@ def vcr_config():def _vcr_disabled() -> bool:if os.environ.get("LITELLM_VCR_DISABLE") == "1":return True- return not os.environ.get("REDIS_HOST")+ return not any(+ os.environ.get(var) for var in ("REDIS_URL", "REDIS_SSL_URL", "REDIS_HOST")+ )def pytest_recording_configure(config, vcr):diff --git a/tests/llm_translation/conftest.py b/tests/llm_translation/conftest.pyindex ed8836e2fea..9da7c981387 100644--- a/tests/llm_translation/conftest.py+++ b/tests/llm_translation/conftest.py@@ -112,7 +112,9 @@ def vcr_config():def _vcr_disabled() -> bool:if os.environ.get("LITELLM_VCR_DISABLE") == "1":return True- return not os.environ.get("REDIS_HOST")+ return not any(+ os.environ.get(var) for var in ("REDIS_URL", "REDIS_SSL_URL", "REDIS_HOST")+ )def pytest_recording_configure(config, vcr):