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

Commit

Permalink
Better reliability for flaky tests [(#1960)](GoogleCloudPlatform/pyth…
Browse files Browse the repository at this point in the history
…on-docs-samples#1960)

* Increases reliability for flaky tests
* Replaces checks where device or gateway ID could affect test outcome.
  • Loading branch information
gguuss committed Jan 10, 2019
1 parent 9b4205b commit 98e824d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions samples/api-client/manager/manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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

Expand Down Expand Up @@ -278,14 +279,24 @@ def test_add_patch_delete_es256(test_topic, capsys):
service_account_json, project_id, cloud_region, registry_id)


@flaky
def test_send_command(test_topic, capsys):
device_id = device_id_template.format('RSA256')
manager.create_registry(
service_account_json, project_id, cloud_region, pubsub_topic,
registry_id)
manager.create_rs256_device(
service_account_json, project_id, cloud_region, registry_id,
device_id, rsa_cert_path)

exists = False
devices = manager.list_devices(
service_account_json, project_id, cloud_region, registry_id)
for device in devices:
if device.get('id') == device_id:
exists = True

if not exists:
manager.create_rs256_device(
service_account_json, project_id, cloud_region, registry_id,
device_id, rsa_cert_path)

# Exercize the functionality
client = cloudiot_mqtt_example.get_client(
Expand Down
2 changes: 2 additions & 0 deletions samples/api-client/manager/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cryptography==2.4.2
flaky==3.4.0
gcp-devrel-py-tools==0.0.15
google-api-python-client==1.7.5
google-auth-httplib2==0.0.3
google-auth==1.6.1
Expand Down

0 comments on commit 98e824d

Please sign in to comment.