diff --git a/locust-scenarios/locustfile.py b/locust-scenarios/locustfile.py index 79a661fcdaca5fea3e3c08344da31c1285b57000..1311589510216bfa4c19ca2226228517e6bb53e2 100644 --- a/locust-scenarios/locustfile.py +++ b/locust-scenarios/locustfile.py @@ -2,102 +2,24 @@ from locust import HttpUser, task 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 - } - }) - - @task - 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= + def create_airplane_type(self): + self.client.post(":8080/api/airplaneTypes", json= { - "firstName": "John", - "lastName": "Doe" + "name": "PráškovaÄŤ 3000" }) - + return @task - def create_flight(self): - self.client.post(":8080/api/flights", json= + def create_airplane(self): + self.client.get(":8080/api/airplaneTypes") + + self.client.post(":8080/api/airplanes", json= { - "departureTime": "2022-12-22T12:04:04.493908908+01:00", - "arrivalTime": "2022-12-22T12:04:04.493908908+01:00" + "name": "Prášek", + "capacity": 2, + "airplaneTypeId": 1 }) - - @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") + self.client.get(":8080/api/airplanes") class BasicUser(HttpUser): @@ -116,9 +38,3 @@ class BasicUser(HttpUser): @task def generate_airplane_report(self): self.client.get(":8085/api/reports/airplane/1") - @task - def generate_airport_report(self): - self.client.get(":8085/api/reports/airport/1") - @task - def generate_flight_report(self): - self.client.get(":8085/api/reports/flight/1")