A high-throughput and memory-efficient inference and serving engine for LLMs
[CI] Wait for SSL cert refresher events in the test (#45489)
Signed-off-by: Andreas Karatzas <akaratza@amd.com>
Andreas Karatzas committed
Jun 12, 2026 at 23:57 UTC
1033ffac2eccf986fdd880f4dee64ca3b22c63c9
1 file changed
+37
-7
tests/entrypoints/serve/utils/test_ssl_cert_refresher.py
+37
-7
@@ -41,6 +41,28 @@ def touch_file(path: str) -> None:
41
Path(path).touch()
42
43
44
+async def wait_for_counts(
45
+ ssl_context: MockSSLContext,
46
+ *,
47
+ cert_chain_count: int,
48
+ ca_count: int,
49
+ timeout: float = 5.0,
50
+) -> None:
51
+ deadline = asyncio.get_running_loop().time() + timeout
52
+ while True:
53
+ if (
54
+ ssl_context.load_cert_chain_count >= cert_chain_count
55
+ and ssl_context.load_ca_count >= ca_count
56
+ ):
57
+ return
58
+
59
+ if asyncio.get_running_loop().time() >= deadline:
60
+ assert ssl_context.load_cert_chain_count >= cert_chain_count
61
+ assert ssl_context.load_ca_count >= ca_count
62
+
63
+ await asyncio.sleep(0.05)
64
+
65
+
66
@pytest.mark.asyncio
67
async def test_ssl_refresher():
68
ssl_context = MockSSLContext()
@@ -53,20 +75,28 @@ async def test_ssl_refresher():
75
assert ssl_context.load_ca_count == 0
76
77
touch_file(key_path)
56
- await asyncio.sleep(1)
57
- assert ssl_context.load_cert_chain_count == 1
78
+ await wait_for_counts(
79
+ ssl_context,
80
+ cert_chain_count=1,
81
+ ca_count=0,
82
+ )
83
assert ssl_context.load_ca_count == 0
84
85
touch_file(cert_path)
86
touch_file(ca_path)
62
- await asyncio.sleep(1)
63
- assert ssl_context.load_cert_chain_count == 2
64
- assert ssl_context.load_ca_count == 1
87
+ await wait_for_counts(
88
+ ssl_context,
89
+ cert_chain_count=2,
90
+ ca_count=1,
91
+ )
92
93
ssl_refresher.stop()
94
+ await asyncio.sleep(0)
95
+ cert_chain_count = ssl_context.load_cert_chain_count
96
+ ca_count = ssl_context.load_ca_count
97
98
touch_file(cert_path)
99
touch_file(ca_path)
100
await asyncio.sleep(1)
71
- assert ssl_context.load_cert_chain_count == 2
72
- assert ssl_context.load_ca_count == 1
101
+ assert ssl_context.load_cert_chain_count == cert_chain_count
102
+ assert ssl_context.load_ca_count == ca_count