package runtime import ( "testing" "github.com/krow/krow-backend/go-api/internal/config" ) // The HTTP server must not cut off a run the runtime considers legal. // // config.DeepestAgentDeadline duplicates the deep tier's deadline, because // internal/runtime already imports internal/config and a cycle to share one // number is a bad trade. This is the thing that makes the duplicate safe: the // two drifting apart is a failing test rather than a 502 in production // months later. // // It is not hypothetical. Production ran HTTP_WRITE_TIMEOUT=30s against a // balanced deadline of 60s, so the server aborted any run over half its // allowed time and the proxy in front reported 502 — a gateway error for // something no gateway did. func TestConfigKnowsTheDeepestAgentDeadline(t *testing.T) { deepest := LimitsForTier("deep").Deadline if config.DeepestAgentDeadline != deepest { t.Fatalf("config.DeepestAgentDeadline is %s but LimitsForTier(\"deep\") is %s — "+ "raise the constant, or the config validation will accept a write timeout "+ "that cuts off a legal run", config.DeepestAgentDeadline, deepest) } // And it must genuinely be the largest, or the name lies. for _, tier := range []string{"fast", "balanced", "deep", "nonsense"} { if d := LimitsForTier(tier).Deadline; d > config.DeepestAgentDeadline { t.Errorf("tier %q allows %s, which exceeds DeepestAgentDeadline %s", tier, d, config.DeepestAgentDeadline) } } }