gatling-sample-framework/docker-run.sh

66 lines
1.6 KiB
Bash

#!/usr/bin/env sh
# ############################################
# This is the unix/linux version of the windows script for running the load tests
# via the docker container
# ############################################
# Initialize variables
export URL="subdomain.organization.com"
DOCKER_IMAGE="gatling-load-test"
DOCKER_CONTAINER="gatling_load_test"
test=""
user=""
pswd=""
count=""
ramp=""
duration=""
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
-test)
test="$2"
shift 2
;;
-user)
user="$2"
shift 2
;;
-pswd)
pswd="$2"
shift 2
;;
-count)
count="$2"
shift 2
;;
-ramp_in_minutes)
ramp="$2"
shift 2
;;
-duration_in_minutes)
duration="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
# Check mandatory arguments
if [ -z "$test" ] || [ -z "$user" ] || [ -z "$pswd" ] || [ -z "$count" ] || [ -z "$ramp" ] || [ -z "$duration" ]; then
echo "Usage: $0 -test \"testname\" -user \"userid\" -pswd \"password\" -count n -ramp_in_minutes n -duration_in_minutes n"
exit 1
fi
docker rm ${DOCKER_CONTAINER}
docker build -t ${DOCKER_IMAGE}:1.0 .
docker run -e TEST="${test}" -e TEST_USER="${user}" -e TEST_PWD="${pswd}" -e BASE_URL="${URL}" -e USER_COUNT="$count" -e RAMP_DURATION="$ramp" -e TEST_DURATION="$duration" --name ${DOCKER_CONTAINER} -p 8000:8000 ${DOCKER_IMAGE}:1.0
cid=$(docker ps --no-trunc -aqf name=${DOCKER_CONTAINER})
docker cp "${cid}":/build/test_report.zip ./out/test_report_"${test}"_"${cid}".zip