Skip to content

Commit b2971bf

Browse files
authored
Add test cases for sequence and cache (kubeflow#1026)
add two test cases to verify - taskruns/runs execution sequence - caching function Signed-off-by: Yihong Wang <[email protected]> Signed-off-by: Yihong Wang <[email protected]>
1 parent 68bf697 commit b2971bf

File tree

6 files changed

+409
-0
lines changed

6 files changed

+409
-0
lines changed

.tekton/pipeline.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,52 @@ spec:
607607
workspaces:
608608
- name: task-pvc
609609
workspace: pipeline-pvc
610+
- name: e2e-test-cond-dep
611+
retries: 1
612+
taskRef:
613+
name: e2e-test
614+
runAfter:
615+
- deploy
616+
- deploy-pipeline-loops-e2e
617+
params:
618+
- name: apikey
619+
value: $(params.apikey)
620+
- name: kubernetes-cluster
621+
value: $(params.kubernetes-cluster)
622+
- name: kubeflow-ns
623+
value: $(params.kubeflow-ns)
624+
- name: slack-webhook
625+
value: $(params.slack-webhook)
626+
- name: slack-channel
627+
value: $(params.slack-channel)
628+
- name: test-script
629+
value: "scripts/deploy/iks/test-condition-depend.sh"
630+
workspaces:
631+
- name: task-pvc
632+
workspace: pipeline-pvc
633+
- name: e2e-test-cache
634+
retries: 1
635+
taskRef:
636+
name: e2e-test
637+
runAfter:
638+
- deploy
639+
- deploy-pipeline-loops-e2e
640+
params:
641+
- name: apikey
642+
value: $(params.apikey)
643+
- name: kubernetes-cluster
644+
value: $(params.kubernetes-cluster)
645+
- name: kubeflow-ns
646+
value: $(params.kubeflow-ns)
647+
- name: slack-webhook
648+
value: $(params.slack-webhook)
649+
- name: slack-channel
650+
value: $(params.slack-channel)
651+
- name: test-script
652+
value: "scripts/deploy/iks/test-cache.sh"
653+
workspaces:
654+
- name: task-pvc
655+
workspace: pipeline-pvc
610656
- name: e2e-test-trusted-ai
611657
retries: 1
612658
taskRef:

scripts/deploy/iks/expect-cache.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"taskRuns": {
3+
"cache-enabled": { "elapsed": 10, "cached": true },
4+
"cache-disabled": { "elapsed": 38 }
5+
}
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sequence": ["false", "condition-1"],
3+
"taskRuns": {
4+
"false": { "elapsed": 10},
5+
"condition-1": {"elapsed": 15}
6+
}
7+
}

scripts/deploy/iks/test-cache.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2022 kubeflow.org
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# cache pipeline
18+
run_cache() {
19+
local REV=1
20+
local DURATION=$1
21+
shift
22+
local PIPELINE_ID
23+
local RUN_ID
24+
local PIPELINE_NAME="cache"
25+
26+
echo " ===== cache pipeline ====="
27+
python3 sdk/python/tests/compiler/testdata/cache.py
28+
retry 3 3 kfp --endpoint http://localhost:8888 pipeline upload -p "$PIPELINE_NAME" sdk/python/tests/compiler/testdata/cache.yaml || :
29+
PIPELINE_ID=$(kfp --endpoint http://localhost:8888 pipeline list | grep "$PIPELINE_NAME" | awk '{print $2}')
30+
if [[ -z "$PIPELINE_ID" ]]; then
31+
echo "Failed to upload pipeline"
32+
return "$REV"
33+
fi
34+
35+
local RUN_NAME="${PIPELINE_NAME}-run-$((RANDOM%10000+1))"
36+
retry 3 3 kfp --endpoint http://localhost:8888 run submit -e "exp-cache" -r "$RUN_NAME" -p "$PIPELINE_ID" || :
37+
RUN_ID=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $2}')
38+
if [[ -z "$RUN_ID" ]]; then
39+
echo "Failed to submit a run for cache pipeline"
40+
return "$REV"
41+
fi
42+
43+
local RUN_STATUS
44+
ENDTIME=$(date -ud "$DURATION minute" +%s)
45+
while [[ "$(date -u +%s)" -le "$ENDTIME" ]]; do
46+
RUN_STATUS=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $6}')
47+
if [[ "$RUN_STATUS" == "Succeeded" || "$RUN_STATUS" == "Completed" ]]; then
48+
REV=0
49+
break;
50+
fi
51+
echo " Status of condition-depend run: $RUN_STATUS"
52+
sleep 10
53+
done
54+
55+
if [[ "$REV" -ne 0 ]]; then
56+
echo " ===== cache pipeline FAILED ====="
57+
return "$REV"
58+
fi
59+
60+
# need to run the pipeline twice to verify caching
61+
RUN_NAME="${PIPELINE_NAME}-run-$((RANDOM%10000+1))"
62+
retry 3 3 kfp --endpoint http://localhost:8888 run submit -e "exp-cache" -r "$RUN_NAME" -p "$PIPELINE_ID" || :
63+
RUN_ID=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $2}')
64+
if [[ -z "$RUN_ID" ]]; then
65+
echo "Failed to submit a run for cache pipeline"
66+
return "$REV"
67+
fi
68+
69+
ENDTIME=$(date -ud "$DURATION minute" +%s)
70+
while [[ "$(date -u +%s)" -le "$ENDTIME" ]]; do
71+
RUN_STATUS=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $6}')
72+
if [[ "$RUN_STATUS" == "Succeeded" || "$RUN_STATUS" == "Completed" ]]; then
73+
REV=0
74+
break;
75+
fi
76+
echo " Status of condition-depend run: $RUN_STATUS"
77+
sleep 10
78+
done
79+
80+
if [[ "$REV" -eq 0 ]]; then
81+
python3 sdk/python/tests/verify_result.py "$RUN_ID" scripts/deploy/iks/expect-cache.json || REV=$?
82+
if [[ "$REV" -eq 0 ]]; then
83+
echo " ===== cache pipeline PASSED ====="
84+
return "$REV"
85+
fi
86+
fi
87+
88+
echo " ===== cache pipeline FAILED ====="
89+
return "$REV"
90+
}
91+
92+
RESULT=0
93+
run_cache 20 || RESULT=$?
94+
95+
STATUS_MSG=PASSED
96+
if [[ "$RESULT" -ne 0 ]]; then
97+
STATUS_MSG=FAILED
98+
fi
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2022 kubeflow.org
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# condition depend pipeline
18+
run_cond_dep() {
19+
local REV=1
20+
local DURATION=$1
21+
shift
22+
local PIPELINE_ID
23+
local RUN_ID
24+
local PIPELINE_NAME="cond-dep"
25+
26+
echo " ===== condition depend pipeline ====="
27+
python3 sdk/python/tests/compiler/testdata/condition_depend.py
28+
retry 3 3 kfp --endpoint http://localhost:8888 pipeline upload -p "$PIPELINE_NAME" sdk/python/tests/compiler/testdata/condition_depend.yaml || :
29+
PIPELINE_ID=$(kfp --endpoint http://localhost:8888 pipeline list | grep "$PIPELINE_NAME" | awk '{print $2}')
30+
if [[ -z "$PIPELINE_ID" ]]; then
31+
echo "Failed to upload pipeline"
32+
return "$REV"
33+
fi
34+
35+
local RUN_NAME="${PIPELINE_NAME}-run-$((RANDOM%10000+1))"
36+
retry 3 3 kfp --endpoint http://localhost:8888 run submit -e "exp-cond-dep" -r "$RUN_NAME" -p "$PIPELINE_ID" || :
37+
RUN_ID=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $2}')
38+
if [[ -z "$RUN_ID" ]]; then
39+
echo "Failed to submit a run for condition-depend pipeline"
40+
return "$REV"
41+
fi
42+
43+
local RUN_STATUS
44+
ENDTIME=$(date -ud "$DURATION minute" +%s)
45+
while [[ "$(date -u +%s)" -le "$ENDTIME" ]]; do
46+
RUN_STATUS=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $6}')
47+
if [[ "$RUN_STATUS" == "Completed" ]]; then
48+
REV=0
49+
break;
50+
fi
51+
echo " Status of condition-depend run: $RUN_STATUS"
52+
sleep 10
53+
done
54+
55+
if [[ "$REV" -eq 0 ]]; then
56+
python3 sdk/python/tests/verify_result.py "$RUN_ID" scripts/deploy/iks/expect-condition-depend.json || REV=$?
57+
if [[ "$REV" -eq 0 ]]; then
58+
echo " ===== condition depend pipeline PASSED ====="
59+
return "$REV"
60+
fi
61+
fi
62+
63+
echo " ===== condition depend pipeline FAILED ====="
64+
return "$REV"
65+
}
66+
67+
RESULT=0
68+
run_cond_dep 20 || RESULT=$?
69+
70+
STATUS_MSG=PASSED
71+
if [[ "$RESULT" -ne 0 ]]; then
72+
STATUS_MSG=FAILED
73+
fi

0 commit comments

Comments
 (0)