Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit 8e6dbe7

Browse files
Takashi Matsuocrwilcox
Takashi Matsuo
andauthored
[iot] fix: mitigate flaky tests [(#3299)](GoogleCloudPlatform/python-docs-samples#3299)
* [iot] fix: mitigate flaky tests * use uuid4 instead of time for resource name * correctly use the pytest marker * mark another test as flaky Co-authored-by: Christopher Wilcox <[email protected]>
1 parent 0aa9cf9 commit 8e6dbe7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

samples/api-client/manager/manager_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
# Add command receiver for bootstrapping device registry / device for testing
2222
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'mqtt_example')) # noqa
23-
from flaky import flaky
2423
from google.cloud import pubsub
2524
import pytest
2625

@@ -33,7 +32,7 @@
3332
es_cert_path = 'resources/ec_public.pem'
3433
rsa_cert_path = 'resources/rsa_cert.pem'
3534
rsa_private_path = 'resources/rsa_private.pem' # Must match rsa_cert
36-
topic_id = 'test-device-events-{}'.format(int(time.time()))
35+
topic_id = 'test-device-events-{}'.format(uuid.uuid4())
3736

3837
project_id = os.environ['GCLOUD_PROJECT']
3938
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
@@ -202,6 +201,7 @@ def test_add_delete_unauth_device(test_topic, capsys):
202201
assert 'UNAUTH' in out
203202

204203

204+
@pytest.mark.flaky(max_runs=5, min_passes=1)
205205
def test_add_config_unauth_device(test_topic, capsys):
206206
device_id = device_id_template.format('UNAUTH')
207207
manager.open_registry(
@@ -363,7 +363,7 @@ def test_add_patch_delete_es256(test_topic, capsys):
363363
service_account_json, project_id, cloud_region, registry_id)
364364

365365

366-
@flaky(max_runs=5, min_passes=1)
366+
@pytest.mark.flaky(max_runs=5, min_passes=1)
367367
def test_send_command(test_topic, capsys):
368368
device_id = device_id_template.format('RSA256')
369369
manager.create_registry(

0 commit comments

Comments
 (0)