Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Use local devfile.yaml for workspace creation in load-test script #22855

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/performance/load-tests/devfile.yaml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 13 additions & 20 deletions tests/performance/load-tests/load-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Loading