Fix rate_limiter_test.exs test "it restricts based on config values" #233

Merged
floatingghost merged 1 commits from ilja/akkoma:fix_flaky_test__rate_limiter_test_exs into develop 2022-11-01 14:25:55 +00:00
Contributor

Fixes one of the 'erratic' tests

It used a timer to sleep.
But time also goes on when doing other things, so depending on hardware, the timings could be off.
I slightly changed the tests so we still test what we functionally want.
Instead of waiting until the cache expires I now have a function to expire the test and use that.

That means we're not testing any more if the cache really expires after a certain amount of time,
but that's the responsability of the dependency imo, so shouldn't be a problem.

I also changed Pleroma.Web.Endpoint, :http, :ip in the tests to 127.0.0.1
Currently it was set to 8.8.8.8, but I see no reason for that and, while I assume that no calls
are made to it, it may come over as weird or suspicious to people.

Fixes one of the 'erratic' tests It used a timer to sleep. But time also goes on when doing other things, so depending on hardware, the timings could be off. I slightly changed the tests so we still test what we functionally want. Instead of waiting until the cache expires I now have a function to expire the test and use that. That means we're not testing any more if the cache really expires after a certain amount of time, but that's the responsability of the dependency imo, so shouldn't be a problem. I also changed `Pleroma.Web.Endpoint, :http, :ip` in the tests to `127.0.0.1` Currently it was set to 8.8.8.8, but I see no reason for that and, while I assume that no calls are made to it, it may come over as weird or suspicious to people.
ilja added 1 commit 2022-10-22 16:03:14 +00:00
ci/woodpecker/pr/woodpecker Pipeline is pending Details
495beceb0e
Fix rate_limiter_test.exs test "it restricts based on config values"
It used a timer to sleep.
But time also goes on when doing other things, so depending on hardware, the timings could be off.
I slightly changed the tests so we still test what we functionally want.
Instead of waiting until the cache expires I now have a function to expire the test and use that.

That means we're not testing any more if the cache really expires after a certain amount of time,
but that's the responsability of the dependency imo, so shouldn't be a problem.

I also changed `Pleroma.Web.Endpoint, :http, :ip` in the tests to `127.0.0.1`
Currently it was set to 8.8.8.8, but I see no reason for that and, while I assume that no calls
are made to it, it may come over as weird or suspicious to people.

weird, that 8.8.8.8 thing is just... bizarre

and yeah, probably good to remove any sleeps

seems to work nicely, thanks!

weird, that 8.8.8.8 thing is just... bizarre and yeah, probably good to remove any `sleep`s seems to work nicely, thanks!
floatingghost merged commit f1dfd76b98 into develop 2022-11-01 14:25:55 +00:00
floatingghost deleted branch fix_flaky_test__rate_limiter_test_exs 2022-11-01 14:25:55 +00:00
Sign in to join this conversation.
No description provided.