Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iot flaky tests #3068

Merged
merged 5 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions iot/api-client/manager/manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
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
from gcp_devrel.testing.flaky import flaky
from flaky import flaky
from google.cloud import pubsub
import pytest

Expand All @@ -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(uuid.uuid1(), int(time.time()))


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -362,7 +363,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(
Expand Down
1 change: 0 additions & 1 deletion iot/api-client/manager/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 6 additions & 5 deletions iot/api-client/mqtt_example/cloudiot_mqtt_example_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import os
import sys
import time
import uuid

from google.cloud import pubsub

# 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
Expand All @@ -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
Expand Down Expand Up @@ -182,7 +183,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(
Expand Down Expand Up @@ -234,7 +235,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')
Expand Down Expand Up @@ -280,7 +281,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')
Expand Down
7 changes: 4 additions & 3 deletions iot/api-client/mqtt_example/cloudiot_mqtt_image_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import sys
import time
import uuid

from google.cloud import pubsub

Expand All @@ -23,7 +24,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


Expand All @@ -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'

Expand Down Expand Up @@ -88,7 +89,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()
Expand Down