mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix redis cluster
This commit is contained in:
parent
143441aa87
commit
f5eaf90921
1 changed files with 0 additions and 33 deletions
|
|
@ -2473,36 +2473,3 @@ async def test_redis_get_ttl():
|
|||
except Exception as e:
|
||||
print(f"Error occurred: {str(e)}")
|
||||
raise e
|
||||
|
||||
|
||||
def test_init_async_client_returns_same_instance():
|
||||
"""
|
||||
Test that once the init_async_client() is called the first time and a real RedisCluster
|
||||
instance is returned, subsequent calls return the same cached instance.
|
||||
"""
|
||||
# Create a fake redis cluster client to simulate a working Redis cluster client.
|
||||
fake_client = MagicMock(spec=RedisCluster)
|
||||
|
||||
with patch(
|
||||
"litellm._redis.get_redis_async_client",
|
||||
return_value=fake_client,
|
||||
) as mock_get_client:
|
||||
# Provide dummy parameters for connection pool and any kwargs.
|
||||
redis_cluster_cache = RedisClusterCache(
|
||||
async_redis_conn_pool="dummy_pool",
|
||||
startup_nodes=[
|
||||
{
|
||||
"host": "127.0.0.1",
|
||||
"port": "7100",
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
# First call should trigger a call to get_redis_async_client.
|
||||
client1 = redis_cluster_cache.init_async_client()
|
||||
# Second call should return the same instance without re‐calling get_redis_async_client.
|
||||
client2 = redis_cluster_cache.init_async_client()
|
||||
|
||||
assert client1 is fake_client
|
||||
assert client1 is client2 # confirm reuse of the client
|
||||
mock_get_client.assert_called_once()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue