vutran1710 / PyrateLimiter

⚔️Python Rate-Limiter using Leaky-Bucket Algorithm Family
https://pyratelimiter.readthedocs.io
MIT License
338 stars 36 forks source link

Update test_sleep() to tolerate small differences in test execution time #42

Closed JWCook closed 2 years ago

JWCook commented 2 years ago

[00.0000] Pushed: 1 items [00.5006] Pushed: 2 items [01.0013] Pushed: 3 items [01.5019] Pushed: 4 items [02.0025] Pushed: 5 items [02.5032] Pushed: 6 items {'error': 'Bucket for test with Rate 6/5 is already full', 'identity': 'test', 'rate': '6/5', 'remaining_time': 1.9962562840009923} [05.0023] Pushed: 8 items [05.5029] Pushed: 9 items [06.0035] Pushed: 10 items [06.5042] Pushed: 11 items [07.0048] Pushed: 12 items [07.5054] Pushed: 13 items {'error': 'Bucket for test with Rate 6/5 is already full', 'identity': 'test', 'rate': '6/5', 'remaining_time': 1.996202890004497} [10.0044] Pushed: 15 items Elapsed: 10.5050 seconds

JWCook commented 2 years ago

Tests are passing on a single python version, but trying to get a matrix of multiple python versions to work. It's been awhile since I've done this in Travis CI, so it may take a few attempts.

vutran1710 commented 2 years ago

Tests are passing on a single python version, but trying to get a matrix of multiple python versions to work. It's been awhile since I've done this in Travis CI, so it may take a few attempts.

how about this in travis.yml

script:
  - poetry run test
JWCook commented 2 years ago

I was just about to suggest that. I think we don't need to use build stages here since there are no steps to run in parallel.

JWCook commented 2 years ago

@vutran1710 Okay, looks like everything is passing now!

JWCook commented 2 years ago

Ah, one small problem: now Travis seems to be running the deploy step for each python version as well. 2.3.5 got deployed, but it attempted to deploy it multiple times: https://app.travis-ci.com/github/vutran1710/PyrateLimiter/builds/238369085

For some reason I thought it would run deploy only once if there was a build matrix. Need to read the docs some more. Sorry about that!

JWCook commented 2 years ago

Actually, based on these docs, just moving deploy back into a separate stage (the way it was before) might be better, since it keeps deploy output separate from test output. Sorry, I've been mostly using GitHub Actions and GitLab CICD in recent years, and started to forget how Travis worked.

I can make another PR for that, unless you'd prefer to do it yourself.