diff --git a/simulation-tests/README.md b/simulation-tests/README.md new file mode 100644 index 00000000..59052dd2 --- /dev/null +++ b/simulation-tests/README.md @@ -0,0 +1,18 @@ +# locust + +A simple open source load testing tool that allows to define user behavior. + +In order to set it up for the first time, we followed the documentation at https://locust.io/. In particular, we: + +* Defined a class for the users that will be simulating. +* Defined a ``wait_time`` variable that will make the simulated users wait between the specified seconds after each task executed. +* Decorated our method with ``@Task`` that creates a micro-thread that calls this method. +* Defined the ``self.client`` attribute that makes it possible to make HTTP calls that will be logged by Locust. + +To use, open the terminal on this folder and run the following command: + +``locust -f locust.py --host https://cara.web.cern.ch`` + +Then, open up a browser and point it to http://localhost:8089. +By default we pointed out the test to our own web server. +``Start swarming`` will trigger the simulation. \ No newline at end of file diff --git a/simulation-tests/locust.py b/simulation-tests/locust.py new file mode 100644 index 00000000..c697a39b --- /dev/null +++ b/simulation-tests/locust.py @@ -0,0 +1,10 @@ +import time +from locust import HttpUser, task, between + +class WebsiteUser(HttpUser): + '''Time (in seconds) between the execution of each task.''' + wait_time = between(10, 20) + + @task + def baseline_model(self): + self.client.get(url="/calculator-open/baseline-model/result") \ No newline at end of file