From 98bc2570c43753c794873ea1d67568dd440637ee Mon Sep 17 00:00:00 2001 From: Skoryk Serhii Date: Fri, 8 Mar 2024 14:32:04 +0200 Subject: [PATCH 1/3] precreate logs folder --- tests/performance/load-tests/load-test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/performance/load-tests/load-test.sh b/tests/performance/load-tests/load-test.sh index 4f678d0b986..eb21d39be81 100755 --- a/tests/performance/load-tests/load-test.sh +++ b/tests/performance/load-tests/load-test.sh @@ -78,6 +78,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 From 8a8c7b858f1d3da5f602416992c2fc7c9b6010ea Mon Sep 17 00:00:00 2001 From: Skoryk Serhii Date: Wed, 20 Mar 2024 13:27:20 +0200 Subject: [PATCH 2/3] use awk instead of sed to work correctly on MacOs --- tests/performance/load-tests/load-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/performance/load-tests/load-test.sh b/tests/performance/load-tests/load-test.sh index eb21d39be81..df83a6173bb 100755 --- a/tests/performance/load-tests/load-test.sh +++ b/tests/performance/load-tests/load-test.sh @@ -65,7 +65,7 @@ function setCompletitionsCount() { 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 From 63ed7dc7aed12309cc054f793a5f9bb93caa7369 Mon Sep 17 00:00:00 2001 From: Skoryk Serhii Date: Wed, 20 Mar 2024 14:42:29 +0200 Subject: [PATCH 3/3] add getTimestamp func to get timestamp from linux and macos --- tests/performance/load-tests/load-test.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/performance/load-tests/load-test.sh b/tests/performance/load-tests/load-test.sh index df83a6173bb..c03ae596380 100755 --- a/tests/performance/load-tests/load-test.sh +++ b/tests/performance/load-tests/load-test.sh @@ -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}" @@ -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 @@ -62,6 +63,15 @@ 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 @@ -88,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"