routing tests, launch.configs, redirect, stats and route statistics

This commit is contained in:
Dobromir Popov
2026-07-11 11:39:47 +03:00
parent f54ea100fb
commit 11bf460027
12 changed files with 546 additions and 80 deletions

View File

@@ -99,6 +99,21 @@ def test_route_stats_ewma_averages_samples():
# ---- choose_route --------------------------------------------------------
def test_route_stats_persist_historical_hop_latency_across_restart(tmp_path):
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)
store.record_sample("m", signature, tokens=100, elapsed_seconds=2.0, now=100.0)
store.save_to_db()
restored = RouteStatsStore(RoutingConfig(stats_half_life_seconds=1e9), db_path=db_path)
row = restored.model_rows("m", now=101.0)[0]
assert row["hop_count"] == 2
assert row["samples"] == 1
assert row["tps"] == 50.0
assert row["latency_ms"] == 2000.0
def _candidates_two_routes():
fast = RouteCandidate(nodes=[], signature="m|fast", prior_tps=100.0)
slow = RouteCandidate(nodes=[], signature="m|slow", prior_tps=50.0)