From 4a45e9c2631dfa3fe6fa4063ffe970d26b814f7e Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Mon, 13 Dec 2021 10:39:27 +0000 Subject: [PATCH] Renamed files and added docstrings on each method. --- .../README.md | 2 +- server-performance-tests/locust.py | 42 +++++++++++++++++++ simulation-tests/locust.py | 10 ----- 3 files changed, 43 insertions(+), 11 deletions(-) rename {simulation-tests => server-performance-tests}/README.md (86%) create mode 100644 server-performance-tests/locust.py delete mode 100644 simulation-tests/locust.py diff --git a/simulation-tests/README.md b/server-performance-tests/README.md similarity index 86% rename from simulation-tests/README.md rename to server-performance-tests/README.md index 59052dd2..7bf5e43b 100644 --- a/simulation-tests/README.md +++ b/server-performance-tests/README.md @@ -9,7 +9,7 @@ In order to set it up for the first time, we followed the documentation at https * 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: +To use, uncomment the desired method on ``lucust.py``` file, open the terminal on this folder and run the following command: ``locust -f locust.py --host https://cara.web.cern.ch`` diff --git a/server-performance-tests/locust.py b/server-performance-tests/locust.py new file mode 100644 index 00000000..1cee4ae0 --- /dev/null +++ b/server-performance-tests/locust.py @@ -0,0 +1,42 @@ +from locust import HttpUser, task, between +from gevent.pool import Group +import time + +''' +Method no. 1 - Simulation with each single user +running x requests in parallel. +Specify the desired number of parallel requests in +"num_of_parallel_requests" variable (35 by default). + +This method was used in simulations with one single +user perfoming 35 requests in parallel. +''' +# num_of_parallel_requests = 35 +# class User(HttpUser): +# wait_time = between(0.05, 0.1) + +# @task(1) +# def test_api(self): +# group = Group() +# for i in range(0, num_of_parallel_requests): +# group.spawn(lambda:self.client.get("/calculator-open/baseline-model/result")) +# group.join() +# while(1): +# time.sleep(1) + +''' +Method no. 2 - Simulation with different users +running x requests concurrently. +With this method, each user is intended to +perform one single request. + +This method was used in simulations with different +number of users requesting once at the same time. +''' +# class User(HttpUser): + +# @task(1) +# def test_api(self): +# self.client.get("/calculator-open/baseline-model/result") +# while(1): +# time.sleep(1) \ No newline at end of file diff --git a/simulation-tests/locust.py b/simulation-tests/locust.py deleted file mode 100644 index c697a39b..00000000 --- a/simulation-tests/locust.py +++ /dev/null @@ -1,10 +0,0 @@ -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