Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: fix test_sharded_channel failed (#35814)

wangxiaolei4df7c00859d0
diff --git a/api/tests/test_containers_integration_tests/libs/broadcast_channel/redis/test_sharded_channel.py b/api/tests/test_containers_integration_tests/libs/broadcast_channel/redis/test_sharded_channel.py
index 43915a204dc..84c1d0ca41b 100644
--- a/api/tests/test_containers_integration_tests/libs/broadcast_channel/redis/test_sharded_channel.py
+++ b/api/tests/test_containers_integration_tests/libs/broadcast_channel/redis/test_sharded_channel.py
@@ -8,6 +8,7 @@ Covers real Redis 7+ sharded pub/sub interactions including:
- Resource cleanup accounting via PUBSUB SHARDNUMSUB
"""
+import socket
import threading
import time
import uuid
@@ -356,10 +357,17 @@ class TestShardedRedisBroadcastChannelClusterIntegration:
def _get_test_topic_name(cls) -> str:
return f"test_sharded_cluster_topic_{uuid.uuid4()}"
+ @staticmethod
+ def _resolve_announced_ip(host: str) -> str:
+ """Resolve the container host name to a literal IP accepted by Redis cluster config."""
+ return socket.getaddrinfo(host, None, type=socket.SOCK_STREAM)[0][4][0]
+
@staticmethod
def _ensure_single_node_cluster(host: str, port: int) -> None:
+ """Bootstrap a single-node cluster using a literal IP for Redis node advertisement."""
client = redis.Redis(host=host, port=port, decode_responses=False)
- client.config_set("cluster-announce-ip", host)
+ announced_ip = TestShardedRedisBroadcastChannelClusterIntegration._resolve_announced_ip(host)
+ client.config_set("cluster-announce-ip", announced_ip)
client.config_set("cluster-announce-port", port)
slots = client.execute_command("CLUSTER", "SLOTS")
if not slots: