routing
This commit is contained in:
@@ -28,9 +28,10 @@ def test_dashboard_served_with_all_panels():
|
||||
).read().decode()
|
||||
for panel in PANELS:
|
||||
assert panel in html
|
||||
assert "<script>" in html # polling client embedded, no build step
|
||||
assert "<script>" in html # polling client embedded, no build step
|
||||
assert "resolveModelGroup" in html
|
||||
assert "buildModelAliasMap" in html
|
||||
assert "modelAliasKey(raw)" in html
|
||||
finally:
|
||||
tracker.stop()
|
||||
|
||||
|
||||
@@ -288,3 +288,19 @@ def test_proxy_head_is_route_head_and_routing_endpoint_lists_routes():
|
||||
assert len(table["routes"]) == 2
|
||||
sampled = [r for r in table["routes"] if r["samples"] > 0]
|
||||
assert sampled, "completed requests must produce route samples"
|
||||
|
||||
|
||||
def test_endpoint_key_distinguishes_same_port_different_hosts():
|
||||
from meshnet_node.torch_server import _clamp_downstream_hops, _endpoint_key
|
||||
|
||||
assert _endpoint_key("http://192.168.0.20:7000") == "192.168.0.20:7000"
|
||||
assert _endpoint_key("http://192.168.0.179:7000") == "192.168.0.179:7000"
|
||||
assert _endpoint_key("http://192.168.0.20:7000") != _endpoint_key("http://192.168.0.179:7000")
|
||||
|
||||
class Backend:
|
||||
shard_end = 21
|
||||
|
||||
hops = [{"endpoint": "http://192.168.0.179:7000", "start_layer": 0}]
|
||||
assert _clamp_downstream_hops(hops, Backend()) == [
|
||||
{"endpoint": "http://192.168.0.179:7000", "start_layer": 22},
|
||||
]
|
||||
|
||||
@@ -910,6 +910,57 @@ def test_tracker_route_endpoint_ignores_model_case_and_outer_whitespace():
|
||||
assert response["route"] == ["http://127.0.0.1:9101"]
|
||||
|
||||
|
||||
def test_tracker_route_prefers_distributed_over_single_full_shard():
|
||||
"""When a full 0-39 node and a partial 0-21 head coexist, /v1/route
|
||||
should return both hops — not the full shard alone."""
|
||||
tracker = TrackerServer(model_presets={
|
||||
"qwen3.6-35b-a3b": {
|
||||
"layers_start": 0,
|
||||
"layers_end": 39,
|
||||
"hf_repo": "unsloth/Qwen3.6-35B-A3B",
|
||||
"aliases": ["Qwen3.6-35B-A3B"],
|
||||
}
|
||||
})
|
||||
tracker_port = tracker.start()
|
||||
try:
|
||||
_post_json(
|
||||
f"http://127.0.0.1:{tracker_port}/v1/nodes/register",
|
||||
{"endpoint": "http://192.168.0.179:7000",
|
||||
"model": "qwen3.6-35b-a3b",
|
||||
"hf_repo": "unsloth/Qwen3.6-35B-A3B",
|
||||
"num_layers": 40,
|
||||
"shard_start": 0,
|
||||
"shard_end": 39,
|
||||
"tracker_mode": True,
|
||||
"hardware_profile": {},
|
||||
"score": 1.0},
|
||||
)
|
||||
_post_json(
|
||||
f"http://127.0.0.1:{tracker_port}/v1/nodes/register",
|
||||
{"endpoint": "http://192.168.0.20:7000",
|
||||
"model": "Qwen3.6-35B-A3B",
|
||||
"hf_repo": "unsloth/Qwen3.6-35B-A3B",
|
||||
"num_layers": 40,
|
||||
"shard_start": 0,
|
||||
"shard_end": 21,
|
||||
"tracker_mode": True,
|
||||
"hardware_profile": {},
|
||||
"score": 1.0},
|
||||
)
|
||||
|
||||
response = _get_json(
|
||||
f"http://127.0.0.1:{tracker_port}/v1/route?model=qwen3.6-35b-a3b"
|
||||
)
|
||||
finally:
|
||||
tracker.stop()
|
||||
|
||||
assert response["route"] == [
|
||||
"http://192.168.0.20:7000",
|
||||
"http://192.168.0.179:7000",
|
||||
]
|
||||
assert [node["start_layer"] for node in response["nodes"]] == [0, 22]
|
||||
|
||||
|
||||
def test_tracker_proxy_ignores_model_case_and_outer_whitespace():
|
||||
class ChatHandler(http.server.BaseHTTPRequestHandler):
|
||||
def log_message(self, fmt, *args):
|
||||
|
||||
Reference in New Issue
Block a user