Dockerize locust and tweak script for configurability

This commit is contained in:
tomdds 2019-11-14 11:53:32 -05:00
parent 217a3bce09
commit d1ef106ea3
2 changed files with 17 additions and 5 deletions

7
load-test/Dockerfile Normal file
View File

@ -0,0 +1,7 @@
FROM locustio/locust
USER root
RUN apk update && apk --no-cache add g++ gcc libxslt-dev
RUN pip install pyquery
USER locust
ADD locustfile.py locustfile.py

View File

@ -6,14 +6,19 @@ from locust import HttpLocust, TaskSequence, seq_task
from pyquery import PyQuery as pq from pyquery import PyQuery as pq
username = os.getenv("ATAT_BA_USERNAME", "") # Provide username/password for basic auth
password = os.getenv("ATAT_BA_PASSWORD", "") USERNAME = os.getenv("ATAT_BA_USERNAME", "")
PASSWORD = os.getenv("ATAT_BA_PASSWORD", "")
# Ability to disable SSL verification for bad cert situations
DISABLE_VERIFY = os.getenv("DISABLE_VERIFY", "true").lower() == "true"
# Alpha numerics for random entity names
LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" LETTERS = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
def login(l): def login(l):
l.client.get("/login-dev", auth=(username, password)) l.client.get("/login-dev", auth=(USERNAME, PASSWORD))
def logout(l): def logout(l):
@ -123,7 +128,7 @@ def create_portfolio(l):
class UserBehavior(TaskSequence): class UserBehavior(TaskSequence):
def on_start(self): def on_start(self):
self.client.verify = False self.client.verify = not DISABLE_VERIFY
login(self) login(self)
@seq_task(1) @seq_task(1)
@ -154,5 +159,5 @@ class WebsiteUser(HttpLocust):
if __name__ == "__main__": if __name__ == "__main__":
# if run as the main file, will spin up a single locust # if run as the main file, will spin up a single locust
# and run through the sequence as it
WebsiteUser().run() WebsiteUser().run()