Skip to content

Commit 2a2d390

Browse files
committed
dss0210 sub area is sync'd
1 parent da335eb commit 2a2d390

File tree

10 files changed

+232
-9
lines changed

10 files changed

+232
-9
lines changed

monitoring/monitorlib/geo.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ def from_coords(coords: List[Tuple[float, float]]) -> Polygon:
121121
vertices=[LatLngPoint(lat=lat, lng=lng) for (lat, lng) in coords]
122122
)
123123

124+
@staticmethod
125+
def from_latlng_coords(coords: List[LatLng]) -> Polygon:
126+
return Polygon(
127+
vertices=[
128+
LatLngPoint(lat=p.lat().degrees, lng=p.lng().degrees) for p in coords
129+
]
130+
)
131+
124132
@staticmethod
125133
def from_latlng_rect(latlngrect: s2sphere.LatLngRect) -> Polygon:
126134
return Polygon(
@@ -651,3 +659,53 @@ def generate_slight_overlap_area(in_points: List[LatLng]) -> List[LatLng]:
651659
)
652660

653661
return [overlap_corner, same_lat_point, opposite_corner, same_lng_point]
662+
663+
664+
def generate_area_in_vicinity(
665+
in_points: List[LatLng], relative_distance: float
666+
) -> List[LatLng]:
667+
"""
668+
Takes a list of LatLng points and returns a list of LatLng points that represents
669+
a non-contiguous area in the vicinity of the input.
670+
671+
The returned polygon is built as such:
672+
- draw a line from the center of the input polygon to the first point of the input polygon
673+
- continue on the line for a distance equal to 'relative_distance' multiplied by the distance between the center and the first point
674+
- from this point, draw a square in the direction opposite of the center of the input polygon
675+
676+
The square will have a size comparable to half of the input polygon's diameter.
677+
"""
678+
starting_point = in_points[0] # our starting point
679+
680+
# Compute the center of mass of the input polygon
681+
center = LatLng.from_degrees(
682+
sum([point.lat().degrees for point in in_points]) / len(in_points),
683+
sum([point.lng().degrees for point in in_points]) / len(in_points),
684+
)
685+
686+
# Compute the distance between the center and the starting point, as a 2D vector
687+
delta_lat = center.lat().degrees - starting_point.lat().degrees
688+
delta_lng = center.lng().degrees - starting_point.lng().degrees
689+
690+
# Multiply the vector by the relative distance
691+
distance_lat = delta_lat * relative_distance
692+
distance_lng = delta_lng * relative_distance
693+
694+
closest_corner = LatLng.from_degrees(
695+
starting_point.lat().degrees - distance_lat,
696+
starting_point.lng().degrees - distance_lng,
697+
)
698+
699+
same_lat_point = LatLng.from_degrees(
700+
closest_corner.lat().degrees, closest_corner.lng().degrees - delta_lng
701+
)
702+
same_lng_point = LatLng.from_degrees(
703+
closest_corner.lat().degrees - delta_lat, closest_corner.lng().degrees
704+
)
705+
706+
opposite_corner = LatLng.from_degrees(
707+
closest_corner.lat().degrees - delta_lat,
708+
closest_corner.lng().degrees - delta_lng,
709+
)
710+
711+
return [closest_corner, same_lat_point, opposite_corner, same_lng_point]

monitoring/monitorlib/geo_test.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
from s2sphere import LatLng
44

5-
from monitoring.monitorlib.geo import generate_slight_overlap_area
5+
from monitoring.monitorlib.geo import (
6+
generate_slight_overlap_area,
7+
generate_area_in_vicinity,
8+
)
9+
10+
MAX_DIFFERENCE = 0.001
611

712

813
def _points(in_points: List[Tuple[float, float]]) -> List[LatLng]:
@@ -34,3 +39,30 @@ def test_generate_slight_overlap_area():
3439
assert generate_slight_overlap_area(
3540
_points([(1, -1), (1, 0), (0, 0), (0, -1)])
3641
) == _points([(1, -1), (1, -1.5), (1.5, -1.5), (1.5, -1)])
42+
43+
44+
def _approx_equals(p1: List[LatLng], p2: List[LatLng]) -> bool:
45+
return all([p1[i].approx_equals(p2[i], MAX_DIFFERENCE) for i in range(len(p1))])
46+
47+
48+
def test_generate_area_in_vicinity():
49+
# Square around 0,0 of edge length 2 -> first corner at 1,1. rel_distance of 2:
50+
# expect a 1 by 1 square with the closest corner at 3,3
51+
assert _approx_equals(
52+
generate_area_in_vicinity(_points([(1, 1), (1, -1), (-1, -1), (-1, 1)]), 2),
53+
_points([(3.0, 3.0), (3.0, 4.0), (4.0, 4.0), (4.0, 3.0)]),
54+
)
55+
56+
# Square around 0,0 of edge length 2 -> first corner at 1,-1. rel_distance of 2:
57+
# expect a 1 by 1 square with the closest corner at 3,-3
58+
assert _approx_equals(
59+
generate_area_in_vicinity(_points([(1, -1), (-1, -1), (-1, 1), (1, 1)]), 2),
60+
_points([(3.0, -3.0), (3.0, -4.0), (4.0, -4.0), (4.0, -3.0)]),
61+
)
62+
63+
# Square with diagonal from 0,0 to -1,-1 -> first corner at -1,-1. rel_distance of 2:
64+
# expect a .5 by .5 square with the closest corner at -2,-2
65+
assert _approx_equals(
66+
generate_area_in_vicinity(_points([(-1, -1), (0, -1), (0, 0), (-1, 0)]), 2),
67+
_points([(-2.0, -2.0), (-2.0, -2.5), (-2.5, -2.5), (-2.5, -2.0)]),
68+
)

monitoring/uss_qualifier/scenarios/astm/utm/dss/fragments/sub/sync.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ either one of the instances at which the subscription was created or the one tha
4141

4242
If the subscription returned by a DSS to which the subscription was synchronized to does not contain the expected notification count,
4343
either one of the instances at which the subscription was created or the one that was queried, may be failing to implement **[astm.f3548.v21.DSS0210,1i](../../../../../../requirements/astm/f3548/v21.md)**.
44+
45+
## 🛑 Secondary DSS returns the subscription in searches for area that contains it check
46+
47+
The secondary DSS should be aware of the subscription's area: when a search query is issued for an area that encompasses the created subscription,
48+
the secondary DSS should return the subscription in its search results. Otherwise, it is in violation of **[astm.f3548.v21.DSS0210,1d](../../../../../../requirements/astm/f3548/v21.md)**.
49+
50+
## 🛑 Secondary DSS does not return the subscription in searches not encompassing the general area of the subscription check
51+
52+
The secondary DSS should be aware of the subscription's area: when a search query is issued for an area not in the vicinity of the created subscription,
53+
the secondary DSS should not return it in its search results. Otherwise, it is in violation of **[astm.f3548.v21.DSS0210,1d](../../../../../../requirements/astm/f3548/v21.md)**.

monitoring/uss_qualifier/scenarios/astm/utm/dss/synchronization/subscription_synchronization.py

Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from uas_standards.astm.f3548.v21.api import Subscription, SubscriptionID
66
from uas_standards.astm.f3548.v21.constants import Scope
77

8+
from monitoring.monitorlib import geo
9+
from monitoring.monitorlib.geo import Volume3D
810
from monitoring.monitorlib.geotemporal import Volume4D
911
from monitoring.monitorlib.mutate.scd import MutatedSubscription
1012
from monitoring.prober.infrastructure import register_resource_type
@@ -93,6 +95,26 @@ def __init__(
9395
volume=self._planning_area.volume,
9496
)
9597

98+
# Get a list of vertices enclosing the area
99+
enclosing_area = geo.get_latlngrect_vertices(
100+
geo.make_latlng_rect(self._planning_area_volume4d.volume)
101+
)
102+
103+
self._enclosing_sub_area_volume4d = Volume4D(
104+
volume=Volume3D(
105+
outline_polygon=geo.Polygon.from_latlng_coords(enclosing_area)
106+
)
107+
)
108+
109+
# Get a list of vertices outside the subscription's area
110+
outside_area = geo.generate_area_in_vicinity(enclosing_area, 2)
111+
112+
self._outside_sub_area_volume4d = Volume4D(
113+
volume=Volume3D(
114+
outline_polygon=geo.Polygon.from_latlng_coords(outside_area)
115+
)
116+
)
117+
96118
self._sub_params = self._planning_area.get_new_subscription_params(
97119
subscription_id=self._sub_id,
98120
# Set this slightly in the past: we will update the subscriptions
@@ -204,20 +226,91 @@ def _create_sub_with_params(self, creation_params: SubscriptionParams):
204226

205227
def _query_secondaries_and_compare(self, expected_sub_params: SubscriptionParams):
206228
for secondary_dss in self._dss_read_instances:
207-
self._validate_sub_from_secondary(
229+
self._validate_get_sub_from_secondary(
208230
secondary_dss=secondary_dss,
209231
expected_sub_params=expected_sub_params,
210232
involved_participants=list(
211233
{self._primary_pid, secondary_dss.participant_id}
212234
),
213235
)
236+
self._validate_sub_area_from_secondary(
237+
secondary_dss=secondary_dss,
238+
expected_sub_id=expected_sub_params.sub_id,
239+
involved_participants=list(
240+
{self._primary_pid, secondary_dss.participant_id}
241+
),
242+
)
243+
244+
def _validate_sub_area_from_secondary(
245+
self,
246+
secondary_dss: DSSInstance,
247+
expected_sub_id: str,
248+
involved_participants: List[str],
249+
):
250+
"""Checks that the secondary DSS is also aware of the proper subscription's area:
251+
- searching for the subscription's area should yield the subscription
252+
- searching outside the subscription's area should not yield the subscription"""
253+
254+
# Query the subscriptions inside the enclosing area
255+
sub_included = secondary_dss.query_subscriptions(
256+
self._enclosing_sub_area_volume4d.to_f3548v21()
257+
)
258+
259+
with self.check(
260+
"Successful subscription search query", secondary_dss.participant_id
261+
) as check:
262+
if sub_included.status_code != 200:
263+
check.record_failed(
264+
"Subscription search query failed",
265+
details=f"Subscription search query failed with status code {sub_included.status_code}",
266+
query_timestamps=[sub_included.request.timestamp],
267+
)
268+
269+
with self.check(
270+
"Secondary DSS returns the subscription in searches for area that contains it",
271+
involved_participants,
272+
) as check:
273+
if expected_sub_id not in sub_included.subscriptions:
274+
check.record_failed(
275+
"Secondary DSS did not return the subscription",
276+
details=f"Secondary DSS did not return the subscription {expected_sub_id} "
277+
f"although the search volume covered the subscription's area",
278+
query_timestamps=[sub_included.request.timestamp],
279+
)
280+
281+
sub_not_included = secondary_dss.query_subscriptions(
282+
self._outside_sub_area_volume4d.to_f3548v21()
283+
)
284+
285+
with self.check(
286+
"Successful subscription search query", secondary_dss.participant_id
287+
) as check:
288+
if sub_not_included.status_code != 200:
289+
check.record_failed(
290+
summary="Subscription search query failed",
291+
details=f"Subscription search query failed with status code {sub_included.status_code}",
292+
query_timestamps=[sub_included.request.timestamp],
293+
)
294+
295+
with self.check(
296+
"Secondary DSS does not return the subscription in searches not encompassing the general area of the subscription",
297+
involved_participants,
298+
) as check:
299+
if expected_sub_id in sub_not_included.subscriptions:
300+
check.record_failed(
301+
summary="Secondary DSS returned the subscription",
302+
details=f"Secondary DSS returned the subscription {expected_sub_id} "
303+
f"although the search volume did not cover the subscription's general area",
304+
query_timestamps=[sub_not_included.request.timestamp],
305+
)
214306

215-
def _validate_sub_from_secondary(
307+
def _validate_get_sub_from_secondary(
216308
self,
217309
secondary_dss: DSSInstance,
218310
expected_sub_params: SubscriptionParams,
219311
involved_participants: List[str],
220312
):
313+
"""Fetches the subscription from the secondary DSS and validates it."""
221314
with self.check(
222315
"Subscription can be found at every DSS",
223316
involved_participants,

monitoring/uss_qualifier/suites/astm/utm/dss_probing.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<th><a href="../../README.md#checked-in">Checked in</a></th>
2222
</tr>
2323
<tr>
24-
<td rowspan="15" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
24+
<td rowspan="16" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
2525
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0005,1</a></td>
2626
<td>Implemented</td>
2727
<td><a href="../../../scenarios/astm/utm/op_intent_ref_access_control.md">ASTM F3548-21 UTM DSS Operational Intent Reference Access Control</a><br><a href="../../../scenarios/astm/utm/dss/subscription_simple.md">ASTM SCD DSS: Subscription Simple</a><br><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a><br><a href="../../../scenarios/astm/utm/dss/subscription_validation.md">ASTM SCD DSS: Subscription Validation</a></td>
@@ -61,6 +61,11 @@
6161
<td>Implemented</td>
6262
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
6363
</tr>
64+
<tr>
65+
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1d</a></td>
66+
<td>Implemented</td>
67+
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
68+
</tr>
6469
<tr>
6570
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1e</a></td>
6671
<td>Implemented</td>

monitoring/uss_qualifier/suites/astm/utm/f3548_21.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<th><a href="../../README.md#checked-in">Checked in</a></th>
3636
</tr>
3737
<tr>
38-
<td rowspan="41" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
38+
<td rowspan="42" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
3939
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0005,1</a></td>
4040
<td>Implemented</td>
4141
<td><a href="../../../scenarios/astm/utm/prep_planners.md">ASTM F3548 flight planners preparation</a><br><a href="../../../scenarios/astm/utm/op_intent_ref_access_control.md">ASTM F3548-21 UTM DSS Operational Intent Reference Access Control</a><br><a href="../../../scenarios/astm/utm/dss/subscription_simple.md">ASTM SCD DSS: Subscription Simple</a><br><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a><br><a href="../../../scenarios/astm/utm/dss/subscription_validation.md">ASTM SCD DSS: Subscription Validation</a><br><a href="../../../scenarios/astm/utm/off_nominal_planning/down_uss.md">Off-Nominal planning: down USS</a><br><a href="../../../scenarios/astm/utm/off_nominal_planning/down_uss_equal_priority_not_permitted.md">Off-Nominal planning: down USS with equal priority conflicts not permitted</a></td>
@@ -80,6 +80,11 @@
8080
<td>Implemented</td>
8181
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
8282
</tr>
83+
<tr>
84+
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1d</a></td>
85+
<td>Implemented</td>
86+
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
87+
</tr>
8388
<tr>
8489
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1e</a></td>
8590
<td>Implemented</td>

monitoring/uss_qualifier/suites/faa/uft/message_signing.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<th><a href="../../README.md#checked-in">Checked in</a></th>
1919
</tr>
2020
<tr>
21-
<td rowspan="41" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
21+
<td rowspan="42" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
2222
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0005,1</a></td>
2323
<td>Implemented</td>
2424
<td><a href="../../../scenarios/astm/utm/prep_planners.md">ASTM F3548 flight planners preparation</a><br><a href="../../../scenarios/astm/utm/op_intent_ref_access_control.md">ASTM F3548-21 UTM DSS Operational Intent Reference Access Control</a><br><a href="../../../scenarios/astm/utm/dss/subscription_simple.md">ASTM SCD DSS: Subscription Simple</a><br><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a><br><a href="../../../scenarios/astm/utm/dss/subscription_validation.md">ASTM SCD DSS: Subscription Validation</a><br><a href="../../../scenarios/astm/utm/off_nominal_planning/down_uss.md">Off-Nominal planning: down USS</a><br><a href="../../../scenarios/astm/utm/off_nominal_planning/down_uss_equal_priority_not_permitted.md">Off-Nominal planning: down USS with equal priority conflicts not permitted</a></td>
@@ -63,6 +63,11 @@
6363
<td>Implemented</td>
6464
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
6565
</tr>
66+
<tr>
67+
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1d</a></td>
68+
<td>Implemented</td>
69+
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
70+
</tr>
6671
<tr>
6772
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1e</a></td>
6873
<td>Implemented</td>

monitoring/uss_qualifier/suites/interuss/dss/all_tests.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@
408408
<td><a href="../../../scenarios/astm/netrid/v22a/dss/heavy_traffic_concurrent.md">ASTM NetRID DSS: Concurrent Requests</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/isa_expiry.md">ASTM NetRID DSS: ISA Expiry</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/isa_subscription_interactions.md">ASTM NetRID DSS: ISA Subscription Interactions</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/isa_simple.md">ASTM NetRID DSS: Simple ISA</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/isa_validation.md">ASTM NetRID DSS: Submitted ISA Validations</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/subscription_simple.md">ASTM NetRID DSS: Subscription Simple</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/subscription_validation.md">ASTM NetRID DSS: Subscription Validation</a><br><a href="../../../scenarios/astm/netrid/v22a/dss/token_validation.md">ASTM NetRID DSS: Token Validation</a></td>
409409
</tr>
410410
<tr>
411-
<td rowspan="15" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
411+
<td rowspan="16" style="vertical-align:top;"><a href="../../../requirements/astm/f3548/v21.md">astm<br>.f3548<br>.v21</a></td>
412412
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0005,1</a></td>
413413
<td>Implemented</td>
414414
<td><a href="../../../scenarios/astm/utm/op_intent_ref_access_control.md">ASTM F3548-21 UTM DSS Operational Intent Reference Access Control</a><br><a href="../../../scenarios/astm/utm/dss/subscription_simple.md">ASTM SCD DSS: Subscription Simple</a><br><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a><br><a href="../../../scenarios/astm/utm/dss/subscription_validation.md">ASTM SCD DSS: Subscription Validation</a></td>
@@ -448,6 +448,11 @@
448448
<td>Implemented</td>
449449
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
450450
</tr>
451+
<tr>
452+
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1d</a></td>
453+
<td>Implemented</td>
454+
<td><a href="../../../scenarios/astm/utm/dss/synchronization/subscription_synchronization.md">ASTM SCD DSS: Subscription Synchronization</a></td>
455+
</tr>
451456
<tr>
452457
<td><a href="../../../requirements/astm/f3548/v21.md">DSS0210,1e</a></td>
453458
<td>Implemented</td>

0 commit comments

Comments
 (0)