Skip to content

Commit e0c438b

Browse files
committed
Align TTL eviction seam test with pool-aware status mapping
TTL eviction maps to 429 with the ttl-expired drop reason when the pool has endpoints and to 503 with the no-endpoints reason when it is empty. The seam test asserted an unconditional 503; split it into both paths to match the translateFlowControlOutcome contract. Signed-off-by: Matthieu Paret <mp@blackfuel.ai>
1 parent 9c38dd1 commit e0c438b

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

pkg/epp/requestcontrol/admission_integration_test.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,34 @@ func TestFlowControlAdmissionController_RealControllerSeam(t *testing.T) {
228228
require.Error(t, waitAdmit(t, filler), "queued filler should be evicted on shutdown")
229229
})
230230

231-
t.Run("evicted_ttl_returns_503_ttl_expired", func(t *testing.T) {
231+
t.Run("evicted_ttl_returns_429_ttl_expired", func(t *testing.T) {
232232
t.Parallel()
233233
// The admission adapter always defers to the controller-default TTL
234234
// (flowControlRequest.InitialEffectiveTTL() == 0), so a short DefaultRequestTTL plus a
235-
// saturated detector forces a TTL eviction of the queued request.
235+
// saturated detector forces a TTL eviction of the queued request. With a non-empty pool
236+
// the eviction is backpressure, not unavailability.
236237
h := newRealFlowControlHarness(t, realFlowControlOpts{
237238
saturation: 1.0,
238239
candidates: nonEmptyEndpoints(),
239240
requestTTL: 100 * time.Millisecond,
240241
})
241242

242243
err := waitAdmit(t, admitAsync(ctx, h.ac, "ttl-req"))
243-
requireDropped(t, err, errcommon.ServiceUnavailable, errcommon.RequestDroppedReasonTTLExpired)
244+
requireDropped(t, err, errcommon.ResourceExhausted, errcommon.RequestDroppedReasonTTLExpired)
245+
})
246+
247+
t.Run("evicted_ttl_empty_pool_returns_503_no_endpoints", func(t *testing.T) {
248+
t.Parallel()
249+
// Same TTL eviction, but against an EMPTY candidate pool the eviction signals genuine
250+
// unavailability: 503 with the no-endpoints drop reason.
251+
h := newRealFlowControlHarness(t, realFlowControlOpts{
252+
saturation: 1.0,
253+
candidates: nil,
254+
requestTTL: 100 * time.Millisecond,
255+
})
256+
257+
err := waitAdmit(t, admitAsync(ctx, h.ac, "ttl-empty-req"))
258+
requireDropped(t, err, errcommon.ServiceUnavailable, errcommon.RequestDroppedReasonNoEndpoints)
244259
})
245260

246261
t.Run("evicted_context_cancelled_returns_503_context_cancelled", func(t *testing.T) {

0 commit comments

Comments
 (0)