(bug fix) - Fix Cache Health Check for Redis when redis_version is float (#8979)

* fix allow flexible types for redis version

* test_cache_ping_with_redis_version_float

* test_cache_ping_with_redis_version_float
This commit is contained in:
Ishaan Jaff 2025-03-04 21:26:18 -08:00 committed by GitHub
parent f1a44d1fdc
commit 42931638df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -75,4 +75,4 @@ class HealthCheckCacheParams(BaseModel):
port: Optional[Union[str, int]] = None port: Optional[Union[str, int]] = None
redis_kwargs: Optional[Dict[str, Any]] = None redis_kwargs: Optional[Dict[str, Any]] = None
namespace: Optional[str] = None namespace: Optional[str] = None
redis_version: Optional[str] = None redis_version: Optional[Union[str, int, float]] = None

View file

@ -184,3 +184,21 @@ def test_cache_ping_health_check_includes_only_cache_attributes(mock_redis_succe
"host": "localhost", "host": "localhost",
"port": 6379, "port": 6379,
} }
def test_cache_ping_with_redis_version_float(mock_redis_success):
"""Test cache ping works when redis_version is a float"""
# Set redis_version as a float
mock_redis_success.cache.redis_version = 7.2
response = client.get("/cache/ping", headers={"Authorization": "Bearer sk-1234"})
assert response.status_code == 200
data = response.json()
print("data=", json.dumps(data, indent=4))
assert data["status"] == "healthy"
assert data["cache_type"] == "redis"
cache_params = data["health_check_cache_params"]
assert isinstance(cache_params, dict)
assert isinstance(cache_params.get("redis_version"), float)