Skip to content

Commit 9c0732e

Browse files
committed
test: fix GPU e2e tests — auto-install runtime and wait for endpoint readiness
Signed-off-by: fredespi <fredrik.espinoza@gmail.com>
1 parent 01f3e9c commit 9c0732e

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

tests/e2e/libraries/RocmCliLibrary.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,15 @@ def setup_standard_rocm(self):
5555

5656
@keyword("a managed runtime is active")
5757
def setup_active_runtime(self):
58-
"""Precondition: verify a managed runtime is active."""
58+
"""Precondition: ensure a managed runtime is active, installing if needed."""
5959
result = run_rocm("runtimes", "list")
60+
if result.contains("installed: none"):
61+
logger.info("No runtime found, installing SDK...")
62+
install = run_rocm("install", "sdk", timeout=600)
63+
assert install.rc == 0, (
64+
f"rocm install sdk failed (rc={install.rc}):\n{install.stdout}"
65+
)
66+
result = run_rocm("runtimes", "list")
6067
assert not result.contains("installed: none"), (
6168
f"No managed runtime is active:\n{result.stdout}"
6269
)

tests/e2e/libraries/ServeLibrary.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from __future__ import annotations
1212

1313
import json
14+
import time
15+
import urllib.error
1416
import urllib.request
1517

1618
from common.cli_runner import CliResult, run_rocm
@@ -90,7 +92,7 @@ def setup_localhost_model(self):
9092

9193
@keyword("a model is being served on GPU")
9294
def setup_gpu_model(self):
93-
"""Start a real model server using rocm serve."""
95+
"""Start a real model server using rocm serve, waiting for readiness."""
9496
self._serve_result = run_rocm(
9597
"serve",
9698
"Qwen/Qwen2.5-1.5B-Instruct",
@@ -104,6 +106,7 @@ def setup_gpu_model(self):
104106
)
105107
self._endpoint = "http://127.0.0.1:11435/v1"
106108
self._model_name = "Qwen/Qwen2.5-1.5B-Instruct"
109+
self._wait_for_endpoint()
107110
logger.info(f"Model served at {self._endpoint}")
108111

109112
@keyword("a model is served in the background")
@@ -170,6 +173,23 @@ def user_serves_default_engine(self):
170173
self._endpoint = "http://127.0.0.1:11435/v1"
171174
self._model_name = "Qwen/Qwen2.5-1.5B-Instruct"
172175

176+
def _wait_for_endpoint(self, timeout: int = 120):
177+
"""Poll the endpoint until it responds or timeout is reached."""
178+
assert self._endpoint is not None, "No endpoint configured"
179+
url = f"{self._endpoint}/models"
180+
deadline = time.time() + timeout
181+
while time.time() < deadline:
182+
try:
183+
req = urllib.request.Request(url)
184+
with urllib.request.urlopen(req, timeout=5) as resp:
185+
if resp.status == 200:
186+
logger.info(f"Endpoint ready at {self._endpoint}")
187+
return
188+
except (urllib.error.URLError, OSError):
189+
pass
190+
time.sleep(5)
191+
raise AssertionError(f"Endpoint {self._endpoint} not ready after {timeout}s")
192+
173193
@keyword("the dashboard offers to use the detected endpoint")
174194
def dashboard_offers_endpoint(self):
175195
"""Simulate the TUI detecting a local endpoint.

0 commit comments

Comments
 (0)