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] Dev Spaces load tests based on kubect apply #22815

Merged
merged 2 commits into from
Feb 14, 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
18 changes: 18 additions & 0 deletions tests/performance/load-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Overview
This script tests how well OpenShift environment can handle running simultaneously many of workspaces. It evaluates the performance of the system under test by checking the average results across all pods and identifying failures that occur during the testing process.

## Prerequisites
What do you need to run those tests
dmytro-ndp marked this conversation as resolved.
Show resolved Hide resolved
- `kubectl` client installed
- Openshift cluster with running Openshift DevSpaces
- test user logged into DevSpaces Dashboard(this quaranies that user namespaces are created)

## Running load tests
1. Log in to Openshift cluster with Openshift DevSpaces or Eclipse Che deployed from terminal
2. Start `load-test.sh` script from `test/e2e/performance/load-tests`. Set number of started workspaces by -c parameter(like ./load-test.sh -c 5).
3. This script gets `cpp` sample devfile.yaml from DevSpaces devfile registry and starts workspaces.
4. As results there are average time of workspace starting and number of failed workspaces.


## Results and logs
If workspace failed to start, logs are saved in current directory.
96 changes: 96 additions & 0 deletions tests/performance/load-tests/load-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash

set -e

GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color

function print() {
echo -e "${GREEN}$1${NC}"
}

function print_error() {
echo -e "${RED}$1${NC}"
}

function cleanup() {
echo "Clean up the environment"
kubectl delete dw --all > /dev/null
kubectl delete dwt --all > /dev/null
}

while getopts "c:" opt; do
case $opt in
c) export COMPLETITIONS_COUNT=$OPTARG
;;
\?) # invalid option
exit 1
;;
:)
echo "Option \"$opt\" needs an argument."
exit 1
;;
esac
done

# Set the number of workspaces to start
if [ -z $COMPLETITIONS_COUNT ]; then
echo "Parameter -c wasn't set, setting completitions count to 3."
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

# 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

echo "Start workspaces from sample devfile"
csplit devfile.yaml /---/
mv xx00 dwt.yaml
mv xx01 dw.yaml
kubectl apply -f dwt.yaml

for ((i=1; i<=$COMPLETITIONS_COUNT; i++)); do
cat dw.yaml | sed "0,/name: cpp/s//name: dw$i/" | kubectl apply -f -
done

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
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)
end_timestamp=$(date -d $end_time +%s)
dw_starting_time=$((end_timestamp - start_timestamp))

print "Devworkspace dw$i starting time: $dw_starting_time seconds"
total_time=$((total_time + dw_starting_time))
succeeded=$((succeeded + 1))
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
done

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