(t *testing.T)
| 23 | ) |
| 24 | |
| 25 | func TestInfer_SkipsUnhealthyRuleBackend(t *testing.T) { |
| 26 | cfg := testConfigTwoBackends(100, true) |
| 27 | srv := New(cfg) |
| 28 | srv.adapters["large-model"] = &alwaysUnhealthyAdapter{name: "large-model"} |
| 29 | |
| 30 | ts := httptest.NewServer(srv.Routes()) |
| 31 | defer ts.Close() |
| 32 | |
| 33 | status, body := postInfer(t, ts.URL, map[string]any{ |
| 34 | "tenant_id": "team-a", |
| 35 | "task_type": "simple", |
| 36 | "input": map[string]any{ |
| 37 | "text": "hello", |
| 38 | }, |
| 39 | "options": map[string]any{ |
| 40 | "stream": false, |
| 41 | "max_tokens": 128, |
| 42 | }, |
| 43 | }) |
| 44 | if status != http.StatusOK { |
| 45 | t.Fatalf("expected 200, got %d body=%s", status, string(body)) |
| 46 | } |
| 47 | var parsed map[string]any |
| 48 | if err := json.Unmarshal(body, &parsed); err != nil { |
| 49 | t.Fatalf("parse json: %v", err) |
| 50 | } |
| 51 | if parsed["selected_backend"] != "small-model" { |
| 52 | t.Fatalf("expected small-model, got %v", parsed["selected_backend"]) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestInfer_AllBackendsUnhealthyRouteError(t *testing.T) { |
| 57 | cfg := testConfigTwoBackends(100, true) |
nothing calls this directly
no test coverage detected