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

Commit

Permalink
[iot] fix: mitigate flaky tests [(#3299)](GoogleCloudPlatform/python-…
Browse files Browse the repository at this point in the history
…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 <crwilcox@google.com>
  • Loading branch information
Takashi Matsuo and crwilcox authored Apr 8, 2020
1 parent 0aa9cf9 commit 8e6dbe7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions samples/api-client/manager/manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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

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

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


@pytest.mark.flaky(max_runs=5, min_passes=1)
def test_add_config_unauth_device(test_topic, capsys):
device_id = device_id_template.format('UNAUTH')
manager.open_registry(
Expand Down Expand Up @@ -363,7 +363,7 @@ def test_add_patch_delete_es256(test_topic, capsys):
service_account_json, project_id, cloud_region, registry_id)


@flaky(max_runs=5, min_passes=1)
@pytest.mark.flaky(max_runs=5, min_passes=1)
def test_send_command(test_topic, capsys):
device_id = device_id_template.format('RSA256')
manager.create_registry(
Expand Down

0 comments on commit 8e6dbe7

Please sign in to comment.