Skip to content

fix(auth): the rate-limit deadline test passes on a busy machine #658

Closed

Description

@PiquelChips

security::tests::rate_limits::rate_limit_deadline_includes_a_blocked_database_query (apps/auth-service/src/security/tests/rate_limits.rs:11) fails when the machine is busy.

The test sets the request deadline to 1 second (policy.request_timeout), holds the rate-limit bucket's lock and expects a 504. It then releases the lock and expects the next request to get a 202 within the same 1-second deadline. On a loaded machine that second request takes longer than a second and gets a 504, so the test fails. The rate limiter is working correctly; only the test fails.

Reproduce

Run the test alone with the machine's load average around 130 to 170:

just db test -E 'test(rate_limit_deadline_includes_a_blocked_database_query)'

It failed once in four runs on a #654 checkout, and once in the full just db test. It passed the one time it ran on main (load average about 130). Nothing in #654 touches the rate limiter.

Expected

The test passes however busy the machine is, without being skipped. For example, the second request could use a longer deadline: the test only needs the first request's deadline to be short.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions