Skip to content

The agent that grows with you

test(local-runtime): the supervisor takes the engine binary; downloads are PM's

ethernet1d88d35c3c20
diff --git a/tests/hermes_cli/test_local_runtime_downloads.py b/tests/hermes_cli/test_local_runtime_downloads.py
deleted file mode 100644
index c0ac8558e49..00000000000
--- a/tests/hermes_cli/test_local_runtime_downloads.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""Runtime downloads must not turn a transient transfer failure into a poisoned cache."""
-
-import threading
-from concurrent.futures import ThreadPoolExecutor
-from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
-from urllib.error import HTTPError
-
-import pytest
-
-from hermes_cli.local_runtime import binaries
-
-
-def asset_server():
- responses = []
- requests = []
-
- class Handler(BaseHTTPRequestHandler):
- def do_GET(self):
- requests.append(self.path)
- body, length, status = responses.pop(0)
- self.send_response(status)
- if length is not None:
- self.send_header("Content-Length", str(length))
- self.end_headers()
- self.wfile.write(body)
- self.close_connection = True
-
- def log_message(self, *args):
- pass
-
- with ThreadingHTTPServer(("127.0.0.1", 0), Handler) as server:
- thread = threading.Thread(target=server.serve_forever, daemon=True)
- thread.start()
- try:
- yield f"http://127.0.0.1:{server.server_port}/{{asset}}", responses, requests
- finally:
- server.shutdown()
- thread.join(timeout=5)
-
-
[email protected]("failure", ["short", "callback"])
[email protected]("known_length", [True, False])
-def test_download_only_publishes_complete_transfers(tmp_path, asset_server, failure, known_length):
- url, responses, requests = asset_server
- dest = tmp_path / "runtime.zip"
- payload = b"runtime archive bytes"
- responses.append((payload[:-1], len(payload), 200))
-
- def progress(done, total):
- if failure == "callback":
- raise RuntimeError("cancelled")
-
- error = RuntimeError if failure == "callback" else binaries.BinaryResolutionError
- with pytest.raises(error):
- binaries._download(url.format(asset=dest.name), dest, progress=progress)
- assert not dest.exists()
- assert not list(tmp_path.glob("*.part"))
-
- # A retry works, including servers that omit Content-Length.
- responses.append((payload, len(payload) if known_length else None, 200))
- ticks = []
- binaries._download(url.format(asset=dest.name), dest,
- progress=lambda done, total: ticks.append((done, total)))
- assert dest.read_bytes() == payload
- assert ticks[-1] == (len(payload), len(payload) if known_length else 0)
- assert len(requests) == 2
-
-
-def test_failed_request_preserves_another_active_download(tmp_path, asset_server):
- url, responses, requests = asset_server
- dest = tmp_path / "runtime.zip"
- payload = b"x" * (2 << 20)
- responses.extend([(payload, len(payload), 200), (b"", 0, 503)])
- started = threading.Event()
- resume = threading.Event()
-
- def pause_download(done, total):
- started.set()
- assert resume.wait(10), "active download was not resumed"
-
- with ThreadPoolExecutor(max_workers=1) as pool:
- active = pool.submit(binaries._download, url.format(asset=dest.name), dest,
- progress=pause_download)
- try:
- assert started.wait(10), "active download did not write its first chunk"
- with pytest.raises(HTTPError) as failed:
- binaries._download(url.format(asset=dest.name), dest)
- assert failed.value.code == 503
- finally:
- resume.set()
- active.result(timeout=10)
-
- assert dest.read_bytes() == payload
- assert not list(tmp_path.glob("*.part"))
- assert len(requests) == 2
diff --git a/tests/hermes_cli/test_local_runtime_hip_assets.py b/tests/hermes_cli/test_local_runtime_hip_assets.py
deleted file mode 100644
index c92c07740f2..00000000000
--- a/tests/hermes_cli/test_local_runtime_hip_assets.py
+++ /dev/null
@@ -1,33 +0,0 @@
-"""Offline contracts against published llama.cpp release asset names.
-
-Upstream release.yml changes 0666ad2b2b (b10356) and cff184438e (b10767),
-verified against GitHub release assets on both sides of each transition.
-"""
-
-import pytest
-
-from hermes_cli.local_runtime.binaries import BinaryResolutionError, resolve_assets
-
-
[email protected]("tag,linux_suffix,windows_suffix", [
- ("b10290", "rocm-7.2-x64.tar.gz", "hip-radeon-x64.zip"),
- ("b10355", "rocm-7.2-x64.tar.gz", "hip-radeon-x64.zip"),
- ("b10356", "rocm-7.14-x64.tar.gz", "rocm-7.14-x64.zip"),
- ("b10679", "rocm-7.14-x64.tar.gz", "rocm-7.14-x64.zip"),
- ("b10766", "rocm-7.14-x64.tar.gz", "rocm-7.14-x64.zip"),
- ("b10767", "rocm-10.0-x64.tar.gz", "rocm-10.0-x64.zip"),
- ("b10964", "rocm-10.0-x64.tar.gz", "rocm-10.0-x64.zip"),
-])
[email protected]("os_name", ["ubuntu", "win"])
-def test_hip_pin_resolves_published_release_archive(tag, linux_suffix, windows_suffix, os_name):
- suffix = linux_suffix if os_name == "ubuntu" else windows_suffix
- plan = resolve_assets(tag, "hip", os_name=os_name, arch="x64")
- assert plan.tag == tag
- assert plan.backend == "hip"
- assert plan.assets == [f"llama-{tag}-bin-{os_name}-{suffix}"]
-
-
[email protected]("os_name", ["ubuntu", "win"])
-def test_hip_rejects_unpublished_arm64_archive(os_name):
- with pytest.raises(BinaryResolutionError, match="no .*HIP.*arm64"):
- resolve_assets("b10964", "hip", os_name=os_name, arch="arm64")
diff --git a/tests/hermes_cli/test_local_runtime_load_mode.py b/tests/hermes_cli/test_local_runtime_load_mode.py
index b6d04466c65..a8ffbec6cd3 100644
--- a/tests/hermes_cli/test_local_runtime_load_mode.py
+++ b/tests/hermes_cli/test_local_runtime_load_mode.py
@@ -16,7 +16,6 @@ from hermes_cli.local_runtime import supervisor
def test_spawn_selects_supported_direct_io_option(tmp_path, monkeypatch, help_text, expected):
monkeypatch.setattr(supervisor, "runtimes_root", lambda: tmp_path / "runtime")
executable = tmp_path / "engine" / "llama-server"
- monkeypatch.setattr(supervisor, "server_binary", lambda _: executable)
probes = []
def run(argv, **kwargs):
@@ -28,7 +27,7 @@ def test_spawn_selects_supported_direct_io_option(tmp_path, monkeypatch, help_te
monkeypatch.setattr(supervisor, "spawn_server", lambda argv, **kwargs: (
commands.append(argv) or SimpleNamespace(pid=123, poll=lambda: 0), None,
))
- sup = supervisor.LlamaServerSupervisor(tmp_path / "engine", tmp_path / "models", port=19001)
+ sup = supervisor.LlamaServerSupervisor(executable, tmp_path / "models", port=19001)
monkeypatch.setattr(sup, "_write_state", lambda: None)
try:
sup._spawn()