load test: Fix argument processing

pull/5484/head
Richard Hansen 2022-03-22 20:05:08 -04:00
parent e4ed4a0d42
commit 4c6d547e10
1 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,9 @@ error() { log "ERROR: $@" >&2; }
fatal() { error "$@"; exit 1; } fatal() { error "$@"; exit 1; }
try() { "$@" || fatal "'$@' failed"; } try() { "$@" || fatal "'$@' failed"; }
[ -n "$1" ] && [ "$1" -gt 0 ] || fatal "no duration specified"
[ -n "$2" ] && [ "$2" -gt 0 ] || fatal "no authors specified"
# Move to the Etherpad base directory. # Move to the Etherpad base directory.
MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1 MY_DIR=$(try cd "${0%/*}" && try pwd -P) || exit 1
try cd "${MY_DIR}/../../../.." try cd "${MY_DIR}/../../../.."
@ -19,7 +22,7 @@ s!"points":[^,]*!"points": 1000!
' settings.json.template >settings.json ' settings.json.template >settings.json
log "Assuming src/bin/installDeps.sh has already been run" log "Assuming src/bin/installDeps.sh has already been run"
node src/node/server.js "${@}" >/dev/null & node src/node/server.js >/dev/null &
ep_pid=$! ep_pid=$!
log "Waiting for Etherpad to accept connections (http://localhost:9001)..." log "Waiting for Etherpad to accept connections (http://localhost:9001)..."
@ -46,7 +49,7 @@ sleep 10
log "Running the load tests..." log "Running the load tests..."
# -d is duration of test, -a is number of authors to test with # -d is duration of test, -a is number of authors to test with
# by specifying the number of authors we set the overall rate of messages # by specifying the number of authors we set the overall rate of messages
etherpad-loadtest -d $1 -a $2 etherpad-loadtest -d "$1" -a "$2"
exit_code=$? exit_code=$?
kill "$ep_pid" && wait "$ep_pid" kill "$ep_pid" && wait "$ep_pid"