loadgenerator: complete implementation

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-06-29 17:10:28 -07:00
parent 08aa1cce26
commit 257cbdf98b
4 changed files with 26 additions and 5 deletions

View file

@ -3,21 +3,32 @@ kind: Deployment
metadata:
name: loadgenerator
spec:
replicas: 1
template:
metadata:
labels:
app: loadgenerator
spec:
restartPolicy: Always
initContainers:
- name: wait-frontend
image: alpine:3.6
command: ['sh', '-c', 'until wget -qO- "http://${FRONTEND_ADDR}"; do echo "waiting for ${FRONTEND_ADDR}"; sleep 2; done;']
command: ['sh', '-c', 'set -x; apk add --no-cache curl;
until curl -f "http://${FRONTEND_ADDR}"; do
echo "waiting for http://${FRONTEND_ADDR}";
sleep 2;
done;']
env:
- name: FRONTEND_ADDR
value: "frontend:80"
containers:
- name: server
- name: main
image: loadgenerator
env:
- name: FRONTEND_ADDR
value: "frontend:8080"
value: "frontend:80"
- name: USERS
value: "1"
resources:
requests:
cpu: 100m

View file

@ -4,4 +4,4 @@ COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
ENTRYPOINT locust --host="http://${FRONTEND_ADDR}" --no-web -c=10
ENTRYPOINT ./loadgen.sh

10
src/loadgenerator/loadgen.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
set -e
if [[ -z "${FRONTEND_ADDR}" ]]; then
echo >&2 "FRONTEND_ADDR not specified"
exit 1
fi
set -x
locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}"

View file

@ -63,4 +63,4 @@ class UserBehavior(TaskSet):
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 1000
max_wait = 2000
max_wait = 10000