Skip to content

Commit 6822a00

Browse files
rsamborskitelpirion
authored andcommitted
Fixing flacky privateca tests (#9075, #9081) (#9189)
* Fixing flacky privateca tests (#9075, #9081) * Fixing backoff to be longer than 1 minute
1 parent 2266c0e commit 6822a00

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
pytest==7.2.1
2-
google-auth==2.16.0
2+
google-auth==2.16.1
33
cryptography==39.0.1
44
backoff==2.2.1

privateca/snippets/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
google-cloud-private-ca==1.6.1
2-
google-cloud-kms==2.14.0
3-
google-cloud-monitoring==2.14.0
2+
google-cloud-monitoring==2.14.1

privateca/snippets/test_certificate_authorities.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ def generate_name() -> str:
4040
return "i" + uuid.uuid4().hex[:10]
4141

4242

43-
@backoff.on_exception(backoff.expo, Exception, max_tries=3)
43+
# We are hitting 5 CAs per minute limit which can't be changed
44+
# We set the backoff function to use 4 as base - this way the 3rd try
45+
# should wait for 64 seconds and avoid per minute quota
46+
def backoff_expo_wrapper():
47+
return backoff.expo(base=4)
48+
49+
50+
@backoff.on_exception(backoff_expo_wrapper, Exception, max_tries=3)
4451
def test_create_certificate(capsys: typing.Any) -> None:
4552
CA_POOL_NAME = generate_name()
4653
CA_NAME = generate_name()
@@ -113,6 +120,7 @@ def test_update_certificate_authority(
113120
assert "Successfully updated the labels !" in out
114121

115122

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

privateca/snippets/test_subordinate_ca.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ def generate_name() -> str:
3838
return "test-" + uuid.uuid4().hex[:10]
3939

4040

41-
@backoff.on_exception(backoff.expo, Exception, max_tries=3)
41+
# We are hitting 5 CAs per minute limit which can't be changed
42+
# We set the backoff function to use 4 as base - this way the 3rd try
43+
# should wait for 64 seconds and avoid per minute quota
44+
def backoff_expo_wrapper():
45+
return backoff.expo(base=4)
46+
47+
48+
@backoff.on_exception(backoff_expo_wrapper, Exception, max_tries=3)
4249
def test_subordinate_certificate_authority(
4350
certificate_authority, capsys: typing.Any
4451
) -> None:

0 commit comments

Comments
 (0)