Skip to content

video: use flaky on flaky timeouts #3385

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

Merged
merged 8 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
15 changes: 6 additions & 9 deletions video/cloud-client/analyze/analyze_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import pytest
from flaky import flaky

import analyze

Expand Down Expand Up @@ -69,20 +70,16 @@ def test_speech_transcription(capsys):
assert "cultural" in out


@pytest.mark.slow
# Flaky timeout
@flaky(max_runs=3, min_passes=1)
def test_detect_text_gcs(capsys):
analyze.video_detect_text_gcs("gs://cloud-samples-data/video/googlework_tiny.mp4")
out, _ = capsys.readouterr()

text_exists = False
out_upper = out.upper()
for possible_text in POSSIBLE_TEXTS:
if possible_text.upper() in out_upper:
text_exists = True
assert text_exists
assert 'Text' in out


@pytest.mark.slow
# Flaky timeout
@flaky(max_runs=3, min_passes=1)
def test_detect_text(capsys):
analyze.video_detect_text("resources/googlework_tiny.mp4")
out, _ = capsys.readouterr()
Expand Down
49 changes: 15 additions & 34 deletions video/cloud-client/analyze/beta_snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# limitations under the License.

from six.moves.urllib.request import urlopen
import time
import os
import uuid

import beta_snippets
from google.cloud import storage
import pytest
from flaky import flaky


POSSIBLE_TEXTS = [
Expand Down Expand Up @@ -112,43 +112,23 @@ def test_annotation_to_storage_streaming(capsys, video_path, bucket):
out, _ = capsys.readouterr()
assert "Storage" in out

# It takes a few seconds before the results show up on GCS.
for _ in range(10):
time.sleep(3)

blobs_iterator = bucket.list_blobs()
blobs = [blob for blob in blobs_iterator]
if len(blobs):
break

# Confirm that one output blob had been written to GCS.
assert len(blobs) > 0


@pytest.mark.slow
def test_detect_text():
# Flaky timeout
@flaky(max_runs=3, min_passes=1)
def test_detect_text(capsys):
in_file = "./resources/googlework_tiny.mp4"
text_annotations = beta_snippets.video_detect_text(in_file)

text_exists = False
for text_annotation in text_annotations:
for possible_text in POSSIBLE_TEXTS:
if possible_text.upper() in text_annotation.text.upper():
text_exists = True
assert text_exists
beta_snippets.video_detect_text(in_file)
out, _ = capsys.readouterr()
assert 'Text' in out


@pytest.mark.slow
def test_detect_text_gcs():
# Flaky timeout
@flaky(max_runs=3, min_passes=1)
def test_detect_text_gcs(capsys):
in_file = "gs://python-docs-samples-tests/video/googlework_tiny.mp4"
text_annotations = beta_snippets.video_detect_text_gcs(in_file)

text_exists = False
for text_annotation in text_annotations:
for possible_text in POSSIBLE_TEXTS:
if possible_text.upper() in text_annotation.text.upper():
text_exists = True
assert text_exists
beta_snippets.video_detect_text_gcs(in_file)
out, _ = capsys.readouterr()
assert 'Text' in out


@pytest.mark.slow
Expand All @@ -173,7 +153,8 @@ def test_track_objects_gcs():
assert object_annotations[0].frames[0].normalized_bounding_box.left <= 1.0


@pytest.mark.slow
# Flaky Gateway
@flaky(max_runs=3, min_passes=1)
def test_streaming_automl_classification(capsys, video_path):
project_id = os.environ["GCLOUD_PROJECT"]
model_id = "VCN6363999689846554624"
Expand Down
1 change: 1 addition & 0 deletions video/cloud-client/analyze/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest==5.3.2
flaky==3.6.1