Should now actually work
This commit is contained in:
parent
0b4f577240
commit
3a12c74af3
7 changed files with 37 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,3 +9,4 @@ pkg/
|
||||||
.idea
|
.idea
|
||||||
.skaffold-*.yaml
|
.skaffold-*.yaml
|
||||||
.kubernetes-manifests-*/
|
.kubernetes-manifests-*/
|
||||||
|
env/
|
||||||
|
|
|
@ -14,4 +14,5 @@ FROM base
|
||||||
COPY --from=builder /install /usr/local
|
COPY --from=builder /install /usr/local
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
ENTRYPOINT ./loadgen.sh
|
ENTRYPOINT ["./loadgen.sh"]
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,15 @@
|
||||||
set -e
|
set -e
|
||||||
trap "exit" TERM
|
trap "exit" TERM
|
||||||
|
|
||||||
if [[ -z "${FRONTEND_ADDR}" ]]; then
|
if [ -z "${FRONTEND_ADDR}" ]; then
|
||||||
echo >&2 "FRONTEND_ADDR not specified"
|
echo >&2 "FRONTEND_ADDR not specified"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
locust --host="http://${FRONTEND_ADDR}" --no-web -c "${USERS:-10}"
|
locust \
|
||||||
|
-f locustfile.py \
|
||||||
|
--host="http://${FRONTEND_ADDR}" \
|
||||||
|
--no-web \
|
||||||
|
-c "${USERS:-10}" \
|
||||||
|
-r 1
|
||||||
|
|
|
@ -30,20 +30,25 @@ products = [
|
||||||
'LS4PSXUNUM',
|
'LS4PSXUNUM',
|
||||||
'OLJCESPC7Z']
|
'OLJCESPC7Z']
|
||||||
|
|
||||||
|
|
||||||
def index(l):
|
def index(l):
|
||||||
l.client.get("/")
|
l.client.get("/")
|
||||||
|
|
||||||
|
|
||||||
def setCurrency(l):
|
def setCurrency(l):
|
||||||
currencies = ['EUR', 'USD', 'JPY', 'CAD']
|
currencies = ['EUR', 'USD', 'JPY', 'CAD']
|
||||||
l.client.post("/setCurrency",
|
l.client.post("/setCurrency",
|
||||||
{'currency_code': random.choice(currencies)})
|
{'currency_code': random.choice(currencies)})
|
||||||
|
|
||||||
|
|
||||||
def browseProduct(l):
|
def browseProduct(l):
|
||||||
l.client.get("/product/" + random.choice(products))
|
l.client.get("/product/" + random.choice(products))
|
||||||
|
|
||||||
|
|
||||||
def viewCart(l):
|
def viewCart(l):
|
||||||
l.client.get("/cart")
|
l.client.get("/cart")
|
||||||
|
|
||||||
|
|
||||||
def addToCart(l):
|
def addToCart(l):
|
||||||
product = random.choice(products)
|
product = random.choice(products)
|
||||||
l.client.get("/product/" + product)
|
l.client.get("/product/" + product)
|
||||||
|
@ -51,6 +56,7 @@ def addToCart(l):
|
||||||
'product_id': product,
|
'product_id': product,
|
||||||
'quantity': random.choice([1, 2, 3, 4, 5, 10])})
|
'quantity': random.choice([1, 2, 3, 4, 5, 10])})
|
||||||
|
|
||||||
|
|
||||||
def checkout(l):
|
def checkout(l):
|
||||||
addToCart(l)
|
addToCart(l)
|
||||||
l.client.post("/cart/checkout", {
|
l.client.post("/cart/checkout", {
|
||||||
|
@ -66,9 +72,17 @@ def checkout(l):
|
||||||
'credit_card_cvv': '672',
|
'credit_card_cvv': '672',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
class UserBehavior(TaskSet):
|
class UserBehavior(TaskSet):
|
||||||
min_wait = 1000
|
min_wait = 500
|
||||||
max_wait = 20000
|
max_wait = 1500
|
||||||
|
|
||||||
|
tasks = {index: 1,
|
||||||
|
setCurrency: 2,
|
||||||
|
browseProduct: 10,
|
||||||
|
addToCart: 2,
|
||||||
|
viewCart: 3,
|
||||||
|
checkout: 1}
|
||||||
|
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
index(self)
|
index(self)
|
||||||
|
@ -83,14 +97,9 @@ class UserBehavior(TaskSet):
|
||||||
traffic_scaler = (traffic_scaler + 1) / 2.0
|
traffic_scaler = (traffic_scaler + 1) / 2.0
|
||||||
|
|
||||||
# Scale traffic between minimum and maximum wait times.
|
# Scale traffic between minimum and maximum wait times.
|
||||||
return self.max_wait + (self.min_wait - self.max_wait) * traffic_scaler
|
wait = self.max_wait + (self.min_wait - self.max_wait) * traffic_scaler
|
||||||
|
return round(wait)
|
||||||
|
|
||||||
tasks = {index: 1,
|
|
||||||
setCurrency: 2,
|
|
||||||
browseProduct: 10,
|
|
||||||
addToCart: 2,
|
|
||||||
viewCart: 3,
|
|
||||||
checkout: 1}
|
|
||||||
|
|
||||||
class WebsiteUser(HttpLocust):
|
class WebsiteUser(HttpLocust):
|
||||||
task_set = UserBehavior
|
task_set = UserBehavior
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
locustio==0.8.1
|
locustio==0.9.0
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# This file is autogenerated by pip-compile
|
# This file is autogenerated by pip-compile
|
||||||
# To update, run:
|
# To update, run:
|
||||||
#
|
#
|
||||||
# pip-compile --output-file requirements.txt requirements.in
|
# pip-compile --output-file=requirements.txt requirements.in
|
||||||
#
|
#
|
||||||
certifi==2018.11.29 # via requests
|
certifi==2018.11.29 # via requests
|
||||||
chardet==3.0.4 # via requests
|
chardet==3.0.4 # via requests
|
||||||
|
@ -13,9 +13,9 @@ greenlet==0.4.15 # via gevent
|
||||||
idna==2.8 # via requests
|
idna==2.8 # via requests
|
||||||
itsdangerous==1.1.0 # via flask
|
itsdangerous==1.1.0 # via flask
|
||||||
jinja2==2.10 # via flask
|
jinja2==2.10 # via flask
|
||||||
locustio==0.8.1
|
locustio==0.9.0
|
||||||
markupsafe==1.1.0 # via jinja2
|
markupsafe==1.1.0 # via jinja2
|
||||||
msgpack-python==0.5.6 # via locustio
|
msgpack==0.6.1 # via locustio
|
||||||
pyzmq==17.0.0 # via locustio
|
pyzmq==17.0.0 # via locustio
|
||||||
requests==2.21.0 # via locustio
|
requests==2.21.0 # via locustio
|
||||||
six==1.12.0 # via locustio
|
six==1.12.0 # via locustio
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue