Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions monitoring/monitorlib/clients/flight_planning/client_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
41 changes: 18 additions & 23 deletions monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NB: I removed the if for the status code: it's not possible to get there without a status_code == 200

removed.append(flight_id)
Loading