diff --git a/monitoring/monitorlib/clients/flight_planning/client_v1.py b/monitoring/monitorlib/clients/flight_planning/client_v1.py index 166f03c64c..ecf70dc48a 100644 --- a/monitoring/monitorlib/clients/flight_planning/client_v1.py +++ b/monitoring/monitorlib/clients/flight_planning/client_v1.py @@ -146,8 +146,8 @@ def try_end_flight( participant_id=self.participant_id, query_type=QueryType.InterUSSFlightPlanningV1DeleteFlightPlan, ) - # 404 is acceptable, as the end state we are interested in is already effective. - if query.status_code not in [200, 404]: + + if query.status_code != 200: raise PlanningActivityError( f"Attempt to delete flight plan returned status {query.status_code} rather than 200 as expected", query, @@ -157,9 +157,12 @@ def try_end_flight( query.response.json, api.DeleteFlightPlanResponse ) except ValueError as e: + raise PlanningActivityError( - f"Response to delete flight plan could not be parsed: {str(e)}", query + f"Response to delete flight plan could not be parsed: {str(e)}", + query, ) + self.created_flight_ids.discard(flight_id) response = PlanningActivityResponse( flight_id=flight_id, diff --git a/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py b/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py index 823a557a8b..de31f8bbb0 100644 --- a/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py +++ b/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py @@ -412,35 +412,30 @@ def cleanup_flights( resp, query = cleanup_flight(flight_planner, flight_id) scenario.record_query(query) except QueryError as e: + for q in e.queries: scenario.record_query(q) - check.record_failed( - summary=f"Failed to clean up flight {flight_id} from {flight_planner.participant_id}", - details=f"{str(e)}\n\nStack trace:\n{e.stacktrace}", - query_timestamps=[q.request.timestamp for q in e.queries], - ) - continue - - # A non-existing flight is considered successfully deleted - if query.status_code in [200, 404]: if ( - resp.flight_plan_status != FlightPlanStatus.Closed - or query.status_code == 404 - ): + e.queries and e.queries[0].status_code == 404 + ): # We allow 404 during cleanup scenario.record_note( f"Deletion of {flight_id}", - f"Deletion of flight {flight_id} returned a status of '{resp.flight_plan_status}' ({FlightPlanStatus.Closed} wanted), with a {query.status_code} status code (200 wanted)", + f"Deletion of flight {flight_id} returned a status code of 404 (instead of a 200)", ) - removed.append(flight_id) - else: - check.record_failed( - summary="Failed to delete flight", - details=( - f"USS indicated {resp.activity_result} with flight plan status {resp.flight_plan_status} rather than the expected Completed with flight plan status Closed. Its notes were: {resp.notes}" - if "notes" in resp - else "See query" - ), - query_timestamps=[query.request.timestamp], + else: + check.record_failed( + summary=f"Failed to clean up flight {flight_id} from {flight_planner.participant_id}", + details=f"{str(e)}\n\nStack trace:\n{e.stacktrace}", + query_timestamps=[q.request.timestamp for q in e.queries], + ) + continue + + if resp.flight_plan_status != FlightPlanStatus.Closed: + scenario.record_note( + f"Deletion of {flight_id}", + f"Deletion of flight {flight_id} returned a status of '{resp.flight_plan_status}' ({FlightPlanStatus.Closed} wanted)", ) + + removed.append(flight_id)