Skip to content

Commit

Permalink
[uss_qualifier/resources/f3548/dss/get_op_intent_telemetry] Use Query…
Browse files Browse the repository at this point in the history
…Error for error handling
  • Loading branch information
mickmis committed Feb 6, 2024
1 parent 72c0c51 commit 6d6aa34
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
21 changes: 15 additions & 6 deletions monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
17 changes: 9 additions & 8 deletions monitoring/uss_qualifier/scenarios/astm/utm/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)

Expand Down

0 comments on commit 6d6aa34

Please sign in to comment.