From bd1f0672f4caa359d45bb9bd75b14e60c79d6bee Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 9 Mar 2020 16:24:32 -0700 Subject: [PATCH 1/4] Checks if min_passes can be used now that we have swapped out devrel tools --- iot/api-client/manager/manager_test.py | 2 +- iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py | 6 +++--- iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/iot/api-client/manager/manager_test.py b/iot/api-client/manager/manager_test.py index ae5cb5e7172..69353d886a3 100644 --- a/iot/api-client/manager/manager_test.py +++ b/iot/api-client/manager/manager_test.py @@ -362,7 +362,7 @@ def test_add_patch_delete_es256(test_topic, capsys): service_account_json, project_id, cloud_region, registry_id) -@flaky +@flaky(max_runs=5, min_passes=1) def test_send_command(test_topic, capsys): device_id = device_id_template.format('RSA256') manager.create_registry( diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py index c01ea1c00dc..28a6d7f1573 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py @@ -182,7 +182,7 @@ def test_config(test_topic, capsys): assert '/devices/{}/config'.format(device_id) in out -@flaky(max_runs=5) +@flaky(max_runs=5, min_passes=1) def test_receive_command(capsys): device_id = device_id_template.format('RSA256') manager.create_registry( @@ -234,7 +234,7 @@ def test_receive_command(capsys): assert '\'me want cookies\'' in out # Verify can receive command -@flaky(max_runs=5) +@flaky(max_runs=5, min_passes=1) def test_gateway_listen_for_bound_device_configs(test_topic, capsys): gateway_id = device_id_template.format('RS256') device_id = device_id_template.format('noauthbind') @@ -280,7 +280,7 @@ def test_gateway_listen_for_bound_device_configs(test_topic, capsys): assert 'Received message' in out -@flaky(max_runs=5) +@flaky(max_runs=5, min_passes=1) def test_gateway_send_data_for_device(test_topic, capsys): gateway_id = device_id_template.format('RS256') device_id = device_id_template.format('noauthbind') diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py index 6d64f9b266a..661f529a19e 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py @@ -88,7 +88,7 @@ def test_image(test_topic, capsys): assert 'on_publish' in out -@flaky(max_runs=5) +@flaky(max_runs=5, min_passes=1) def test_image_recv(test_topic, capsys): """Transmit an image with IoT Core and receive it from PubSub""" subscriber = pubsub.SubscriberClient() From b9e383994053e893f7a791f2eac99421eee50da8 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 9 Mar 2020 16:52:28 -0700 Subject: [PATCH 2/4] Replace imports. --- iot/api-client/manager/manager_test.py | 2 +- iot/api-client/manager/requirements.txt | 1 - iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py | 2 +- iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/iot/api-client/manager/manager_test.py b/iot/api-client/manager/manager_test.py index 69353d886a3..b74e242bbff 100644 --- a/iot/api-client/manager/manager_test.py +++ b/iot/api-client/manager/manager_test.py @@ -19,7 +19,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 flaky import flaky from google.cloud import pubsub import pytest diff --git a/iot/api-client/manager/requirements.txt b/iot/api-client/manager/requirements.txt index 8cade07e44c..bb2abbfa3e3 100644 --- a/iot/api-client/manager/requirements.txt +++ b/iot/api-client/manager/requirements.txt @@ -1,6 +1,5 @@ cryptography==2.8 flaky==3.6.1 -gcp-devrel-py-tools==0.0.15 google-api-python-client==1.7.11 google-auth-httplib2==0.0.3 google-auth==1.11.2 diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py index 28a6d7f1573..048145d1a71 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py @@ -20,7 +20,7 @@ # Add manager for bootstrapping device registry / device for testing sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa -from gcp_devrel.testing.flaky import flaky +from flaky import flaky import manager import pytest diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py index 661f529a19e..01fc15077ec 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py @@ -23,7 +23,7 @@ # Add manager as library sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa import cloudiot_mqtt_image -from gcp_devrel.testing.flaky import flaky +from flaky import flaky import manager From c9bf990a8d7f6cf944df45310489ed3dcff0bebf Mon Sep 17 00:00:00 2001 From: Gus Class Date: Mon, 9 Mar 2020 17:44:14 -0700 Subject: [PATCH 3/4] More random registry id --- iot/api-client/manager/manager_test.py | 3 ++- iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py | 3 ++- iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/iot/api-client/manager/manager_test.py b/iot/api-client/manager/manager_test.py index b74e242bbff..1eb3fbd52c2 100644 --- a/iot/api-client/manager/manager_test.py +++ b/iot/api-client/manager/manager_test.py @@ -16,6 +16,7 @@ import os import sys import time +import uuid # Add command receiver for bootstrapping device registry / device for testing sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'mqtt_example')) # noqa @@ -38,7 +39,7 @@ service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id) -registry_id = 'test-registry-{}'.format(int(time.time())) +registry_id = 'test-registry-{}-{}'.format(iuuid.uuid1(), int(time.time())) @pytest.fixture(scope="session", autouse=True) diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py index 048145d1a71..4f57b31ca28 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py @@ -15,6 +15,7 @@ import os import sys import time +import uuid from google.cloud import pubsub @@ -39,7 +40,7 @@ service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id) -registry_id = 'test-registry-{}'.format(int(time.time())) +registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time())) mqtt_bridge_hostname = 'mqtt.googleapis.com' mqtt_bridge_port = 443 diff --git a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py index 01fc15077ec..bfebd4a99ce 100644 --- a/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py +++ b/iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py @@ -15,6 +15,7 @@ import os import sys import time +import uuid from google.cloud import pubsub @@ -39,7 +40,7 @@ service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id) -registry_id = 'test-registry-{}'.format(int(time.time())) +registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time())) image_path = './resources/owlister_hootie.png' From b47bdbffa32022d89e3f0ef4caa7eda1c99fe080 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Tue, 10 Mar 2020 11:00:43 -0700 Subject: [PATCH 4/4] Syntax typo --- iot/api-client/manager/manager_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iot/api-client/manager/manager_test.py b/iot/api-client/manager/manager_test.py index 1eb3fbd52c2..c29d6e3c425 100644 --- a/iot/api-client/manager/manager_test.py +++ b/iot/api-client/manager/manager_test.py @@ -39,7 +39,7 @@ service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS'] pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id) -registry_id = 'test-registry-{}-{}'.format(iuuid.uuid1(), int(time.time())) +registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time())) @pytest.fixture(scope="session", autouse=True)