Skip to content

Commit

Permalink
tests: harden 'test_bucket_w_default_event_based_hold' (googleapis#468)
Browse files Browse the repository at this point in the history
Reload blob w/ spurious EBH.

Closes googleapis#435.
  • Loading branch information
tseaver authored and cojenco committed Oct 13, 2021
1 parent aec0bb7 commit 0c7d27f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from google.api_core import path_template
import google.oauth2
from test_utils.retry import RetryErrors
from test_utils.retry import RetryInstanceState
from test_utils.system import unique_resource_id
from test_utils.vpcsc_config import vpcsc_config

Expand All @@ -57,12 +58,17 @@ def _bad_copy(bad_request):
return err_msg.startswith("No file found in request. (POST") and "copyTo" in err_msg


def _no_event_based_hold(blob):
return not blob.event_based_hold


retry_429 = RetryErrors(exceptions.TooManyRequests, max_tries=6)
retry_429_harder = RetryErrors(exceptions.TooManyRequests, max_tries=10)
retry_429_503 = RetryErrors(
[exceptions.TooManyRequests, exceptions.ServiceUnavailable], max_tries=10
)
retry_bad_copy = RetryErrors(exceptions.BadRequest, error_predicate=_bad_copy)
retry_no_event_based_hold = RetryInstanceState(_no_event_based_hold)


def _empty_bucket(client, bucket):
Expand Down Expand Up @@ -2482,6 +2488,11 @@ def test_bucket_w_default_event_based_hold(self):
self.assertFalse(bucket.retention_policy_locked)

blob.upload_from_string(payload)

# https://github.com/googleapis/python-storage/issues/435
if blob.event_based_hold:
retry_no_event_based_hold(blob.reload)()

self.assertFalse(blob.event_based_hold)
self.assertFalse(blob.temporary_hold)
self.assertIsNone(blob.retention_expiration_time)
Expand Down

0 comments on commit 0c7d27f

Please sign in to comment.