Repository navigation
test: the rate limit test allows for the tokens that refill while it runs - #41
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestConformance/RateLimitfailed thecanaryCI run of the 0.3.1 release commit on Postgres 17 (claim with an empty bucket = 1 jobs, wait 0s; want 0 and ~200ms). It is a timing assumption in the test; no library code changes.The queue is limited to 5 jobs per second with a burst of 2. The test claims the burst and expects the next claim to get nothing. A token refills in 200 ms, and on a loaded runner more than that passed between the two claims, so the second claim correctly got one job.
The test now bounds what each claim may return by the time elapsed since the first one, instead of assuming the claims are closer together than a refill. On a fast machine the checks are as strict as before.
The closing check ("no more than rate × time + burst are ever claimed") could not fail: it allowed 12 jobs and only 10 were inserted. It now inserts 20 and compares against the measured time.
Testing
go test -race -count=8 -run TestConformance/RateLimit ./driver/...passes for both drivers against Postgres 17.golangci-lint: 0 issues.Only a test changed, so no
hopperbenchresults.Checklist
make checkpasses — lint and the changed test run locally; the full suite runs in CI hereGODEBUG=fips140=only)docs/PLAN.md— none