From d1ef106ea35f07cc0762323c110dbd3420adc290 Mon Sep 17 00:00:00 2001 From: tomdds Date: Thu, 14 Nov 2019 11:53:32 -0500 Subject: [PATCH] Dockerize locust and tweak script for configurability --- load-test/Dockerfile | 7 +++++++ {tests => load-test}/locustfile.py | 15 ++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 load-test/Dockerfile rename {tests => load-test}/locustfile.py (90%) diff --git a/load-test/Dockerfile b/load-test/Dockerfile new file mode 100644 index 00000000..344dd107 --- /dev/null +++ b/load-test/Dockerfile @@ -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 + diff --git a/tests/locustfile.py b/load-test/locustfile.py similarity index 90% rename from tests/locustfile.py rename to load-test/locustfile.py index b50114a4..1a4d73ca 100644 --- a/tests/locustfile.py +++ b/load-test/locustfile.py @@ -6,14 +6,19 @@ from locust import HttpLocust, TaskSequence, seq_task from pyquery import PyQuery as pq -username = os.getenv("ATAT_BA_USERNAME", "") -password = os.getenv("ATAT_BA_PASSWORD", "") +# Provide username/password for basic auth +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" def login(l): - l.client.get("/login-dev", auth=(username, password)) + l.client.get("/login-dev", auth=(USERNAME, PASSWORD)) def logout(l): @@ -123,7 +128,7 @@ def create_portfolio(l): class UserBehavior(TaskSequence): def on_start(self): - self.client.verify = False + self.client.verify = not DISABLE_VERIFY login(self) @seq_task(1) @@ -154,5 +159,5 @@ class WebsiteUser(HttpLocust): if __name__ == "__main__": # if run as the main file, will spin up a single locust - # and run through the sequence as it WebsiteUser().run() +