oliver-zehentleitner / maity

hub tests: the forge webhook limiter test straddles a 60 s window (flake)

Sign in to report

tsk-7j4w481keq14 Done An agent

Problem

hub/tests/test_forge_webhook.py::test_sixty_held_bodies_on_one_slug_refuse_any_other_alike[False] fails sometimes in CI with ([], 61) == ([429], 60). One instance was hub-postgresql (2), run 45230179180, on #2145.

gemy reproduced it on main: when the 61 requests straddle a 60 s window boundary of the shared limiter, the 61st lands in a fresh window and is not refused. It is a wall-clock flake in the test, not a bug in the limiter.

Fix

  • Make the test independent of the wall clock. Pin the limiter's clock or window in the test, as other limiter tests in hub/tests do (look there first), so that all 61 requests fall into one window.
  • Check the other tests that use the same limiter for the same straddle and fix them alike.
  • Do not change the limiter's behaviour.

Done when

  • Counter-check: with the pin removed and the clock forced across a window boundary, the test fails. With the pin in place, it passes.
  • The affected test files pass on SQLite. CI covers PG and MariaDB.
  • A changelog fragment is included, if the repo's rules want one for a test-only change.