Skip to content

Fix flakey ratelimit test #7105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2023
Merged

Fix flakey ratelimit test #7105

merged 2 commits into from
Sep 14, 2023

Conversation

nic-hartley
Copy link
Contributor

Closes #6952

This deletes the flakey ratelimit test and adds four new ones:

  • publish_new_crate_ratelimit_hit: Adds a row into publish_limit_buckets as though the user had been ratelimited, with a last_refill far in the future to ensure the ratelimiting code is hit
  • publish_new_crate_ratelimit_expires: Ditto, but last_refill is now juuuust far enough in the past for the ratelimit to hit
  • publish_new_crate_ratelimit_expires: Defaults the ratelimit to one crate every day, then sets the override to allow the test user to publish two crates a day, and then test that they can publish 2 tests a day and no more.
  • publish_new_crate_expired_override_ignored: Ditto, but the override expires_at is set to just moments ago, and then checks that the test user has the normal (1-crate) limit.

These tests should be infallible (well, assuming the code isn't broken, at least!) and I'm mostly only confident about that because NaiveDateTime has no time zones to worry about. Maybe try to avoid running it on a leap second boundary just in case.

(CC @LawnGnome, when you have a second)

@Turbo87 Turbo87 added C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear A-backend ⚙️ labels Sep 14, 2023
Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, and I can't break it locally. Thanks for doing this, and so thoroughly!

@LawnGnome LawnGnome merged commit e92af00 into rust-lang:main Sep 14, 2023
@nic-hartley
Copy link
Contributor Author

No problem, glad I could help!

@nic-hartley nic-hartley deleted the 6952-fix-ratelimit-test branch September 15, 2023 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix flaky rate limiter test
3 participants