mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-09-02 20:28:50 +02:00
🐛 e2e: stop racing the deadline in the stream failure check
handleStreamTicker compares updateFailure to updateMaxFailure before incrementing it, so with updateMaxFailure 2 and a 1s interval the bouncer gives up on the third consecutive failed poll, roughly 3s after the endpoint starts failing. The check slept 2s and then polled for a 200 for up to 15s, leaving about a second of margin, and once that window closes it never reopens: a runner under load turns this into a 15s wait followed by a failure. Assert the 200 immediately after the endpoint starts failing, which is always inside the window, and keep polling for the 403 that follows.
This commit is contained in:
@@ -34,10 +34,11 @@ body() {
|
|||||||
echo "[$SCENARIO] previously CIDR-banned IP must pass again once deletion is polled"
|
echo "[$SCENARIO] previously CIDR-banned IP must pass again once deletion is polled"
|
||||||
wait_for_status "http://127.0.0.1:${WEB_PORT}/foo" 200 15 -H "X-Forwarded-For: 10.0.0.1"
|
wait_for_status "http://127.0.0.1:${WEB_PORT}/foo" 200 15 -H "X-Forwarded-For: 10.0.0.1"
|
||||||
|
|
||||||
echo "[$SCENARIO] making the stream endpoint fail -> bouncer must pass for one more cycle (updateMaxFailure: 2)"
|
echo "[$SCENARIO] making the stream endpoint fail -> bouncer must still pass (updateMaxFailure: 2)"
|
||||||
lapi_set_stream_fail
|
lapi_set_stream_fail
|
||||||
sleep 2 # update cache is every 1 seconds then waiting for minimum 1 cycle
|
# No sleep: the bouncer gives up on the third failed poll, so at a 1s interval the
|
||||||
wait_for_status "http://127.0.0.1:${WEB_PORT}/foo" 200 15 -H "X-Forwarded-For: 8.8.8.8"
|
# window where it still serves is ~3s wide and never reopens. Assert inside it.
|
||||||
|
assert_status "http://127.0.0.1:${WEB_PORT}/foo" 200 -H "X-Forwarded-For: 8.8.8.8"
|
||||||
|
|
||||||
echo "[$SCENARIO] bouncer must block everything (isStreamHealthy: false)"
|
echo "[$SCENARIO] bouncer must block everything (isStreamHealthy: false)"
|
||||||
wait_for_status "http://127.0.0.1:${WEB_PORT}/foo" 403 15 -H "X-Forwarded-For: 8.8.8.8"
|
wait_for_status "http://127.0.0.1:${WEB_PORT}/foo" 403 15 -H "X-Forwarded-For: 8.8.8.8"
|
||||||
|
|||||||
Reference in New Issue
Block a user