Skip to content

Commit b1d9789

Browse files
authored
fix: Updated wait_for_ready to fix flacky tests (#9168)
## Description Fixes #9125 Updated sleep to have longer time outs (1-32 seconds) to avoid flackyness. ## Checklist - [X] I have followed [Sample Guidelines from AUTHORING_GUIDE.MD](https://togithub.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md) - [X] **Tests** pass: `nox -s py-3.9` (see [Test Environment Setup](https://togithub.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup)) - [X] **Lint** pass: `nox -s lint` (see [Test Environment Setup](https://togithub.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md#test-environment-setup)) - [X] Please **merge** this PR for me once it is approved.
1 parent 701eaf5 commit b1d9789

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

kms/snippets/noxfile_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
3131
# build specific Cloud project. You can also use your own string
3232
# to use your own Cloud project.
33-
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
34-
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
33+
# "gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
34+
'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
3535
# If you need to use a specific version of pip,
3636
# change pip_version_override to the string representation
3737
# of the version number, for example, "20.2.4"

kms/snippets/snippets_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ def symmetric_key_id(client, project_id, location_id, key_ring_id):
203203

204204

205205
def wait_for_ready(client, key_version_name):
206-
for i in range(5):
206+
for i in range(4):
207207
key_version = client.get_crypto_key_version(request={'name': key_version_name})
208208
if key_version.state == kms.CryptoKeyVersion.CryptoKeyVersionState.ENABLED:
209209
return
210-
time.sleep(0.1*(i**2))
210+
time.sleep((i+1)**2)
211211
pytest.fail('{} not ready'.format(key_version_name))
212212

213213

0 commit comments

Comments
 (0)