load gen started

This commit is contained in:
Steve Waterworth
2018-02-06 15:51:43 -05:00
parent 75e4405f9f
commit ca34278047
6 changed files with 69 additions and 0 deletions

13
load-gen/Dockerfile Normal file
View File

@@ -0,0 +1,13 @@
FROM python:3
WORKDIR /load
COPY requirements.txt /load/
RUN pip install -r requirements.txt
COPY run.sh /load/
COPY robot-shop.py /load/
CMD ["./run.sh"]

15
load-gen/build.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
# get the tag info
eval $(egrep '[A-Z]+=' ../.env)
echo "Repo $REPO"
echo "Tag $TAG"
docker build -t ${REPO}/rs-load:${TAG} . && docker tag ${REPO}/rs-load:${TAG} ${REPO}/rs-load
if [ "$1" = "push" ]
then
echo "pushing..."
docker push ${REPO}/rs-load:${TAG} ${REPO}/rs-load
fi

10
load-gen/load-gen.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
docker run \
-it \
--rm \
--network robotshop_robot-shop \
-e 'HOST=http://web:8080' \
steveww/rs-load

View File

@@ -0,0 +1 @@
locustio

20
load-gen/robot-shop.py Normal file
View File

@@ -0,0 +1,20 @@
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
print('Starting')
@task
def index(self):
self.client.get("/")
@task
def user(self):
res = self.client.get("/api/user/uniqueid")
print('User {}'.format(res.content))
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 1000
max_wait = 5000

10
load-gen/run.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/sh
if [ -z "$HOST" ]
then
echo "HOST env not set"
exit 1
fi
locust -f robot-shop.py --host "$HOST" --no-web -c 1 -r 1