From 365e7ed08121a2802618851d8ccce2f82e92ed18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Wed, 20 Mar 2024 20:59:13 +0100 Subject: [PATCH] [uss_qualifier/scenarios/flight_planning] Enable skipping check if USS indicates NotSupported (#567) --- .../scenarios/flight_planning/test_steps.py | 17 +++++++++++++---- monitoring/uss_qualifier/scenarios/scenario.py | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py b/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py index 24aedb2d87..55be5aaf73 100644 --- a/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py +++ b/monitoring/uss_qualifier/scenarios/flight_planning/test_steps.py @@ -432,10 +432,12 @@ def submit_flight( flight_info: FlightInfo, flight_id: Optional[str] = None, additional_fields: Optional[dict] = None, + skip_if_not_supported: bool = False, ) -> Tuple[PlanningActivityResponse, Optional[str]]: """Submit a flight intent with an expected result. A check fail is considered by default of high severity and as such will raise an ScenarioCannotContinueError. The severity of each failed check may be overridden if needed. + If skip_if_not_supported=True and the USS responds that the operation is not supported, the check is skipped without failing. This function does not directly implement a test step. @@ -453,16 +455,23 @@ def submit_flight( resp, query, flight_id = request_flight( flight_planner, flight_info, flight_id, additional_fields ) - result = (resp.activity_result, resp.flight_plan_status) + scenario.record_query(query) except QueryError as e: - for q in e.queries: - scenario.record_query(q) + scenario.record_queries(e.queries) check.record_failed( summary=f"Error from {flight_planner.participant_id} when attempting to submit a flight intent (flight ID: {flight_id})", details=f"{str(e)}\n\nStack trace:\n{e.stacktrace}", query_timestamps=[q.request.timestamp for q in e.queries], ) - scenario.record_query(query) + + if ( + skip_if_not_supported + and resp.activity_result == PlanningActivityResult.NotSupported + ): + check.skip() + return resp, None + + result = (resp.activity_result, resp.flight_plan_status) check_details = ( f'{flight_planner.participant_id} indicated {result} rather than the expected {" or ".join([f"({expected_result[0]}, {expected_result[1]})" for expected_result in expected_results])}' + ( diff --git a/monitoring/uss_qualifier/scenarios/scenario.py b/monitoring/uss_qualifier/scenarios/scenario.py index feabe79001..ea790a2817 100644 --- a/monitoring/uss_qualifier/scenarios/scenario.py +++ b/monitoring/uss_qualifier/scenarios/scenario.py @@ -170,6 +170,9 @@ def record_passed(self) -> None: ) self._step_report.passed_checks.append(passed_check) + def skip(self) -> None: + self._outcome_recorded = True + def get_scenario_type_by_name(scenario_type_name: TestScenarioTypeName) -> Type: inspection.import_submodules(scenarios_module)