Skip to content

Commit 6396cb9

Browse files
authored
[https://nvbugs/5538098][fix] Checking connection to etcd server in unit test (#8006)
Signed-off-by: Patrice Castonguay <[email protected]>
1 parent 334e2ca commit 6396cb9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/unittest/disaggregated/test_remoteDictionary.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import signal
3+
import socket
34
import subprocess
45
import time
56
import unittest
@@ -9,6 +10,17 @@
910
from tensorrt_llm.serve.metadata_server import EtcdDictionary
1011

1112

13+
def wait_for_port(host, port, timeout=15):
14+
start = time.time()
15+
while time.time() - start < timeout:
16+
try:
17+
with socket.create_connection((host, port), timeout=1):
18+
return True
19+
except OSError:
20+
time.sleep(0.5)
21+
raise RuntimeError(f"Timeout waiting for {host}:{port}")
22+
23+
1224
def start_etcd_server():
1325
# Command to start etcd
1426
etcd_cmd = ["etcd"]
@@ -21,7 +33,6 @@ def start_etcd_server():
2133
preexec_fn=os.setsid) # This makes it run in a new process group
2234

2335
# Wait a bit for etcd to start
24-
time.sleep(5)
2536

2637
return process
2738

@@ -45,6 +56,8 @@ def setUp(self):
4556
self.host = "localhost"
4657
self.port = 2379
4758

59+
wait_for_port(self.host, self.port)
60+
4861
# Create a clean etcd client for test setup/teardown
4962
self.cleanup_client = etcd3.client(host=self.host, port=self.port)
5063

0 commit comments

Comments
 (0)