From 6175b72e02178ea988fe2e9fd5dd8bf29d54abb8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A1n=20Mach=C3=A1=C4=8Dek?= <xmachac5@fi.muni.cz>
Date: Sun, 7 May 2023 23:23:18 +0200
Subject: [PATCH] fix - locust according to core changes

---
 locust-scenarios/locustfile.py | 100 +++++++++++++++++----------------
 1 file changed, 51 insertions(+), 49 deletions(-)

diff --git a/locust-scenarios/locustfile.py b/locust-scenarios/locustfile.py
index 79a661f..c647def 100644
--- a/locust-scenarios/locustfile.py
+++ b/locust-scenarios/locustfile.py
@@ -5,53 +5,11 @@ class Admin(HttpUser):
 
     def on_start(self):
     #create airplane type - just once because creating airplane type more times would report fail due to not unique name
-    self.client.post(":8080/api/airplaneTypes", json=
-    {
-        "name": "Práškovač 2000"
-    })
-
-    self.client.post(":8080/api/countries", json=
-    {
-        "name": "Slovensko"
-    })
-    self.client.post(":8080/api/cities", json=
-    {
-        "name": "HolĂ­ÄŤ"
-    })
-    self.client.post(":8080/api/cities", json=
-    {
-        "name": "Senica"
-    })
-    self.client.post(":8080/api/cities/1/countries/1", json=
-    {
-        "name": "Senica"
-    })
-    self.client.post(":8080/api/cities/2/countries/1", json=
-    {
-        "name": "Senica"
-    })
-    #create 2 airports - just once because airport need to have unique code
-    self.client.post(":8080/api/airports", json=
-    {
-        "name": "Trávník Holíč",
-        "code": "TH",
-        "location": {
-            "latitude": 48.48440,
-            "longitude": 17.9380
-        }
-    })
-    self.client.post(":8080/api/airports", json=
-    {
-        "name": "Hlinište Senica",
-        "code": "HS",
-        "location": {
-            "latitude": 48.40500,
-            "longitude": 17.22000
-        }
-    })
+        self.client.post(":8080/api/airplaneTypes", json=
+        {
+            "name": "Práškovač 2000"
+        })
 
-    @task
-    def create_airplane(self):
         response  = self.client.get(":8080/api/airplaneTypes/1")
 
         if response.status_code == 200:
@@ -59,9 +17,49 @@ class Admin(HttpUser):
             {
                 "name": "Prášek",
                 "capacity": 2,
-                "airplaneTypeId": 1
+                "typeId": 1
             })
 
+        self.client.post(":8080/api/countries", json=
+        {
+            "name": "Slovensko"
+        })
+        self.client.post(":8080/api/cities", json=
+        {
+            "name": "HolĂ­ÄŤ"
+        })
+        self.client.post(":8080/api/cities", json=
+        {
+            "name": "Senica"
+        })
+        self.client.post(":8080/api/cities/1/countries/1", json=
+        {
+            "name": "Senica"
+        })
+        self.client.post(":8080/api/cities/2/countries/1", json=
+        {
+            "name": "Senica"
+        })
+        #create 2 airports - just once because airport need to have unique code
+        self.client.post(":8080/api/airports", json=
+        {
+            "name": "Travnik Holic",
+            "code": "THL",
+            "location": {
+                "latitude": 41.40338,
+                "longitude": 2.17403
+            }
+        })
+        self.client.post(":8080/api/airports", json=
+        {
+            "name": "Hliniste Senica",
+            "code": "HSL",
+            "location": {
+                "latitude": 41.40338,
+                "longitude": 2.17403
+            }
+        })
+
     @task
     def create_steward(self):
         self.client.post(":8080/api/stewards", json=
@@ -74,8 +72,9 @@ class Admin(HttpUser):
     def create_flight(self):
         self.client.post(":8080/api/flights", json=
         {
-            "departureTime": "2022-12-22T12:04:04.493908908+01:00",
-            "arrivalTime": "2022-12-22T12:04:04.493908908+01:00"
+            "departureTime": "2023-12-22T12:04:04.493908908+01:00",
+            "arrivalTime": "2023-12-22T12:04:04.493908908+01:00",
+            "airplaneId": 1
         })
 
     @task
@@ -101,6 +100,9 @@ class Admin(HttpUser):
 
 
 class BasicUser(HttpUser):
+    min_wait = 5000
+    max_wait = 15000
+
     @task
     def get_airplane(self):
         self.client.get(":8080/api/airplanes")
-- 
GitLab