Skip to content

Fixing flacky privateca tests (#9075, #9081) #9189

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

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion privateca/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest==7.2.1
google-auth==2.16.0
google-auth==2.16.1
cryptography==39.0.1
backoff==2.2.1
3 changes: 1 addition & 2 deletions privateca/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
google-cloud-private-ca==1.6.1
google-cloud-kms==2.14.0
google-cloud-monitoring==2.14.0
google-cloud-monitoring==2.14.1
10 changes: 9 additions & 1 deletion privateca/snippets/test_certificate_authorities.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ def generate_name() -> str:
return "i" + uuid.uuid4().hex[:10]


@backoff.on_exception(backoff.expo, Exception, max_tries=3)
# We are hitting 5 CAs per minute limit which can't be changed
# We set the backoff function to use 4 as base - this way the 3rd try
# should wait for 64 seconds and avoid per minute quota
def backoff_expo_wrapper():
return backoff.expo(base=4)


@backoff.on_exception(backoff_expo_wrapper, Exception, max_tries=3)
def test_create_certificate(capsys: typing.Any) -> None:
CA_POOL_NAME = generate_name()
CA_NAME = generate_name()
Expand Down Expand Up @@ -113,6 +120,7 @@ def test_update_certificate_authority(
assert "Successfully updated the labels !" in out


@backoff.on_exception(backoff_expo_wrapper, Exception, max_tries=3)
def test_create_monitor_ca_policy(capsys: typing.Any) -> None:
create_ca_monitor_policy(PROJECT)

Expand Down
9 changes: 8 additions & 1 deletion privateca/snippets/test_subordinate_ca.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ def generate_name() -> str:
return "test-" + uuid.uuid4().hex[:10]


@backoff.on_exception(backoff.expo, Exception, max_tries=3)
# We are hitting 5 CAs per minute limit which can't be changed
# We set the backoff function to use 4 as base - this way the 3rd try
# should wait for 64 seconds and avoid per minute quota
def backoff_expo_wrapper():
return backoff.expo(base=4)


@backoff.on_exception(backoff_expo_wrapper, Exception, max_tries=3)
def test_subordinate_certificate_authority(
certificate_authority, capsys: typing.Any
) -> None:
Expand Down