Skip to content

Commit

Permalink
[uss_qualifier] netrid: cover net0260 timestamp accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Nov 14, 2024
1 parent 97aa8c7 commit 5b7af59
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 5 deletions.
15 changes: 15 additions & 0 deletions monitoring/monitorlib/fetch/rid.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,21 @@ def timestamp(self) -> Optional[StringBasedDateTime]:
f"Cannot retrieve speed using RID version {self.rid_version}"
)

@property
def timestamp_accuracy(self) -> Optional[float]:
if self.rid_version == RIDVersion.f3411_19:
if not self.v19_value.has_field_with_value("current_state"):
return None
return self.v19_value.current_state.timestamp_accuracy
elif self.rid_version == RIDVersion.f3411_22a:
if not self.v22a_value.has_field_with_value("current_state"):
return None
return self.v22a_value.current_state.timestamp_accuracy
else:
raise NotImplementedError(
f"Cannot retrieve speed using RID version {self.rid_version}"
)

def errors(self) -> List[str]:
try:
rid_version = self.rid_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def _rect_str(rect) -> str:

VERTICAL_SPEED_PRECISION = 0.1
SPEED_PRECISION = 0.05
TIMESTAMP_ACCURACY_PRECISION = 0.05


@dataclass
Expand All @@ -68,6 +69,16 @@ def most_recent_position(self) -> Optional[Position]:
def flight(self) -> fetch.rid.Flight:
return self.query.flights[self.flight_index]

# TODO we may rather want to expose the whole flight object (self.query.flights[self.flight])
# and let callers access subfields directly (will be handled in separate PR)
@property
def timestamp_accuracy(self) -> Optional[float]:
return self.query.flights[self.flight_index].timestamp_accuracy

@property
def raw_flight(self) -> dict:
return self.query.query.response.json["flights"][self.flight_index]


ObservationType = Union[Flight, DPObservedFlight]

Expand Down Expand Up @@ -898,7 +909,7 @@ def _evaluate_normal_sp_observation(
participants=[mapping.injected_flight.uss_participant_id],
)

# Check that altitudes match for any observed flights matching injected flights
# Check that required fields are present and match for any observed flights matching injected flights
for mapping in mappings.values():
injected_telemetry = mapping.injected_flight.flight.telemetry[
mapping.telemetry_index
Expand Down Expand Up @@ -1036,6 +1047,47 @@ def _evaluate_normal_sp_observation(
details=f"{mapping.injected_flight.uss_participant_id}'s flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} had telemetry index {mapping.telemetry_index} at {injected_telemetry.timestamp} with track={injected_telemetry.track}, but Service Provider reported track={mapping.observed_flight.flight.raw.current_state.track} at {mapping.observed_flight.query.query.request.initiated_at}",
)

# Due to how implicit dicts are deserialized and the timestamp_accuracy is specified in the OpenAPI file for F3411-v22a,
# we need to look into the raw JSON response to determine if the field is present:
#
# Because the spec requires the field to be present while also specifying a default value, the implicit dict based class derived
# from the spec may not catch that a field is missing at deserialization time (because the RIDAircraftState class specifies a default
# value for the field, no ValueError will be thrown when ImplicitDict.parse() is called).
#
# This means that a missing json field will neither raise an exception nor cause the field to be set to None when we access it,
# meaning this part of the logic cannot rely on the deserialized value to determine if the field was present or not.
raw_flight = mapping.observed_flight.raw_flight
raw_state = (
raw_flight["current_state"] if "current_state" in raw_flight else {}
)
with self._test_scenario.check(
"Service Provider timestamp accuracy is present",
[mapping.injected_flight.uss_participant_id],
) as check:
if "timestamp_accuracy" not in raw_state:
check.record_failed(
"Timestamp accuracy not present in Service Provider response",
details=f"Timestamp accuracy not present in Service Provider {mapping.injected_flight.uss_participant_id}'s response for flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} with telemetry index {mapping.telemetry_index}",
)

if "timestamp_accuracy" in raw_state:
# From this point on we can use the 'timestamp_accuracy' field of the deserialized object
with self._test_scenario.check(
"Service Provider timestamp accuracy is correct",
[mapping.injected_flight.uss_participant_id],
) as check:
if (
abs(
mapping.observed_flight.timestamp_accuracy
- injected_telemetry.timestamp_accuracy
)
> TIMESTAMP_ACCURACY_PRECISION
):
check.record_failed(
"Timestamp accuracy in Service Provider response is incorrect",
details=f"Timestamp accuracy in Service Provider {mapping.injected_flight.uss_participant_id}'s response for flight with injection ID {mapping.injected_flight.flight.injection_id} in test {mapping.injected_flight.test_id} with telemetry index {mapping.telemetry_index} is {mapping.observed_flight.timestamp_accuracy} which is not equal to the injected value of {injected_telemetry.timestamp_accuracy}",
)

# Verify that flight details queries succeeded and returned correctly-formatted data
for mapping in mappings.values():
details_queries = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ The identity of flights is determined by precisely matching the known injected p

**[astm.f3411.v19.NET0260,Table1,16](../../../../requirements/astm/f3411/v19.md)** requires that relevant Remote ID data, consistent with the common data dictionary, be reported by the Service Provider. Injected flight data had a specified horizontal accuracy that was different from the reported one.

#### ⚠️ Service Provider timestamp accuracy is present check

If the timestamp accuracy is not present, the USS under test is not properly implementing the REST interface specified by the OpenAPI definition contained in Annex A4, and is therefore in violation of **[astm.f3411.v19.NET0710,1](../../../../requirements/astm/f3411/v19.md)**.

#### ⚠️ Service Provider timestamp accuracy is correct check

**[astm.f3411.v19.NET0260,Table1,5](../../../../requirements/astm/f3411/v19.md)** requires that relevant Remote ID data, consistent with the common data dictionary, be reported by the Service Provider. The observed timestamp accuracy differs from the injected one.

#### Successful flight details query check

**[astm.f3411.v19.NET0710,2](../../../../requirements/astm/f3411/v19.md)** and **[astm.f3411.v19.NET0340](../../../../requirements/astm/f3411/v19.md)** require a Service Provider to implement the GET flight details endpoint. This check will fail if uss_qualifier cannot query that endpoint (specified in the ISA present in the DSS) successfully.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ The identity of flights is determined by precisely matching the known injected p

**[astm.f3411.v22a.NET0260,Table1,17](../../../../requirements/astm/f3411/v22a.md)** requires that relevant Remote ID data, consistent with the common data dictionary, be reported by the Service Provider. Injected flight data had a specified horizontal accuracy that was different from the reported one.

#### ⚠️ Service Provider timestamp accuracy is present check

If the timestamp accuracy is not present, the USS under test is not properly implementing the REST interface specified by the OpenAPI definition contained in Annex A4, and is therefore in violation of **[astm.f3411.v22a.NET0710,1](../../../../requirements/astm/f3411/v22a.md)**.

#### ⚠️ Service Provider timestamp accuracy is correct check

**[astm.f3411.v22a.NET0260,Table1,6](../../../../requirements/astm/f3411/v22a.md)** requires that relevant Remote ID data, consistent with the common data dictionary, be reported by the Service Provider. The observed timestamp accuracy differs from the injected one.

#### Successful flight details query check

**[astm.f3411.v22a.NET0710,2](../../../../requirements/astm/f3411/v22a.md)** and **[astm.f3411.v22a.NET0340](../../../../requirements/astm/f3411/v22a.md) require a Service Provider to implement the GET flight details endpoint. This check will fail if uss_qualifier cannot query that endpoint (specified in the ISA present in the DSS) successfully.
Expand Down
7 changes: 6 additions & 1 deletion monitoring/uss_qualifier/suites/astm/netrid/f3411_19.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<th><a href="../../README.md#checked-in">Checked in</a></th>
</tr>
<tr>
<td rowspan="69" style="vertical-align:top;"><a href="../../../requirements/astm/f3411/v19.md">astm<br>.f3411<br>.v19</a></td>
<td rowspan="70" style="vertical-align:top;"><a href="../../../requirements/astm/f3411/v19.md">astm<br>.f3411<br>.v19</a></td>
<td><a href="../../../requirements/astm/f3411/v19.md">DSS0010</a></td>
<td>Implemented</td>
<td><a href="../../../scenarios/astm/netrid/v19/dss/token_validation.md">ASTM NetRID DSS: Token Validation</a></td>
Expand Down Expand Up @@ -286,6 +286,11 @@
<td>Implemented</td>
<td><a href="../../../scenarios/astm/netrid/v19/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../../requirements/astm/f3411/v19.md">NET0260,Table1,5</a></td>
<td>Implemented</td>
<td><a href="../../../scenarios/astm/netrid/v19/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../../requirements/astm/f3411/v19.md">NET0260,Table1,9</a></td>
<td>Implemented</td>
Expand Down
7 changes: 6 additions & 1 deletion monitoring/uss_qualifier/suites/astm/netrid/f3411_22a.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<th><a href="../../README.md#checked-in">Checked in</a></th>
</tr>
<tr>
<td rowspan="94" style="vertical-align:top;"><a href="../../../requirements/astm/f3411/v22a.md">astm<br>.f3411<br>.v22a</a></td>
<td rowspan="95" style="vertical-align:top;"><a href="../../../requirements/astm/f3411/v22a.md">astm<br>.f3411<br>.v22a</a></td>
<td><a href="../../../requirements/astm/f3411/v22a.md">DSS0010</a></td>
<td>Implemented</td>
<td><a href="../../../scenarios/astm/netrid/v22a/dss/token_validation.md">ASTM NetRID DSS: Token Validation</a></td>
Expand Down Expand Up @@ -326,6 +326,11 @@
<td>Implemented</td>
<td><a href="../../../scenarios/astm/netrid/v22a/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../../requirements/astm/f3411/v22a.md">NET0260,Table1,6</a></td>
<td>Implemented</td>
<td><a href="../../../scenarios/astm/netrid/v22a/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../../requirements/astm/f3411/v22a.md">NET0260,Table1,7</a></td>
<td>Implemented</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<th><a href="../README.md#checked-in">Checked in</a></th>
</tr>
<tr>
<td rowspan="94" style="vertical-align:top;"><a href="../../requirements/astm/f3411/v22a.md">astm<br>.f3411<br>.v22a</a></td>
<td rowspan="95" style="vertical-align:top;"><a href="../../requirements/astm/f3411/v22a.md">astm<br>.f3411<br>.v22a</a></td>
<td><a href="../../requirements/astm/f3411/v22a.md">DSS0010</a></td>
<td>Implemented</td>
<td><a href="../../scenarios/astm/netrid/v22a/dss/token_validation.md">ASTM NetRID DSS: Token Validation</a></td>
Expand Down Expand Up @@ -322,6 +322,11 @@
<td>Implemented</td>
<td><a href="../../scenarios/astm/netrid/v22a/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../requirements/astm/f3411/v22a.md">NET0260,Table1,6</a></td>
<td>Implemented</td>
<td><a href="../../scenarios/astm/netrid/v22a/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../requirements/astm/f3411/v22a.md">NET0260,Table1,7</a></td>
<td>Implemented</td>
Expand Down
7 changes: 6 additions & 1 deletion monitoring/uss_qualifier/suites/uspace/required_services.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<th><a href="../README.md#checked-in">Checked in</a></th>
</tr>
<tr>
<td rowspan="94" style="vertical-align:top;"><a href="../../requirements/astm/f3411/v22a.md">astm<br>.f3411<br>.v22a</a></td>
<td rowspan="95" style="vertical-align:top;"><a href="../../requirements/astm/f3411/v22a.md">astm<br>.f3411<br>.v22a</a></td>
<td><a href="../../requirements/astm/f3411/v22a.md">DSS0010</a></td>
<td>Implemented</td>
<td><a href="../../scenarios/astm/netrid/v22a/dss/token_validation.md">ASTM NetRID DSS: Token Validation</a></td>
Expand Down Expand Up @@ -323,6 +323,11 @@
<td>Implemented</td>
<td><a href="../../scenarios/astm/netrid/v22a/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../requirements/astm/f3411/v22a.md">NET0260,Table1,6</a></td>
<td>Implemented</td>
<td><a href="../../scenarios/astm/netrid/v22a/nominal_behavior.md">ASTM NetRID nominal behavior</a></td>
</tr>
<tr>
<td><a href="../../requirements/astm/f3411/v22a.md">NET0260,Table1,7</a></td>
<td>Implemented</td>
Expand Down

0 comments on commit 5b7af59

Please sign in to comment.