From 6f1a2e1cb5ab9517f4b33c0433e0a94cbf70de19 Mon Sep 17 00:00:00 2001 From: Julien Perrochet Date: Wed, 13 Dec 2023 17:46:20 +0100 Subject: [PATCH] [uss_qualifier] check notifications to operator on conflict --- .../clients/flight_planning/client_v1.py | 23 ++++++++++-------- .../flight_planning/flight_planner.py | 5 ++-- .../flight_intent_validation.py | 4 ++-- .../conflict_equal_priority_not_permitted.py | 10 ++++---- .../conflict_higher_priority.py | 8 +++---- .../utm/notifications_to_operator/__init__.py | 0 .../astm/utm/off_nominal_planning/down_uss.py | 2 +- .../prioritization_test_steps.py | 24 +++++++++---------- .../scenarios/flight_planning/test_steps.py | 24 ++++++++++--------- .../uspace/flight_auth/validation.py | 4 ++-- 10 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 monitoring/uss_qualifier/scenarios/astm/utm/notifications_to_operator/__init__.py diff --git a/monitoring/monitorlib/clients/flight_planning/client_v1.py b/monitoring/monitorlib/clients/flight_planning/client_v1.py index e7c99c9c65..2eb3451e5c 100644 --- a/monitoring/monitorlib/clients/flight_planning/client_v1.py +++ b/monitoring/monitorlib/clients/flight_planning/client_v1.py @@ -1,12 +1,14 @@ import uuid from typing import Optional + from implicitdict import ImplicitDict +from uas_standards.interuss.automated_testing.flight_planning.v1 import api +from uas_standards.interuss.automated_testing.flight_planning.v1.constants import Scope + from monitoring.monitorlib.clients.flight_planning.client import ( FlightPlannerClient, ) -from monitoring.monitorlib.clients.flight_planning.test_preparation import ( - TestPreparationActivityResponse, -) +from monitoring.monitorlib.clients.flight_planning.client import PlanningActivityError from monitoring.monitorlib.clients.flight_planning.flight_info import ( FlightInfo, FlightID, @@ -15,17 +17,17 @@ from monitoring.monitorlib.clients.flight_planning.planning import ( PlanningActivityResponse, ) -from monitoring.monitorlib.fetch import query_and_describe, QueryType -from monitoring.monitorlib.geotemporal import Volume4D -from monitoring.monitorlib.infrastructure import UTMClientSession -from monitoring.uss_qualifier.configurations.configuration import ParticipantID -from monitoring.monitorlib.clients.flight_planning.client import PlanningActivityError from monitoring.monitorlib.clients.flight_planning.planning import ( PlanningActivityResult, FlightPlanStatus, ) -from uas_standards.interuss.automated_testing.flight_planning.v1 import api -from uas_standards.interuss.automated_testing.flight_planning.v1.constants import Scope +from monitoring.monitorlib.clients.flight_planning.test_preparation import ( + TestPreparationActivityResponse, +) +from monitoring.monitorlib.fetch import query_and_describe, QueryType +from monitoring.monitorlib.geotemporal import Volume4D +from monitoring.monitorlib.infrastructure import UTMClientSession +from monitoring.uss_qualifier.configurations.configuration import ParticipantID class V1FlightPlannerClient(FlightPlannerClient): @@ -91,6 +93,7 @@ def _inject( queries=[query], activity_result=resp.planning_result, flight_plan_status=resp.flight_plan_status, + includes_advisories=resp.includes_advisories, ) return response diff --git a/monitoring/uss_qualifier/resources/flight_planning/flight_planner.py b/monitoring/uss_qualifier/resources/flight_planning/flight_planner.py index 0b28f7cf79..08ce4214ba 100644 --- a/monitoring/uss_qualifier/resources/flight_planning/flight_planner.py +++ b/monitoring/uss_qualifier/resources/flight_planning/flight_planner.py @@ -24,6 +24,7 @@ from monitoring.monitorlib.clients.flight_planning.planning import ( PlanningActivityResult, FlightPlanStatus, + AdvisoryInclusion, ) from monitoring.monitorlib.fetch import QueryError, Query from monitoring.monitorlib.geotemporal import Volume4D, Volume4DCollection @@ -122,7 +123,7 @@ def request_flight( self, request: InjectFlightRequest, flight_id: Optional[str] = None, - ) -> Tuple[InjectFlightResponse, fetch.Query, str]: + ) -> Tuple[InjectFlightResponse, fetch.Query, str, Optional[AdvisoryInclusion]]: usage_states = { OperationalIntentState.Accepted: AirspaceUsageState.Planned, OperationalIntentState.Activated: AirspaceUsageState.InUse, @@ -210,7 +211,7 @@ def request_flight( operational_intent_id="", ) - return response, resp.queries[0], flight_id + return response, resp.queries[0], flight_id, resp.includes_advisories def cleanup_flight( self, flight_id: str diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py b/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py index 62226e5802..efa0d6bd8b 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py @@ -197,7 +197,7 @@ def _validate_ended_cancellation(self): self._intents_extent, ) as planned_validator: self.begin_test_step("Plan flight intent") - _, flight_id = plan_flight_intent( + _, flight_id, _ = plan_flight_intent( self, self.tested_uss, self.valid_flight.request, @@ -212,7 +212,7 @@ def _validate_ended_cancellation(self): def _validate_precision_intersection(self): self.begin_test_step("Plan control flight intent") - _, _ = plan_flight_intent( + _, _, _ = plan_flight_intent( self, self.tested_uss, self.valid_flight.request, diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py index d7b880f4aa..a76b6b9414 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py @@ -215,7 +215,7 @@ def _attempt_plan_flight_conflict(self) -> OperationalIntentReference: self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 2") - _, self.flight2_id = plan_flight_intent( + _, self.flight2_id, _ = plan_flight_intent( self, self.control_uss, self.flight2_planned.request, @@ -287,7 +287,7 @@ def _attempt_modify_planned_flight_conflict( self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 1c") - _, self.flight1_id = plan_flight_intent( + _, self.flight1_id, _ = plan_flight_intent( self, self.tested_uss, self.flight1c_planned.request, @@ -393,7 +393,7 @@ def _modify_activated_flight_preexisting_conflict( self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 2m") - _, self.flight2_id = plan_flight_intent( + _, self.flight2_id, _ = plan_flight_intent( self, self.control_uss, self.flight2m_planned.request, @@ -410,7 +410,7 @@ def _modify_activated_flight_preexisting_conflict( flight_2_oi_ref, ) as validator: self.begin_test_step("Declare Flight 2 non-conforming") - resp_flight_2, _ = submit_flight_intent( + resp_flight_2, _, _ = submit_flight_intent( self, "Successful transition to non-conforming state", { @@ -442,7 +442,7 @@ def _modify_activated_flight_preexisting_conflict( self.begin_test_step( "Attempt to modify activated Flight 1 in conflict with nonconforming Flight 2" ) - resp_flight_1, _ = submit_flight_intent( + resp_flight_1, _, _ = submit_flight_intent( self, "Successful modification or rejection", { diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py index 3628c0988b..9ae5e0a504 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py @@ -215,7 +215,7 @@ def _attempt_plan_flight_conflict(self): self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 2") - resp_flight_2, self.flight2_id = plan_flight_intent( + resp_flight_2, self.flight2_id, _ = plan_flight_intent( self, self.control_uss, self.flight2_planned.request, @@ -255,7 +255,7 @@ def _attempt_modify_planned_flight_conflict( self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 1") - resp_flight_1, self.flight1_id = plan_flight_intent( + resp_flight_1, self.flight1_id, _ = plan_flight_intent( self, self.tested_uss, self.flight1_planned.request, @@ -271,7 +271,7 @@ def _attempt_modify_planned_flight_conflict( self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 2") - resp_flight_2, self.flight2_id = plan_flight_intent( + resp_flight_2, self.flight2_id, _ = plan_flight_intent( self, self.control_uss, self.flight2_planned.request, @@ -359,7 +359,7 @@ def _modify_activated_flight_conflict_preexisting( self._intents_extent, ) as validator: self.begin_test_step("Plan Flight 2") - _, self.flight2_id = plan_flight_intent( + _, self.flight2_id, _ = plan_flight_intent( self, self.control_uss, self.flight2_planned.request, diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/notifications_to_operator/__init__.py b/monitoring/uss_qualifier/scenarios/astm/utm/notifications_to_operator/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/off_nominal_planning/down_uss.py b/monitoring/uss_qualifier/scenarios/astm/utm/off_nominal_planning/down_uss.py index ca704c6927..43becbfecd 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/off_nominal_planning/down_uss.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/off_nominal_planning/down_uss.py @@ -229,7 +229,7 @@ def _plan_flight_conflict_planned(self): self._intents_extent, ) as validator: self.begin_test_step("Tested USS attempts to plan Flight 1") - resp, flight_id = submit_flight_intent( + resp, flight_id, _ = submit_flight_intent( self, "Successful planning", { diff --git a/monitoring/uss_qualifier/scenarios/flight_planning/prioritization_test_steps.py b/monitoring/uss_qualifier/scenarios/flight_planning/prioritization_test_steps.py index 253e2dc117..181b55d587 100644 --- a/monitoring/uss_qualifier/scenarios/flight_planning/prioritization_test_steps.py +++ b/monitoring/uss_qualifier/scenarios/flight_planning/prioritization_test_steps.py @@ -31,7 +31,7 @@ def plan_priority_conflict_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly planned", { @@ -61,7 +61,7 @@ def modify_planned_priority_conflict_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly modified", { @@ -94,7 +94,7 @@ def activate_priority_conflict_flight_intent( flight_intent, OperationalIntentState.Activated, scenario ) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly activated", { @@ -127,7 +127,7 @@ def modify_activated_priority_conflict_flight_intent( flight_intent, OperationalIntentState.Activated, scenario ) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly modified", { @@ -157,7 +157,7 @@ def plan_conflict_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly planned", { @@ -187,7 +187,7 @@ def modify_planned_conflict_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly modified", { @@ -220,7 +220,7 @@ def activate_conflict_flight_intent( flight_intent, OperationalIntentState.Activated, scenario ) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly activated", { @@ -253,7 +253,7 @@ def modify_activated_conflict_flight_intent( flight_intent, OperationalIntentState.Activated, scenario ) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Incorrectly modified", { @@ -287,7 +287,7 @@ def plan_permitted_conflict_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, flight_id = submit_flight_intent( + resp, flight_id, _ = submit_flight_intent( scenario, "Successful planning", {InjectFlightResponseResult.Planned}, @@ -316,7 +316,7 @@ def modify_planned_permitted_conflict_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Successful modification", {InjectFlightResponseResult.Planned}, @@ -348,7 +348,7 @@ def activate_permitted_conflict_flight_intent( flight_intent, OperationalIntentState.Activated, scenario ) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Successful activation", {InjectFlightResponseResult.ReadyToFly}, @@ -380,7 +380,7 @@ def modify_activated_permitted_conflict_flight_intent( flight_intent, OperationalIntentState.Activated, scenario ) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Successful modification", {InjectFlightResponseResult.ReadyToFly}, diff --git a/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py b/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py index 385eebf91a..aff6c3037d 100644 --- a/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py +++ b/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py @@ -5,6 +5,7 @@ PlanningActivityResponse, PlanningActivityResult, FlightPlanStatus, + AdvisoryInclusion, ) from monitoring.monitorlib.clients.flight_planning.client_v1 import ( @@ -50,7 +51,7 @@ def plan_flight_intent( scenario: TestScenarioType, flight_planner: FlightPlanner, flight_intent: InjectFlightRequest, -) -> Tuple[InjectFlightResponse, Optional[str]]: +) -> Tuple[InjectFlightResponse, Optional[str], Optional[AdvisoryInclusion]]: """Plan a flight intent that should result in success. Note: This method is deprecated in favor of plan_flight @@ -63,7 +64,7 @@ def plan_flight_intent( """ expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) - resp, flight_id = submit_flight_intent( + resp, flight_id, advisories = submit_flight_intent( scenario, "Successful planning", {InjectFlightResponseResult.Planned}, @@ -72,7 +73,7 @@ def plan_flight_intent( flight_intent, ) - return resp, flight_id + return resp, flight_id, advisories def activate_flight_intent( @@ -94,7 +95,7 @@ def activate_flight_intent( ) scenario.begin_test_step(test_step) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Successful activation", {InjectFlightResponseResult.ReadyToFly}, @@ -125,7 +126,7 @@ def modify_planned_flight_intent( expect_flight_intent_state(flight_intent, OperationalIntentState.Accepted, scenario) scenario.begin_test_step(test_step) - resp, _ = submit_flight_intent( + resp, _, _ = submit_flight_intent( scenario, "Successful modification", {InjectFlightResponseResult.Planned}, @@ -161,7 +162,7 @@ def modify_activated_flight_intent( scenario.begin_test_step(test_step) if preexisting_conflict: - resp, flight_id = submit_flight_intent( + resp, flight_id, _ = submit_flight_intent( scenario, "Successful modification", { @@ -201,7 +202,7 @@ def modify_activated_flight_intent( ) else: - resp, flight_id = submit_flight_intent( + resp, flight_id, _ = submit_flight_intent( scenario, "Successful modification", {InjectFlightResponseResult.ReadyToFly}, @@ -223,7 +224,7 @@ def submit_flight_intent( flight_planner: FlightPlanner, flight_intent: InjectFlightRequest, flight_id: Optional[str] = None, -) -> Tuple[InjectFlightResponse, Optional[str]]: +) -> Tuple[InjectFlightResponse, Optional[str], Optional[AdvisoryInclusion]]: """Submit a flight intent with an expected result. Note: This method is deprecated in favor of submit_flight @@ -243,7 +244,7 @@ def submit_flight_intent( with scenario.check(success_check, [flight_planner.participant_id]) as check: try: - resp, query, flight_id = flight_planner.request_flight( + resp, query, flight_id, advisories = flight_planner.request_flight( flight_intent, flight_id ) except QueryError as e: @@ -273,7 +274,8 @@ def submit_flight_intent( for failed_result, failed_check_name in failed_checks.items(): with scenario.check( - failed_check_name, [flight_planner.participant_id] + failed_check_name, + [flight_planner.participant_id], ) as check: if resp.result == failed_result: check.record_failed( @@ -283,7 +285,7 @@ def submit_flight_intent( query_timestamps=[query.request.timestamp], ) - return resp, flight_id + return resp, flight_id, advisories def delete_flight_intent( diff --git a/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py b/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py index 2c1e1182cb..465bbc5c4f 100644 --- a/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py +++ b/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py @@ -92,7 +92,7 @@ def _attempt_invalid_flights(self) -> bool: for flight_intent in self.invalid_flight_intents: with self.check("Failure", [self.ussp.participant_id]) as failure_check: try: - resp, query, flight_id = self.ussp.request_flight( + resp, query, flight_id, _ = self.ussp.request_flight( flight_intent.request ) except QueryError as e: @@ -135,7 +135,7 @@ def _attempt_invalid_flights(self) -> bool: return True def _plan_valid_flight(self) -> bool: - resp, _ = plan_flight_intent( + resp, _, _ = plan_flight_intent( self, self.ussp, self.valid_flight_intent.request,