MCPcopy Create free account
hub / github.com/InferCore/InferCore / TestInfer_SkipsUnhealthyRuleBackend

Function TestInfer_SkipsUnhealthyRuleBackend

internal/server/server_test.go:25–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func 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
56func TestInfer_AllBackendsUnhealthyRouteError(t *testing.T) {
57 cfg := testConfigTwoBackends(100, true)

Callers

nothing calls this directly

Calls 5

testConfigTwoBackendsFunction · 0.85
postInferFunction · 0.85
RoutesMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected