Skip to content

Commit

Permalink
fix: accept flaky behavior of service (#9817)
Browse files Browse the repository at this point in the history
* fix: accept flaky behavior of service

* fix: fix import statement
  • Loading branch information
engelke authored and pull[bot] committed Mar 20, 2024
1 parent dce06dc commit a5e6b65
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions batch/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ pytest==7.2.0
google-cloud-compute==1.11.0
google-cloud-resource-manager==1.10.0
google-cloud-storage==2.8.0
flaky==3.7.0
4 changes: 4 additions & 0 deletions batch/tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from typing import Callable
import uuid

from flaky import flaky

import google.auth
from google.cloud import batch_v1
import pytest
Expand Down Expand Up @@ -90,11 +92,13 @@ def _check_logs(job, capsys):
assert all("Hello world!" in log_msg for log_msg in output)


@flaky(max_runs=3, min_passes=1)
def test_script_job(job_name, capsys):
job = create_script_job(PROJECT, REGION, job_name)
_test_body(job, additional_test=lambda: _check_logs(job, capsys))


@flaky(max_runs=3, min_passes=1)
def test_container_job(job_name):
job = create_container_job(PROJECT, REGION, job_name)
_test_body(job, additional_test=lambda: _check_tasks(job_name))
2 changes: 2 additions & 0 deletions batch/tests/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import uuid

from flaky import flaky

import google.auth
from google.cloud import batch_v1
Expand Down Expand Up @@ -65,6 +66,7 @@ def _test_bucket_content(test_bucket):
assert content == file_content_template.format(task_number=i)


@flaky(max_runs=3, min_passes=1)
def test_bucket_job(job_name, test_bucket):
job = create_script_job_with_bucket(PROJECT, REGION, job_name, test_bucket)
_test_body(job, lambda: _test_bucket_content(test_bucket))
3 changes: 3 additions & 0 deletions batch/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import uuid

from flaky import flaky

import google.auth
from google.cloud import batch_v1
from google.cloud import compute_v1
Expand Down Expand Up @@ -109,6 +111,7 @@ def instance_template():
operation_client.wait(project=PROJECT, operation=op.name)


@flaky(max_runs=3, min_passes=1)
def test_template_job(job_name, instance_template):
job = create_script_job_with_template(PROJECT, REGION, job_name, instance_template.self_link)
_test_body(job)

0 comments on commit a5e6b65

Please sign in to comment.