Skip to content

Commit 5a96b11

Browse files
authored
test: Add a test case for the validation (kubeflow#1051)
Add a test to verify the performance of webhook validation. huge amount of edges in DAG causes a performance issue in tekton earlier. adding this test case to avoid the performance degradation. Signed-off-by: Yihong Wang <[email protected]> Signed-off-by: Yihong Wang <[email protected]>
1 parent 30eb178 commit 5a96b11

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed

.tekton/pipeline.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,29 @@ spec:
653653
workspaces:
654654
- name: task-pvc
655655
workspace: pipeline-pvc
656+
- name: e2e-test-many-edges
657+
retries: 1
658+
taskRef:
659+
name: e2e-test
660+
runAfter:
661+
- deploy
662+
- deploy-pipeline-loops-e2e
663+
params:
664+
- name: apikey
665+
value: $(params.apikey)
666+
- name: kubernetes-cluster
667+
value: $(params.kubernetes-cluster)
668+
- name: kubeflow-ns
669+
value: $(params.kubeflow-ns)
670+
- name: slack-webhook
671+
value: $(params.slack-webhook)
672+
- name: slack-channel
673+
value: $(params.slack-channel)
674+
- name: test-script
675+
value: "scripts/deploy/iks/test-many-edges.sh"
676+
workspaces:
677+
- name: task-pvc
678+
workspace: pipeline-pvc
656679
- name: e2e-test-trusted-ai
657680
retries: 1
658681
taskRef:

scripts/deploy/iks/test-many-edges.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2021 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+
# a pipeline with many edges which triggers validation in webhook
18+
run_many_edges() {
19+
local REV=1
20+
local DURATION=$1
21+
shift
22+
local PIPELINE_ID
23+
local RUN_ID
24+
25+
echo " ===== many edges ====="
26+
python3 scripts/deploy/iks/test/many-edges.py
27+
retry 3 3 kfp --endpoint http://localhost:8888 pipeline upload -p many-edges scripts/deploy/iks/test/many-edges.yaml || :
28+
PIPELINE_ID=$(kfp --endpoint http://localhost:8888 pipeline list | grep 'many-edges' | awk '{print $2}')
29+
if [[ -z "$PIPELINE_ID" ]]; then
30+
echo "Failed to upload pipeline"
31+
return "$REV"
32+
fi
33+
34+
local RUN_NAME="many-edges-run-$((RANDOM%10000+1))"
35+
local ENDTIME
36+
37+
ENDTIME=$(date -ud "5 second" +%s)
38+
retry 3 3 kfp --endpoint http://localhost:8888 run submit -e exp-many-edges -r "$RUN_NAME" -p "$PIPELINE_ID" || :
39+
RUN_ID=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $2}')
40+
if [[ -z "$RUN_ID" ]]; then
41+
echo "Failed to submit a run for many edges pipeline"
42+
return "$REV"
43+
fi
44+
45+
if [[ "$(date -u +%s)" -gt "$ENDTIME" ]]; then
46+
echo "validation duration is longer then 5 seconds"
47+
return "$REV"
48+
fi
49+
50+
# only need to verify the webhook validation. no need to verify the run status
51+
echo " ===== many edges PASSED ====="
52+
53+
return 0
54+
}
55+
56+
RESULT=0
57+
run_many_edges 20 || RESULT=$?
58+
59+
STATUS_MSG=PASSED
60+
if [[ "$RESULT" -ne 0 ]]; then
61+
STATUS_MSG=FAILED
62+
fi

scripts/deploy/iks/test/many-edges.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2020 kubeflow.org
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from kfp import dsl, components
16+
import kfp
17+
18+
PRINT_STR = """
19+
name: print
20+
description: print a message
21+
inputs:
22+
- {name: msg, type: String}
23+
implementation:
24+
container:
25+
image: alpine:3.6
26+
command:
27+
- echo
28+
- {inputValue: msg}
29+
"""
30+
31+
print_op = components.load_component_from_text(PRINT_STR)
32+
33+
echo_num = 50
34+
35+
@dsl.pipeline(
36+
name='many-edges-pipeline',
37+
description='many edges'
38+
)
39+
def manyecho():
40+
dep_list = []
41+
for idx in range(echo_num):
42+
op = print_op("test")
43+
if len(dep_list) > 0:
44+
op.after(*dep_list)
45+
dep_list.append(op)
46+
47+
48+
if __name__ == '__main__':
49+
from kfp_tekton.compiler import TektonCompiler
50+
TektonCompiler().compile(manyecho, __file__.replace('.py', '.yaml'))
51+
# kfp.compiler.Compiler().compile(manyecho, __file__.replace('.py', '-argo.yaml'))

0 commit comments

Comments
 (0)