Skip to content

Commit e92dc6a

Browse files
authored
Iot flaky tests (#3068)
* Checks if min_passes can be used now that we have swapped out devrel tools * Replace imports. * More random registry id
1 parent d93085b commit e92dc6a

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

iot/api-client/manager/manager_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
import os
1717
import sys
1818
import time
19+
import uuid
1920

2021
# Add command receiver for bootstrapping device registry / device for testing
2122
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'mqtt_example')) # noqa
22-
from gcp_devrel.testing.flaky import flaky
23+
from flaky import flaky
2324
from google.cloud import pubsub
2425
import pytest
2526

@@ -38,7 +39,7 @@
3839
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
3940

4041
pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id)
41-
registry_id = 'test-registry-{}'.format(int(time.time()))
42+
registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time()))
4243

4344

4445
@pytest.fixture(scope="session", autouse=True)
@@ -362,7 +363,7 @@ def test_add_patch_delete_es256(test_topic, capsys):
362363
service_account_json, project_id, cloud_region, registry_id)
363364

364365

365-
@flaky
366+
@flaky(max_runs=5, min_passes=1)
366367
def test_send_command(test_topic, capsys):
367368
device_id = device_id_template.format('RSA256')
368369
manager.create_registry(

iot/api-client/manager/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
cryptography==2.8
22
flaky==3.6.1
3-
gcp-devrel-py-tools==0.0.15
43
google-api-python-client==1.7.11
54
google-auth-httplib2==0.0.3
65
google-auth==1.11.2

iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
import os
1616
import sys
1717
import time
18+
import uuid
1819

1920
from google.cloud import pubsub
2021

2122
# Add manager for bootstrapping device registry / device for testing
2223
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa
23-
from gcp_devrel.testing.flaky import flaky
24+
from flaky import flaky
2425
import manager
2526

2627
import pytest
@@ -39,7 +40,7 @@
3940
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
4041

4142
pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id)
42-
registry_id = 'test-registry-{}'.format(int(time.time()))
43+
registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time()))
4344

4445
mqtt_bridge_hostname = 'mqtt.googleapis.com'
4546
mqtt_bridge_port = 443
@@ -182,7 +183,7 @@ def test_config(test_topic, capsys):
182183
assert '/devices/{}/config'.format(device_id) in out
183184

184185

185-
@flaky(max_runs=5)
186+
@flaky(max_runs=5, min_passes=1)
186187
def test_receive_command(capsys):
187188
device_id = device_id_template.format('RSA256')
188189
manager.create_registry(
@@ -234,7 +235,7 @@ def test_receive_command(capsys):
234235
assert '\'me want cookies\'' in out # Verify can receive command
235236

236237

237-
@flaky(max_runs=5)
238+
@flaky(max_runs=5, min_passes=1)
238239
def test_gateway_listen_for_bound_device_configs(test_topic, capsys):
239240
gateway_id = device_id_template.format('RS256')
240241
device_id = device_id_template.format('noauthbind')
@@ -280,7 +281,7 @@ def test_gateway_listen_for_bound_device_configs(test_topic, capsys):
280281
assert 'Received message' in out
281282

282283

283-
@flaky(max_runs=5)
284+
@flaky(max_runs=5, min_passes=1)
284285
def test_gateway_send_data_for_device(test_topic, capsys):
285286
gateway_id = device_id_template.format('RS256')
286287
device_id = device_id_template.format('noauthbind')

iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616
import sys
1717
import time
18+
import uuid
1819

1920
from google.cloud import pubsub
2021

@@ -23,7 +24,7 @@
2324
# Add manager as library
2425
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'manager')) # noqa
2526
import cloudiot_mqtt_image
26-
from gcp_devrel.testing.flaky import flaky
27+
from flaky import flaky
2728
import manager
2829

2930

@@ -39,7 +40,7 @@
3940
service_account_json = os.environ['GOOGLE_APPLICATION_CREDENTIALS']
4041

4142
pubsub_topic = 'projects/{}/topics/{}'.format(project_id, topic_id)
42-
registry_id = 'test-registry-{}'.format(int(time.time()))
43+
registry_id = 'test-registry-{}-{}'.format(uuid.uuid1(), int(time.time()))
4344

4445
image_path = './resources/owlister_hootie.png'
4546

@@ -88,7 +89,7 @@ def test_image(test_topic, capsys):
8889
assert 'on_publish' in out
8990

9091

91-
@flaky(max_runs=5)
92+
@flaky(max_runs=5, min_passes=1)
9293
def test_image_recv(test_topic, capsys):
9394
"""Transmit an image with IoT Core and receive it from PubSub"""
9495
subscriber = pubsub.SubscriberClient()

0 commit comments

Comments
 (0)