From 0cc8dc06dd559af3daad64b18ef2a803a26b81a3 Mon Sep 17 00:00:00 2001
From: Andrej Zabka <andrej.zabka@mavenir.com>
Date: Sun, 7 May 2023 18:29:58 +0200
Subject: [PATCH] Updated locust scenario to accept/reject random applications
 and added note to readme

---
 README.md                   |  4 ++++
 scenario-locust/scenario.py | 27 ++++++++-------------------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/README.md b/README.md
index f7d0ec2..d249e0e 100644
--- a/README.md
+++ b/README.md
@@ -216,6 +216,10 @@ Also feel free to monitor the system through grafana during all the following st
 If you followed step 1, you (as a manager) should also get an e-mail notification about 
 new component being created. 
 
+*Note: It is possible to time-out our team's e-mail address if you make too many new notifications (for example during the second scenario - load test). 
+So if the Notifications module is not working, try to wait a few minutes, maybe another reviewer
+was doing a load test at the same time. In real system we would not use a regular Gmail address for such job - there would be no timeouts.*
+
 #### 4. Log in as an manager and create a visualization of a car
 - Log in using a manager scope (test_5), same way as before.
 - Now, you can perform all operations, except POST at /carComponent (only engineers can do that).
diff --git a/scenario-locust/scenario.py b/scenario-locust/scenario.py
index a3edd01..abbeff2 100644
--- a/scenario-locust/scenario.py
+++ b/scenario-locust/scenario.py
@@ -1,30 +1,19 @@
 from locust import HttpUser, task
 import random
 
-
 class Admin(HttpUser):
-    id = 0
+    fixed_count = 1
 
-    def on_start(self):
+    @task
+    def update_random_application_status(self):
         response = self.client.get("/application")
 
         if len(response.json()) == 0:
-            self.client.post("/application", json={
-                "name": "Jozko",
-                "surname": "Example",
-                "birthday": "2023-05-06",
-                "email": "jozko.example@example.com"
-            })
-
-            response = self.client.get("/application")
+            return
 
-        self.id = response.json()[0]['id']
-
-    @task
-    def update_application_status(self):
-        self.client.get("/application")
+        applicationNumber = random.choice([i for i in range(1, len(response.json()))])
         status = random.choice(["accepted", "rejected"])
-        self.client.put(f"/application/status?id={self.id}&applicationStatus={status}")
+        self.client.put(f"/application/status?id={applicationNumber}&applicationStatus={status}")
 
     @task
     def get_application(self):
@@ -41,6 +30,6 @@ class User(HttpUser):
         self.client.post("/application", json={
             "name": "Jozko",
             "surname": "Example",
-            "birthday": "2023-05-06",
-            "email": "jozko.example@example.com"
+            "birthday": "2000-05-06",
+            "email": "john@example.com"
         })
-- 
GitLab