test descriptions

This commit is contained in:
Dobromir Popov
2026-07-11 22:25:30 +03:00
parent 7d259d7c9b
commit 7cf8d9bcf3
43 changed files with 876 additions and 265 deletions

View File

@@ -56,6 +56,7 @@ def _fake_node(node_id, shard_start, shard_end, benchmark=100.0, endpoint=None):
def test_route_stats_sample_becomes_proven_and_decays():
"Route stats sample becomes proven and decays\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore(RoutingConfig(stats_half_life_seconds=100.0))
sig = "m|a[0-39]"
assert store.snapshot(sig, "m", now=0.0)["status"] == "unsampled"
@@ -68,12 +69,14 @@ def test_route_stats_sample_becomes_proven_and_decays():
def test_route_stats_rejects_near_empty_samples():
"Route stats rejects near empty samples\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore(RoutingConfig(min_sample_tokens=8))
assert not store.record_sample("m", "sig", tokens=3, elapsed_seconds=1.0)
assert store.snapshot("sig", "m")["samples"] == 0
def test_route_stats_epoch_bump_marks_stale():
"Route stats epoch bump marks stale\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore()
sig = "m|a[0-39]"
store.record_sample("m", sig, tokens=100, elapsed_seconds=10.0, now=0.0)
@@ -88,6 +91,7 @@ def test_route_stats_epoch_bump_marks_stale():
def test_route_stats_ewma_averages_samples():
"Route stats ewma averages samples\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore(RoutingConfig(stats_half_life_seconds=1e9))
sig = "m|a"
store.record_sample("m", sig, tokens=100, elapsed_seconds=10.0, now=0.0) # 10 tps
@@ -100,6 +104,7 @@ def test_route_stats_ewma_averages_samples():
def test_route_stats_persist_historical_hop_latency_across_restart(tmp_path):
"Route stats persist historical hop latency across restart\n\nTags: http, performance, persistence, routing, tracker"
db_path = str(tmp_path / "routing-stats.sqlite")
signature = "m|gpu[0-11]->cpu[12-23]"
store = RouteStatsStore(RoutingConfig(stats_half_life_seconds=1e9), db_path=db_path)
@@ -121,6 +126,7 @@ def _candidates_two_routes():
def test_choose_route_without_samples_is_deterministic_best_prior():
"Choose route without samples is deterministic best prior\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore()
fast, slow = _candidates_two_routes()
for _ in range(20):
@@ -130,6 +136,7 @@ def test_choose_route_without_samples_is_deterministic_best_prior():
def test_choose_route_traffic_proportional_to_tps():
"Choose route traffic proportional to tps\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore(RoutingConfig(stats_half_life_seconds=1e9))
fast, slow = _candidates_two_routes()
now = 0.0
@@ -149,6 +156,7 @@ def test_choose_route_traffic_proportional_to_tps():
def test_choose_route_scouts_unproven_routes_at_explore_share():
"Choose route scouts unproven routes at explore share\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore(RoutingConfig(explore_share=0.25, stats_half_life_seconds=1e9))
fast, slow = _candidates_two_routes()
now = 1.0
@@ -167,6 +175,7 @@ def test_choose_route_scouts_unproven_routes_at_explore_share():
def test_enumerate_routes_mixed_topology_yields_both_routes():
"Enumerate routes mixed topology yields both routes\n\nTags: http, performance, routing, tracker"
gpu = _fake_node("gpu", 0, 21, benchmark=11000.0)
cpu = _fake_node("cpu", 0, 39, benchmark=425.0)
candidates = _enumerate_routes([gpu, cpu], 0, 39, model="qwen3.6-35b-a3b")
@@ -182,11 +191,13 @@ def test_enumerate_routes_mixed_topology_yields_both_routes():
def test_enumerate_routes_requires_head_at_first_layer():
"Enumerate routes requires head at first layer\n\nTags: http, performance, routing, tracker"
tail_only = _fake_node("tail", 22, 39)
assert _enumerate_routes([tail_only], 0, 39, model="m") == []
def test_route_table_reports_coefficient_and_share():
"Route table reports coefficient and share\n\nTags: http, performance, routing, tracker"
store = RouteStatsStore(RoutingConfig(explore_share=0.3, stats_half_life_seconds=1e9))
fast, slow = _candidates_two_routes()
now = 1.0
@@ -207,10 +218,8 @@ def test_route_table_reports_coefficient_and_share():
def test_proxy_head_is_route_head_and_routing_endpoint_lists_routes():
"""Mixed topology (partial head 0-21 + full node 0-39): the proxy target
must be the selected route's own head, downstream hops must continue at
head.shard_end + 1 (the ADR-0020 flaw), and /v1/routing must list both
candidate routes."""
"Mixed topology (partial head 0-21 + full node 0-39): the proxy target must be the selected route's own head, downstream hops must continue at head.\n\nTags: http, performance, routing, tracker"
class ChatHandler(http.server.BaseHTTPRequestHandler):
def log_message(self, *args): # noqa: ARG002
@@ -306,6 +315,7 @@ def test_proxy_head_is_route_head_and_routing_endpoint_lists_routes():
def test_admin_model_load_request_queues_directive_on_joined_node():
"Admin model load request queues directive on joined node\n\nTags: http, performance, routing, tracker"
tracker = TrackerServer(validator_service_token="test-admin")
port = tracker.start()
try:
@@ -341,6 +351,7 @@ def test_admin_model_load_request_queues_directive_on_joined_node():
def test_endpoint_key_distinguishes_same_port_different_hosts():
"Endpoint key distinguishes same port different hosts\n\nTags: http, performance, routing, tracker"
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"