From fb4140d69c1c0b4f285b17c6748d62ac0b279f73 Mon Sep 17 00:00:00 2001 From: Drasko DRASKOVIC Date: Wed, 18 May 2016 20:41:21 +0200 Subject: [PATCH] Add Locust test template Signed-off-by: Drasko DRASKOVIC --- test/locust/README.md | 16 ++++++++++++++++ test/locust/checkStatus.py | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/locust/README.md create mode 100644 test/locust/checkStatus.py diff --git a/test/locust/README.md b/test/locust/README.md new file mode 100644 index 00000000..d179bdda --- /dev/null +++ b/test/locust/README.md @@ -0,0 +1,16 @@ +## Locust Performance Testing +Locust website: http://locust.io/ + +Locust is an easy-to-use, distributed, user load testing tool. +Intended for load testing web sites (or other systems) and figuring out how many +concurrent users a system can handle. + +## Usage +```bash +locust -f locustfile.py --host=http://localhost:1026 +``` + +Open the browser at localhost:8089 and start the swarm. + +## Documentation +http://docs.locust.io/en/latest/index.html diff --git a/test/locust/checkStatus.py b/test/locust/checkStatus.py new file mode 100644 index 00000000..656edab9 --- /dev/null +++ b/test/locust/checkStatus.py @@ -0,0 +1,19 @@ +from locust import HttpLocust, TaskSet, task, ResponseError + +class CheckStatus(TaskSet): + def on_start(self): + """ on_start is called when a Locust start before any task is scheduled """ + print("Locus test started") + + @task(1) + def getVersion(self): + headers = {'Content-Type': 'application/json', 'Accept': 'application/json'} + response = self.client.get("/version", headers=headers) + + print "Response status code:", response.status_code + print "Response content:", response.content + +class HelloLocust(HttpLocust): + task_set = CheckStatus + min_wait=5000 + max_wait=9000