Skip to content

test(portal): stop the X.509 rate limit test crossing seconds - #14884

Open
thomaseizinger wants to merge 1 commit into
mainfrom
fix-flaky-x509-rate-limit-test
Open

test(portal): stop the X.509 rate limit test crossing seconds#14884
thomaseizinger wants to merge 1 commit into
mainfrom
fix-flaky-x509-rate-limit-test

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Aug 28, 2026

Copy link
Copy Markdown
Member

PortalAPI.Client.SocketTest "rate limits failed X.509 authentication before repeating validation" fails intermittently, for example here: https://github.com/firezone/firezone/actions/runs/33148396459/job/98774513409?pr=14883

Other tests in this file already work around this by using Enum.any instead:

# Subsequent connections should be rate limited. Use Enum.any? to avoid
# flakiness from crossing second boundaries with the slow (1/s) refill rate.
rate_limited =
Enum.any?(1..3, fn _ ->
connect(Socket, attrs, connect_info: connect_info) == {:error, :rate_limit}
end)
assert rate_limited, "Expected at least one connection attempt to be rate limited"

This PR applies the same pattern to the x509 rate limiter test.

The bucket holds one token and refills one per second, so two attempts
18ms apart still straddle a second boundary and the second is admitted.
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 81.624%. first build — fix-flaky-x509-rate-limit-test into main

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants