load gen started
This commit is contained in:
13
load-gen/Dockerfile
Normal file
13
load-gen/Dockerfile
Normal 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
15
load-gen/build.sh
Executable 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
10
load-gen/load-gen.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
docker run \
|
||||
-it \
|
||||
--rm \
|
||||
--network robotshop_robot-shop \
|
||||
-e 'HOST=http://web:8080' \
|
||||
steveww/rs-load
|
||||
|
1
load-gen/requirements.txt
Normal file
1
load-gen/requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
locustio
|
20
load-gen/robot-shop.py
Normal file
20
load-gen/robot-shop.py
Normal 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
10
load-gen/run.sh
Executable 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
|
||||
|
Reference in New Issue
Block a user