Skip to content

Commit 214a22d

Browse files
committed
Fix the flaky SDK execution tests
Signed-off-by: mprahl <[email protected]>
1 parent 1fd50b9 commit 214a22d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/sdk-execution-tests/sdk_execution_tests.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
from kfp import client
2121
from kfp import dsl # noqa
2222
import kfp_server_api
23+
import kubernetes.client
24+
import kubernetes.client.rest
25+
import kubernetes.config
2326
import pytest
2427
import yaml
2528

2629
KFP_ENDPOINT = os.environ['KFP_ENDPOINT']
30+
KFP_NAMESPACE = os.getenv("KFP_NAMESPACE", "kubeflow")
2731
TIMEOUT_SECONDS = os.environ['TIMEOUT_SECONDS']
2832
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
2933
PROJECT_ROOT = os.path.abspath(
@@ -32,6 +36,7 @@
3236
'test_data_config.yaml')
3337

3438
kfp_client = client.Client(host=KFP_ENDPOINT)
39+
kubernetes.config.load_kube_config()
3540

3641

3742
@dataclasses.dataclass
@@ -123,6 +128,13 @@ def test(test_case: TestCase) -> None:
123128
api_run = wait(run_result)
124129
assert api_run.state == test_case.expected_state, f'Pipeline {test_case.name} ended with incorrect status: {api_run.state}. More info: {run_url}'
125130

131+
try:
132+
print(f'Deleting the Argo Workflow for run {api_run.run_id}')
133+
kubernetes.client.CustomObjectsApi().delete_collection_namespaced_custom_object(
134+
"argoproj.io", "v1alpha1", KFP_NAMESPACE, "workflows", label_selector=f'pipeline/runid={api_run.run_id}'
135+
)
136+
except kubernetes.client.rest.ApiException as e:
137+
print(f'Failed to delete the Argo Workflow for run {api_run.run_id}: {e}', file=sys.stderr)
126138

127139
if __name__ == '__main__':
128140
pytest.main()

0 commit comments

Comments
 (0)