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

[Tests] Load tests should work correctly on macOs #22887

Merged
merged 3 commits into from
Mar 20, 2024
Merged
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: 16 additions & 4 deletions tests/performance/load-tests/load-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ NC='\033[0m' # No Color

# Do cleanup if the script is interrupted or fails
trap cleanup ERR SIGINT
# Detect the operating system
OS="$(uname)"

function print() {
echo -e "${GREEN}$1${NC}"
Expand Down Expand Up @@ -49,7 +51,6 @@ function setCompletitionsCount() {
if [ -z $COMPLETITIONS_COUNT ]; then
echo "Parameter -c wasn't set, setting completitions count to 3."
export COMPLETITIONS_COUNT=3
else
echo "Parameter -c was set to $COMPLETITIONS_COUNT ."
fi

Expand All @@ -62,10 +63,19 @@ function setCompletitionsCount() {
fi
}

function getTimestamp() {
if [ "$OS" = "Darwin" ]; then
date -j -f "%Y-%m-%dT%H:%M:%S" "$1" "+%s"
else
[ "$OS" = "Linux" ]
date -d $1 +%s
fi
}

function runTest() {
# start COMPLETITIONS_COUNT workspaces in parallel
for ((i = 1; i <= $COMPLETITIONS_COUNT; i++)); do
cat devworkspace.yaml | sed "0,/name: code-latest/s//name: dw$i/" | kubectl apply -f - &
awk '/name:/ && !modif { sub(/name: .*/, "name: '"dw$i"'"); modif=1 } {print}' devworkspace.yaml | kubectl apply -f - &
done
wait

Expand All @@ -78,6 +88,8 @@ function runTest() {

# Delete logs on file system if it exists
rm -f logs/dw*
# Create logs directory
mkdir logs || true

total_time=0
succeeded=0
Expand All @@ -86,8 +98,8 @@ function runTest() {
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)
end_timestamp=$(date -d $end_time +%s)
start_timestamp=$(getTimestamp $start_time)
end_timestamp=$(getTimestamp $end_time)
dw_starting_time=$((end_timestamp - start_timestamp))

print "Devworkspace dw$i starting time: $dw_starting_time seconds"
Expand Down
Loading