Skip to content

Commit

Permalink
SDK - Tests - Improved the "ContainerOp.set_retry" test (kubeflow#1843)
Browse files Browse the repository at this point in the history
Properly testing the feature isntead of just comparing with golden data.
  • Loading branch information
Ark-kun authored and k8s-ci-robot committed Aug 17, 2019
1 parent d66508d commit 2b246bc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 102 deletions.
19 changes: 18 additions & 1 deletion sdk/python/tests/compiler/compiler_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
from kubernetes.client import V1Toleration


def some_op():
return dsl.ContainerOp(
name='sleep',
image='busybox',
command=['sleep 1'],
)


class TestCompiler(unittest.TestCase):
# Define the places of samples covered by unit tests.
core_sample_path = os.path.join(os.path.dirname(__file__), '..', '..', '..',
Expand Down Expand Up @@ -337,7 +345,16 @@ def test_py_volume(self):

def test_py_retry(self):
"""Test retry functionality."""
self._test_py_compile_yaml('retry')
number_of_retries = 137
def my_pipeline():
some_op().set_retry(number_of_retries)

workflow = kfp.compiler.Compiler()._compile(my_pipeline)
name_to_template = {template['name']: template for template in workflow['spec']['templates']}
main_dag_tasks = name_to_template[workflow['spec']['entrypoint']]['dag']['tasks']
template = name_to_template[main_dag_tasks[0]['template']]

self.assertEqual(template['retryStrategy']['limit'], number_of_retries)

def test_py_image_pull_secrets(self):
"""Test pipeline imagepullsecret."""
Expand Down
42 changes: 0 additions & 42 deletions sdk/python/tests/compiler/testdata/retry.py

This file was deleted.

59 changes: 0 additions & 59 deletions sdk/python/tests/compiler/testdata/retry.yaml

This file was deleted.

0 comments on commit 2b246bc

Please sign in to comment.