Fix the issues with #9538

Signed-off-by: root <root@localhost.localdomain>
This commit is contained in:
root 2024-10-24 20:13:02 +08:00
parent 808862a55f
commit 198f2be1a5
2 changed files with 9 additions and 2 deletions

View File

@ -74,10 +74,11 @@ def init_app(app):
redis_client.initialize(master)
elif dify_config.REDIS_USE_CLUSTERS:
startup_nodes = [
{"host": node.split(":")[0], "port": int(node.split(":")[1])} for node in dify_config.REDIS_CLUSTERS.split(",")
{"host": node.split(":")[0], "port": int(node.split(":")[1])}
for node in dify_config.REDIS_CLUSTERS.split(",")
]
nodes = [ClusterNode(host=node["host"], port=node["port"]) for node in startup_nodes]
redis_client.initialize(RedisCluster(startup_nodes=nodes,password=dify_config.REDIS_CLUSTERS_PASSWORD))
redis_client.initialize(RedisCluster(startup_nodes=nodes, password=dify_config.REDIS_CLUSTERS_PASSWORD))
else:
redis_params.update(
{

View File

@ -1,6 +1,8 @@
from unittest.mock import MagicMock
import pytest
import redis
from api.extensions.ext_redis import RedisClientWrapper
from core.entities.provider_entities import ModelLoadBalancingConfiguration
from core.model_manager import LBModelManager
@ -55,6 +57,10 @@ def test_lb_model_manager_fetch_next(mocker, lb_model_manager):
start_index += 1
return start_index
fake_redis_client = redis.Redis(host="localhost", port=6379, db=0)
redis_client = RedisClientWrapper()
redis_client.initialize(fake_redis_client)
mocker.patch("redis.Redis.incr", side_effect=incr)
mocker.patch("redis.Redis.set", return_value=None)
mocker.patch("redis.Redis.expire", return_value=None)