From 301503fd01428ce9463dc8d385ab7ce3b1a4cc9f Mon Sep 17 00:00:00 2001 From: Sergey Skorik Date: Wed, 28 Feb 2024 12:16:20 +0200 Subject: [PATCH] [Test] Use local devfile.yaml for workspace creation in load-test script (#22855) --- tests/performance/load-tests/devfile.yaml | 20 ++++++++++++++ tests/performance/load-tests/load-test.sh | 33 +++++++++-------------- 2 files changed, 33 insertions(+), 20 deletions(-) create mode 100644 tests/performance/load-tests/devfile.yaml diff --git a/tests/performance/load-tests/devfile.yaml b/tests/performance/load-tests/devfile.yaml new file mode 100644 index 00000000000..f0d42bc66bd --- /dev/null +++ b/tests/performance/load-tests/devfile.yaml @@ -0,0 +1,20 @@ +kind: DevWorkspace +apiVersion: workspace.devfile.io/v1alpha2 +metadata: + name: code-latest +spec: + started: true + template: + components: + - name: dev + container: + image: quay.io/devfile/universal-developer-image:latest + contributions: + - name: che-code + uri: https://eclipse-che.github.io/che-plugin-registry/main/v3/plugins/che-incubator/che-code/latest/devfile.yaml + components: + - name: che-code-runtime-description + container: + env: + - name: CODE_HOST + value: 0.0.0.0 diff --git a/tests/performance/load-tests/load-test.sh b/tests/performance/load-tests/load-test.sh index ebbca59aa1e..aedfab093e5 100755 --- a/tests/performance/load-tests/load-test.sh +++ b/tests/performance/load-tests/load-test.sh @@ -40,38 +40,30 @@ if [ -z $COMPLETITIONS_COUNT ]; then export COMPLETITIONS_COUNT=3 fi -# Checkout to user devspaces namespace -export userName=$(kubectl config view --minify -o jsonpath='{.users[0].name}' | sed 's|/.*||') -kubectl config set-context --current --namespace=$userName-devspaces - # Delete all dw and dwt objects from test namespace cleanup # Delete logs -rm dw* || true +rm dw* || true > /dev/null -# Get Openshift DevSpaces url and path to sample devfile yaml from devfile-registry -export devworkspaceUrl=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}' | sed 's/:6443//' | sed 's/api/devspaces.apps/') -export testDevfilePath="devfile-registry/devfiles/TP__cpp__c-plus-plus/devworkspace-che-code-latest.yaml" -echo "Download the devfile" -curl --insecure "$devworkspaceUrl/$testDevfilePath" -o devfile.yaml +for ((i=1; i<=$COMPLETITIONS_COUNT; i++)); do + cat devfile.yaml | sed "0,/name: code-latest/s//name: dw$i/" | kubectl apply -f - & +done -echo "Start workspaces from sample devfile" -csplit devfile.yaml /---/ -mv xx00 dwt.yaml -mv xx01 dw.yaml -kubectl apply -f dwt.yaml +wait for ((i=1; i<=$COMPLETITIONS_COUNT; i++)); do - cat dw.yaml | sed "0,/name: cpp/s//name: dw$i/" | kubectl apply -f - + kubectl wait --for=condition=Ready "dw/dw$i" --timeout=180s || true & done +wait + total_time=0 succeeded=0 echo "Wait for all workspaces are started and calculate average workspaces starting time" for ((i=1; i<=$COMPLETITIONS_COUNT; i++)); do - if kubectl wait --for=condition=Ready "dw/dw$i" --timeout=120s; then + if [ "$(kubectl get dw dw$i --template='{{.status.phase}}')" == "Running" ]; then start_time=$(kubectl get dw dw$i --template='{{range .status.conditions}}{{if eq .type "Started"}}{{.lastTransitionTime}}{{end}}{{end}}') end_time=$(kubectl get dw dw$i --template='{{range .status.conditions}}{{if eq .type "Ready"}}{{.lastTransitionTime}}{{end}}{{end}}') start_timestamp=$(date -d $start_time +%s) @@ -84,13 +76,14 @@ for ((i=1; i<=$COMPLETITIONS_COUNT; i++)); do else print_error "Timeout waiting for dw$i to become ready or an error occurred." kubectl describe dw dw$i > dw$i-log.log - kubectl logs $(oc get dw dw$i --template='{{.status.devworkspaceId}}') > dw$i-pod.log || true -fi + kubectl logs $(kubectl get dw dw$i --template='{{.status.devworkspaceId}}') > dw$i-pod.log || true +fi done +wait + print "==================== Test results ====================" print "Average workspace starting time for $succeeded workspaces from $COMPLETITIONS_COUNT started: $((total_time / succeeded)) seconds" print "$((COMPLETITIONS_COUNT - succeeded)) workspaces failed. See failed workspace pod logs in the current folder for details." trap cleanup ERR EXIT -