Skip to content
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

fix: 941 - respect rate-limits during integration tests #943

Merged
merged 4 commits into from
Jul 7, 2024

Conversation

monsieurtanuki
Copy link
Contributor

What

  • Now we respect the rate limites during integration tests in PROD data for "search products" and "get product" queries.
  • Basically, a couple of classes, and some refactoring around tests, where "search products" needed to be gathered.

Fixes bug(s)

Files

New files:

  • too_many_requests_exception.dart: Exception when the server returns "Too many requests".
  • too_many_requests_manager.dart: Manager dedicated to "too many requests" server response.

Deleted files:

  • api_get_to_be_completed_products_test.dart: moved "searchProduct" code to api_search_products_test
  • api_get_user_products_test.dart: moved "searchProduct" code to api_search_products_test
  • api_matched_product_v2_test.dart: moved "searchProduct" code to api_search_products_test

Impacted files:

  • api_get_localized_product_test.dart: now using the TooManyRequestsManager for "getProduct" queries
  • api_get_product_image_ids_test.dart: now using the TooManyRequestsManager for "getProduct" queries
  • api_get_product_test.dart: moved "searchProduct" code to api_search_products_test; now using the TooManyRequestsManager for "getProduct" queries
  • api_json_to_from_test.dart: now using the TooManyRequestsManager for "getProduct" queries
  • api_matched_product_v1_test.dart: now using the TooManyRequestsManager for "getProduct" queries
  • api_not_food_get_product_test.dart: now using the TooManyRequestsManager for "getProduct" queries
  • api_ocr_ingredients_test.dart: now using the TooManyRequestsManager for "getProduct" queries
  • api_search_products_test.dart: now using the TooManyRequestsManager for "searchProducts" queries; moved code there from other test files, gathering all "searchProducts" queries here
  • get_locations_order.dart: unrelated minor improvement
  • get_proofs_order.dart: unrelated minor improvement
  • open_food_api_client.dart: now checking for TooManyRequestsExceptions for "getProduct" and "searchProducts" queries
  • openfoodfacts.dart: added the 2 new files

New files:
* `too_many_requests_exception.dart`: Exception when the server returns "Too many requests".
* `too_many_requests_manager.dart`: Manager dedicated to "too many requests" server response.

Deleted files:
* `api_get_to_be_completed_products_test.dart`: moved "searchProduct" code to `api_search_products_test`
* `api_get_user_products_test.dart`: moved "searchProduct" code to `api_search_products_test`
* `api_matched_product_v2_test.dart`: moved "searchProduct" code to `api_search_products_test`

Impacted files:
* `api_get_localized_product_test.dart`: now using the `TooManyRequestsManager` for "getProduct" queries
* `api_get_product_image_ids_test.dart`: now using the `TooManyRequestsManager` for "getProduct" queries
* `api_get_product_test.dart`: moved "searchProduct" code to `api_search_products_test`; now using the `TooManyRequestsManager` for "getProduct" queries
* `api_json_to_from_test.dart`: now using the `TooManyRequestsManager` for "getProduct" queries
* `api_matched_product_v1_test.dart`: now using the `TooManyRequestsManager` for "getProduct" queries
* `api_not_food_get_product_test.dart`: now using the `TooManyRequestsManager` for "getProduct" queries
* `api_ocr_ingredients_test.dart`: now using the `TooManyRequestsManager` for "getProduct" queries
* `api_search_products_test.dart`: now using the `TooManyRequestsManager` for "searchProducts" queries; moved code there from other test files, gathering all "searchProducts" queries here
* `get_locations_order.dart`: unrelated minor improvement
* `get_proofs_order.dart`: unrelated minor improvement
* `open_food_api_client.dart`: now checking for `TooManyRequestsException`s for "getProduct" and "searchProducts" queries
* `openfoodfacts.dart`: added the 2 new files
@monsieurtanuki monsieurtanuki requested a review from a team as a code owner June 24, 2024 13:02
@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 97.31544% with 8 lines in your changes missing coverage. Please review.

Project coverage is 75.44%. Comparing base (820d145) to head (c5d58e6).
Report is 56 commits behind head on master.

Files with missing lines Patch % Lines
test/api_search_products_test.dart 97.77% 5 Missing ⚠️
lib/src/utils/too_many_requests_exception.dart 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #943      +/-   ##
==========================================
- Coverage   76.34%   75.44%   -0.91%     
==========================================
  Files         239      248       +9     
  Lines        8494     9027     +533     
==========================================
+ Hits         6485     6810     +325     
- Misses       2009     2217     +208     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@monsieurtanuki monsieurtanuki requested a review from teolemon July 2, 2024 14:09
@monsieurtanuki monsieurtanuki requested a review from M123-dev July 7, 2024 05:57
Copy link
Contributor

@g123k g123k left a comment

Choose a reason for hiding this comment

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

LGTM 👌
Really interesting change!

@monsieurtanuki monsieurtanuki merged commit 881dc5b into openfoodfacts:master Jul 7, 2024
3 checks passed
@monsieurtanuki
Copy link
Contributor Author

Thank you @g123k for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Respect rate-limits during integration tests
4 participants