feat(api): add load-aware client fallback
This commit is contained in:
@@ -46,6 +46,24 @@ func TestFailoverTimeBudgetExceeded(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAvoidanceFallbackContinuesToAvoidedCandidate(t *testing.T) {
|
||||
candidates := []store.RuntimeModelCandidate{
|
||||
{PlatformID: "available-candidate"},
|
||||
{PlatformID: "avoided-full-candidate", LoadAvoided: true},
|
||||
}
|
||||
|
||||
if !hasLoadAvoidanceFallback(candidates, 0, 99) {
|
||||
t.Fatal("expected non-avoided candidate to fall back to later avoided candidate")
|
||||
}
|
||||
if hasLoadAvoidanceFallback(candidates, 1, 99) {
|
||||
t.Fatal("avoided candidate should not force another load-avoidance fallback")
|
||||
}
|
||||
decision := loadAvoidanceFallbackDecision(&clients.ClientError{Code: "bad_request", StatusCode: 400, Retryable: false})
|
||||
if !decision.Retry || decision.Reason != "load_avoidance_fallback" || decision.Action != "next" {
|
||||
t.Fatalf("expected active load avoidance fallback to force next candidate, got %+v", decision)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailoverHardStopBeatsModelOverride(t *testing.T) {
|
||||
runnerPolicy := store.RunnerPolicy{
|
||||
Status: "active",
|
||||
|
||||
Reference in New Issue
Block a user