RSpec search_spec.rb RateLimiter LimitExceeded problems

AI-generated summary

The discussion revolves around issues with the search_spec.rb test in Discourse’s RSpec tests. Mittineague initially encountered 30 test failures and then 7 after running database migrations. Some failures were due to “RateLimiter LimitExceeded” errors, which Mittineague was under the impression should be exempt in testing.

zogstrip suggested flushing Redis and using rake autospec to run tests. cpradio questioned the use of autospec, but zogstrip explained its benefits, including automatic re-running of failed tests.

After trying autospec, cpradio encountered a dozen failures, including three related to Search. zogstrip suspected a possible issue with the database locale. cpradio mentioned following the Discourse installation guide, which didn’t cover locale settings.

Continuing the discussion from Search within topic is omitting results:

I was getting things set up to do a PR - Pull Request - and figured it might be nice to include a test.

So I ran
bundle exec rspec spec/components/search_spec.rb
and got “38 examples, 30 failures” - Ouch!
* my change didn’t add any Fails, but then it didn’t remove any either :sadpanda:

After running

RAILS_ENV=development bundle exec rake db:migrate
RAILS_ENV=development bundle exec rspec spec/components/search_spec.rb

Much better, only 7 Fails. Some “expecting _ got 5” etc. and some “RateLimiter LimitExceeded”

I was under the impression that testing was exempt from rate limits.

Am I missing a command option?

TBH, I’m not all that sure that I’ll be able to write some good test code, but I’d rather not be timed out between attempts.

Have you tried flushing redis (redis-cli flushall)?

Also, you’ve got to start using autospec: rake autospec. You’re welcome :wink:

Doesn’t that run every test? Sometimes it is nice to be able to run the ones you know you are affecting or are throwing errors to help nail things down.

Does autospec do something to help increase ratelimits?

It does, but it’s clever enough to watch the files and stop what it’s currently doing to run the tests associated with the file you just saved :wink: And it will automatically keep re-trying the same tests until they’re green. Huge time saver since you don’t have to wait for rails to launch every time!

Hmm… Okay, with that in mind though, I think it doesn’t like me or it may not like my setup, as I tried it after wiping the discourse_test database, and re-seeding that database, and it gets about a dozen failures.

3 are related to Search

rspec ./spec/components/search_spec.rb:68 # Search escapes non alphanumeric characters
rspec ./spec/components/search_spec.rb:429 # Search Advanced search supports before and after in:first user:
rspec ./spec/components/search_spec.rb:485 # Search Advanced search can find by status

So I guess I’ll have to spend some time to figure out why this is happening, when I get a chance.

Might be an issue with the locale of your database or your postgresql server.

I followed

I don’t see anything mentioned there about locale… or ensuring it is set properly.