Skip to content

Commit

Permalink
test: Add a test case for the validation (kubeflow#1051)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
yhwang authored Sep 30, 2022
1 parent 30eb178 commit 5a96b11
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .tekton/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,29 @@ spec:
workspaces:
- name: task-pvc
workspace: pipeline-pvc
- name: e2e-test-many-edges
retries: 1
taskRef:
name: e2e-test
runAfter:
- deploy
- deploy-pipeline-loops-e2e
params:
- name: apikey
value: $(params.apikey)
- name: kubernetes-cluster
value: $(params.kubernetes-cluster)
- name: kubeflow-ns
value: $(params.kubeflow-ns)
- name: slack-webhook
value: $(params.slack-webhook)
- name: slack-channel
value: $(params.slack-channel)
- name: test-script
value: "scripts/deploy/iks/test-many-edges.sh"
workspaces:
- name: task-pvc
workspace: pipeline-pvc
- name: e2e-test-trusted-ai
retries: 1
taskRef:
Expand Down
62 changes: 62 additions & 0 deletions scripts/deploy/iks/test-many-edges.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
#
# Copyright 2021 kubeflow.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# a pipeline with many edges which triggers validation in webhook
run_many_edges() {
local REV=1
local DURATION=$1
shift
local PIPELINE_ID
local RUN_ID

echo " ===== many edges ====="
python3 scripts/deploy/iks/test/many-edges.py
retry 3 3 kfp --endpoint http://localhost:8888 pipeline upload -p many-edges scripts/deploy/iks/test/many-edges.yaml || :
PIPELINE_ID=$(kfp --endpoint http://localhost:8888 pipeline list | grep 'many-edges' | awk '{print $2}')
if [[ -z "$PIPELINE_ID" ]]; then
echo "Failed to upload pipeline"
return "$REV"
fi

local RUN_NAME="many-edges-run-$((RANDOM%10000+1))"
local ENDTIME

ENDTIME=$(date -ud "5 second" +%s)
retry 3 3 kfp --endpoint http://localhost:8888 run submit -e exp-many-edges -r "$RUN_NAME" -p "$PIPELINE_ID" || :
RUN_ID=$(kfp --endpoint http://localhost:8888 run list | grep "$RUN_NAME" | awk '{print $2}')
if [[ -z "$RUN_ID" ]]; then
echo "Failed to submit a run for many edges pipeline"
return "$REV"
fi

if [[ "$(date -u +%s)" -gt "$ENDTIME" ]]; then
echo "validation duration is longer then 5 seconds"
return "$REV"
fi

# only need to verify the webhook validation. no need to verify the run status
echo " ===== many edges PASSED ====="

return 0
}

RESULT=0
run_many_edges 20 || RESULT=$?

STATUS_MSG=PASSED
if [[ "$RESULT" -ne 0 ]]; then
STATUS_MSG=FAILED
fi
51 changes: 51 additions & 0 deletions scripts/deploy/iks/test/many-edges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2020 kubeflow.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from kfp import dsl, components
import kfp

PRINT_STR = """
name: print
description: print a message
inputs:
- {name: msg, type: String}
implementation:
container:
image: alpine:3.6
command:
- echo
- {inputValue: msg}
"""

print_op = components.load_component_from_text(PRINT_STR)

echo_num = 50

@dsl.pipeline(
name='many-edges-pipeline',
description='many edges'
)
def manyecho():
dep_list = []
for idx in range(echo_num):
op = print_op("test")
if len(dep_list) > 0:
op.after(*dep_list)
dep_list.append(op)


if __name__ == '__main__':
from kfp_tekton.compiler import TektonCompiler
TektonCompiler().compile(manyecho, __file__.replace('.py', '.yaml'))
# kfp.compiler.Compiler().compile(manyecho, __file__.replace('.py', '-argo.yaml'))

0 comments on commit 5a96b11

Please sign in to comment.