Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uss_qualifier/resources/f3548/dss/get_op_intent_telemetry] Use QueryError for error handling #499

Merged
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
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
Loading