diff --git a/kms/snippets/requirements-test.txt b/kms/snippets/requirements-test.txt index 758bc040f3a8..8855f3cf1f88 100644 --- a/kms/snippets/requirements-test.txt +++ b/kms/snippets/requirements-test.txt @@ -1,3 +1,2 @@ +backoff==1.10.0 pytest==5.3.2 -gcp-devrel-py-tools==0.0.15 -google-cloud-core diff --git a/kms/snippets/snippets_test.py b/kms/snippets/snippets_test.py index 9b2c7ad462a8..c5c34a281793 100644 --- a/kms/snippets/snippets_test.py +++ b/kms/snippets/snippets_test.py @@ -20,13 +20,11 @@ from google.cloud import kms_v1 from google.cloud.kms_v1 import enums from google.iam.v1.policy_pb2 import Policy - +import backoff import pytest import snippets -from gcp_devrel.testing import eventually_consistent - def create_key_helper(key_id, purpose, algorithm, t): try: @@ -181,6 +179,8 @@ def test_key_policy(self): self.member, self.role) + @backoff.on_exception( + backoff.expo, (Aborted, AssertionError), max_time=60) def check_policy(): policy = snippets.get_crypto_key_policy( self.project_id, @@ -192,8 +192,9 @@ def check_policy(): if b.role == self.role and self.member in b.members: found = True assert found - eventually_consistent.call(check_policy, - exceptions=(Aborted, AssertionError)) + + check_policy() + # remove member snippets.remove_member_from_crypto_key_policy( self.project_id, @@ -203,7 +204,9 @@ def check_policy(): self.member, self.role) - def check_policy(): + @backoff.on_exception( + backoff.expo, (Aborted, AssertionError), max_time=60) + def check_policy_again(): policy = snippets.get_crypto_key_policy( self.project_id, self.location, @@ -214,9 +217,8 @@ def check_policy(): if b.role == self.role and self.member in b.members: found = True assert not found - eventually_consistent.call( - check_policy, - exceptions=(Aborted, AssertionError)) + + check_policy_again() def test_symmetric_encrypt_decrypt(self): cipher_bytes = snippets.encrypt_symmetric(self.project_id,