Skip to content

Commit 6d04d56

Browse files
authored
fix: accept flaky behavior of service (GoogleCloudPlatform#9817)
* fix: accept flaky behavior of service * fix: fix import statement
1 parent 0b46c37 commit 6d04d56

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

batch/requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pytest==7.2.0
22
google-cloud-compute==1.11.0
33
google-cloud-resource-manager==1.10.0
44
google-cloud-storage==2.8.0
5+
flaky==3.7.0

batch/tests/test_basics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from typing import Callable
1616
import uuid
1717

18+
from flaky import flaky
19+
1820
import google.auth
1921
from google.cloud import batch_v1
2022
import pytest
@@ -90,11 +92,13 @@ def _check_logs(job, capsys):
9092
assert all("Hello world!" in log_msg for log_msg in output)
9193

9294

95+
@flaky(max_runs=3, min_passes=1)
9396
def test_script_job(job_name, capsys):
9497
job = create_script_job(PROJECT, REGION, job_name)
9598
_test_body(job, additional_test=lambda: _check_logs(job, capsys))
9699

97100

101+
@flaky(max_runs=3, min_passes=1)
98102
def test_container_job(job_name):
99103
job = create_container_job(PROJECT, REGION, job_name)
100104
_test_body(job, additional_test=lambda: _check_tasks(job_name))

batch/tests/test_bucket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import uuid
1515

16+
from flaky import flaky
1617

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

6768

69+
@flaky(max_runs=3, min_passes=1)
6870
def test_bucket_job(job_name, test_bucket):
6971
job = create_script_job_with_bucket(PROJECT, REGION, job_name, test_bucket)
7072
_test_body(job, lambda: _test_bucket_content(test_bucket))

batch/tests/test_template.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
import uuid
1616

17+
from flaky import flaky
18+
1719
import google.auth
1820
from google.cloud import batch_v1
1921
from google.cloud import compute_v1
@@ -109,6 +111,7 @@ def instance_template():
109111
operation_client.wait(project=PROJECT, operation=op.name)
110112

111113

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

0 commit comments

Comments
 (0)