naming convention and variable load

This commit is contained in:
Steve Waterworth
2018-04-24 17:35:44 +01:00
parent e56116bfb0
commit 7eafcadcad
4 changed files with 33 additions and 19 deletions

View File

@@ -6,8 +6,8 @@ COPY requirements.txt /load/
RUN pip install -r requirements.txt
COPY run.sh /load/
COPY entrypoint.sh /load/
COPY robot-shop.py /load/
CMD ["./run.sh"]
CMD ["./entrypoint.sh"]

27
load-gen/entrypoint.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/sh
if [ -z "$HOST" ]
then
echo "HOST env not set"
exit 1
fi
TEST=$(echo "$HOST" | egrep '^http://[a-z0-9]+')
if [ -z "$TEST" ]
then
echo "Host must start with http://"
exit 1
fi
if echo "$NUM_CLIENTS" | egrep -q '^[0-9]+$'
then
CLIENTS=${NUM_CLIENTS:-1}
else
echo "$NUM_CLIENTS is not a number falling back to 1"
CLIENTS=1
fi
echo "Starting load with $CLIENTS clients"
locust -f robot-shop.py --host "$HOST" --no-web -c $CLIENTS -r 1

View File

@@ -1,5 +1,8 @@
#!/bin/sh
# Changing the NUM_CLIENTS environment variable varies the load on the application
# The bigger the number the more requests, the bigger the load
# get the tag info
eval $(egrep '[A-Z]+=' ../.env)
@@ -11,5 +14,6 @@ docker run \
--rm \
--network=host \
-e 'HOST=http://localhost:8080' \
-e 'NUM_CLIENTS=1' \
${REPO}/rs-load:${TAG}

View File

@@ -1,17 +0,0 @@
#!/bin/sh
if [ -z "$HOST" ]
then
echo "HOST env not set"
exit 1
fi
TEST=$(echo "$HOST" | egrep '^http://[a-z0-9]+')
if [ -z "$TEST" ]
then
echo "Host must start with http://"
exit 1
fi
locust -f robot-shop.py --host "$HOST" --no-web -c 1 -r 1