diff --git a/monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py b/monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py index 520914a059..298732f220 100644 --- a/monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py +++ b/monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py @@ -212,6 +212,13 @@ def get_op_intent_telemetry( op_intent_ref: OperationalIntentReference, uss_participant_id: Optional[str] = None, ) -> Tuple[Optional[VehicleTelemetry], Query]: + """ + Get telemetry of an operational intent. + Returns: + VehicleTelemetry if available, None otherwise + Raises: + * QueryError: if request failed, if HTTP status code is different than 200, or if the parsing of the response failed. + """ self._uses_scope(Scope.ConformanceMonitoringForSituationalAwareness) op = OPERATIONS[OperationID.GetOperationalIntentTelemetry] query = query_and_describe( @@ -222,14 +229,16 @@ def get_op_intent_telemetry( uss_participant_id, scope=Scope.ConformanceMonitoringForSituationalAwareness, ) - if query.status_code == 200: - result: GetOperationalIntentTelemetryResponse = ImplicitDict.parse( - query.response.json, GetOperationalIntentTelemetryResponse + if query.status_code == 412: + return None, query + elif query.status_code != 200: + raise QueryError( + f"Received code {query.status_code} when attempting to retrieval operational intent telemetry for {op_intent_ref.id}", + query, ) - telemetry = result.telemetry if "telemetry" in result else None - return telemetry, query else: - return None, query + result = query.parse_json_result(GetOperationalIntentTelemetryResponse) + return result.telemetry, query def put_op_intent( self, diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/test_steps.py b/monitoring/uss_qualifier/scenarios/astm/utm/test_steps.py index d3edc1aa0f..01e6752cab 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/test_steps.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/test_steps.py @@ -442,20 +442,21 @@ def _check_op_intent_details( ) def _check_op_intent_telemetry(self, oi_ref: OperationalIntentReference): - oi_tel, oi_tel_query = self._dss.get_op_intent_telemetry( - oi_ref, self._flight_planner.participant_id - ) - self._scenario.record_query(oi_tel_query) - with self._scenario.check( "Operational intent telemetry retrievable", [self._flight_planner.participant_id], ) as check: - if oi_tel_query.status_code not in {200, 412}: + try: + oi_tel, oi_tel_query = self._dss.get_op_intent_telemetry( + oi_ref, self._flight_planner.participant_id + ) + self._scenario.record_query(oi_tel_query) + except fetch.QueryError as e: + self._scenario.record_queries(e.queries) + oi_tel_query = e.queries[0] check.record_failed( summary="Operational intent telemetry could not be retrieved from USS", - severity=Severity.High, - details=f"Received status code {oi_tel_query.status_code} from {self._flight_planner.participant_id} when querying for telemetry of operational intent {oi_ref.id}", + details=f"Received status code {oi_tel_query.status_code} from {self._flight_planner.participant_id} when querying for telemetry of operational intent {oi_ref.id}; {e}", query_timestamps=[oi_tel_query.request.timestamp], )