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

Tests: Google Driver #33

Open
scottwernervt opened this issue Nov 7, 2018 · 3 comments
Open

Tests: Google Driver #33

scottwernervt opened this issue Nov 7, 2018 · 3 comments
Labels

Comments

@scottwernervt
Copy link
Owner

Google driver tests still randomly fail due to API rate limiting even after introducing delays. Need to rework how we use fixtures for containers and blobs.

Ideas:

  • Use one container per module for uploading and deleting files from. File names would be randomized.
  • Use retry decorator to catch API rate limit exception and pause.
  • Perform all container and blob cleanup at the end of session.
@micimize
Copy link

This just a travis cli / testing issue, right? It shouldn't effect end users?

@scottwernervt
Copy link
Owner Author

Yes, it is only a testing issue and does NOT effect end users.

@habibutsu
Copy link
Contributor

You can try make following improvements and it will useful not only for tests

--- a/src/cloudstorage/drivers/google.py
+++ b/src/cloudstorage/drivers/google.py
@@ -8,6 +8,9 @@ from datetime import datetime, timedelta
 from http import HTTPStatus
 from typing import Any, Dict, Iterable, List  # noqa: F401
 
+from urllib3.util.retry import Retry
+from requests.adapters import HTTPAdapter
+
 # noinspection PyPackageRequirements
 from google.auth.exceptions import GoogleAuthError
 
@@ -110,6 +113,13 @@ class GoogleStorageDriver(Driver):
 
         self._client = storage.Client()
 
+        retries_strategy = Retry(
+            total=5,
+            backoff_factor=0.1,
+            status_forcelist=[408, 429])
+        http = self._client._http
+        http.mount('https://', HTTPAdapter(max_retries=retries_strategy))
+
     def __iter__(self) -> Iterable[Container]:
         for bucket in self.client.list_buckets():
             yield self._make_container(bucket)

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

No branches or pull requests

3 participants