diff --git a/locust-scenarios/locustfile.py b/locust-scenarios/locustfile.py index c09974314566038e246aee9fd10a868d7f3d3b44..59010aa27eeb9b44d6b72ffdaaf3719b25cf55e7 100644 --- a/locust-scenarios/locustfile.py +++ b/locust-scenarios/locustfile.py @@ -51,23 +51,53 @@ class Admin(HttpUser): }) @task - def create_airplane_type(self): - self.client.post(":8080/api/airplaneTypes", json= + def create_airplane(self): + response = self.client.get(":8080/api/airplaneTypes/1") + + if response.status_code == 200: + self.client.post(":8080/api/airplanes", json= + { + "name": "Prášek", + "capacity": 2, + "airplaneTypeId": 1 + }) + + @task + def create_steward(self): + self.client.post(":8080/api/stewards", json= { - "name": "Práškovač 3000" + "firstName": "John", + "lastName": "Doe" }) - return - @task - def create_airplane(self): - self.client.get(":8080/api/airplaneTypes") - self.client.post(":8080/api/airplanes", json= + @task + def create_flight(self): + self.client.post(":8080/api/flights", json= { - "name": "Prášek", - "capacity": 2, - "airplaneTypeId": 1 + "departureTime": "2022-12-22T12:04:04.493908908+01:00", + "arrivalTime": "2022-12-22T12:04:04.493908908+01:00" }) - self.client.get(":8080/api/airplanes") + + @task + def assign_steward_flight(self): + response_steward = self.client.get(":8080/api/stewards/1") + response_flight = self.client.get(":8080/api/flights/1") + + if response_steward.status_code == 200 and response_flight.status_code == 200: + self.client.post(":8080/api/stewards/1/flights/1") + self.client.delete(":8080/api/stewards/1/flights/1") + + @task + def assign_airport_flight(self): + response_airport1 = self.client.get(":8080/api/airports/1") + response_airport2 = self.client.get(":8080/api/airports/2") + response_flight = self.client.get(":8080/api/flights/1") + + if response_airport1.status_code == 200 and response_flight.status_code == 200 and response_airport2.status_code == 200: + self.client.post(":8080/api/airports/1/departingFlights/1") + self.client.post(":8080/api/airports/2/arrivingFlights/1") + self.client.delete(":8080/api/airports/1/departingFlights/1") + self.client.delete(":8080/api/airports/2/arrivingFlights/1") class BasicUser(HttpUser):