Skip to content

Commit

Permalink
Add notification_index checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Oct 27, 2023
1 parent 06c6ae5 commit 1ab70e6
Show file tree
Hide file tree
Showing 12 changed files with 288 additions and 72 deletions.
11 changes: 11 additions & 0 deletions monitoring/monitorlib/fetch/rid.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,17 @@ def isa_url(self) -> str:
f"Cannot retrieve isa_url using RID version {self.rid_version}"
)

@property
def notification_index(self) -> int:
if self.rid_version == RIDVersion.f3411_19:
return self.v19_value.notification_index
elif self.rid_version == RIDVersion.f3411_22a:
return self.v22a_value.notification_index
else:
raise NotImplementedError(
f"Cannot retrieve notification_index using RID version {self.rid_version}"
)


class RIDQuery(ImplicitDict):
v19_query: Optional[Query] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

While neither ASTM F3411-19 nor F3411-22a explicitly require DSS implementations to implement all endpoints specified in Annex A4 (of each respective standard), InterUSS automated testing expects DSS implementations to implement all DSS endpoints specified in Annex A4. Specifically:

* <tt>PutISA</tt>: The DSS implementation under test must implement the ability to create and update an Identification Service Area by ID in accordance with the API specified in Annex A4 of the respective standard.
* <tt>GetISA</tt>: The DSS implementation under test must implement the ability to retrieve an Identification Service Area by ID in accordance with the API specified in Annex A4 of the respective standard.
* <tt>DeleteISA</tt>: The DSS implementation under test must implement the ability to delete an Identification Service Area by ID in accordance with the API specified in Annex A4 of the respective standard.
* <tt>SearchISAs</tt>: The DSS implementation under test must implement the ability to search for Identification Service Areas meeting the specified criteria in accordance with the API specified in Annex A4 of the respective standard.
* <tt>CreateSubscription</tt>: The DSS implementation under test must implement the ability to create a subscription in accordance with the API specified in Annex A4 of the respective standard.
* <tt>SearchSubscriptions</tt>: The DSS implementation under test must implement the ability to search for subscriptions in accordance with the API specified in Annex A4 of the respective standard.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ def run(self):
def _check_subscription_behaviors(self):
"""
- Create an ISA.
- Create a subscription, response should include the pre-existing ISA.
- Modify the ISA, response should include the subscription.
- Delete the ISA, response should include the subscription.
- Create a subscription, response should include the pre-existing ISA and have a notification_index of 0.
- Modify the ISA, response should include the subscription with an incremented notification_index.
- Delete the ISA, response should include the subscription with an incremented notification_index.
- Delete the subscription.
"""

Expand Down Expand Up @@ -115,9 +115,22 @@ def _check_subscription_behaviors(self):
],
)

with self.check(
"Newly created subscription has a notification_index of 0",
[self._dss.participant_id],
) as check:
if created_subscription.subscription.notification_index != 0:
check.record_failed(
summary="Subscription notification_index is not 0",
severity=Severity.High,
participants=[self._dss.participant_id],
details=f"The subscription created for the area {self._isa_area} is expected to have a notification_index of 0. The returned subscription has a notification_index of {created_subscription.subscription.notification_index}.",
query_timestamps=[created_subscription.query.request.timestamp],
)

# Modify the ISA
with self.check(
"Response to the mutation of the ISA contains subscription ID",
"Mutate the ISA",
[self._dss.participant_id],
) as check:
mutated_isa = self._dss_wrapper.put_isa_expect_response_code(
Expand All @@ -133,12 +146,20 @@ def _check_subscription_behaviors(self):
isa_version=created_isa.dss_query.isa.version,
)

subscriptions_to_isa = []
# Check that the subscription ID is returned in the response
with self.check(
"Response to the mutation of the ISA contains subscription ID",
[self._dss.participant_id],
) as check:

subs_to_mutated_isa = {}
for returned_subscriber in mutated_isa.dss_query.subscribers:
for sub_in_subscriber in returned_subscriber.raw.subscriptions:
subscriptions_to_isa.append(sub_in_subscriber.subscription_id)
subs_to_mutated_isa[
sub_in_subscriber.subscription_id
] = sub_in_subscriber

if created_subscription.subscription.id not in subscriptions_to_isa:
if created_subscription.subscription.id not in subs_to_mutated_isa.keys():
check.record_failed(
summary="ISA mutation response does not contain expected subscription ID",
severity=Severity.High,
Expand All @@ -151,9 +172,27 @@ def _check_subscription_behaviors(self):
],
)

# Check that the subscription index has been incremented by least by 1
sub_to_mutated_isa = subs_to_mutated_isa.get(
created_subscription.subscription.id
)
if sub_to_mutated_isa is not None:
with self.check(
"Subscription to an ISA has its notification index incremented after mutation",
[self._dss.participant_id],
) as check:
if sub_to_mutated_isa.notification_index <= 0:
check.record_failed(
summary="Subscription notification_index has not been increased",
severity=Severity.High,
participants=[self._dss.participant_id],
details=f"The subscription created for the area {self._isa_area} is expected to have a notification_index of 1 or more. The returned subscription has a notification_index of {subs_to_mutated_isa[created_subscription.subscription.id].notification_index}.",
query_timestamps=[created_subscription.query.request.timestamp],
)

# Delete the ISA
with self.check(
"Response to the deletion of the ISA contains subscription ID",
"Delete the ISA",
[self._dss.participant_id],
) as check:
deleted_isa = self._dss_wrapper.del_isa_expect_response_code(
Expand All @@ -163,14 +202,20 @@ def _check_subscription_behaviors(self):
isa_version=mutated_isa.dss_query.isa.version,
)

subscriptions_to_deleted_isa = []
# Check response to deletion of ISA
with self.check(
"Response to the deletion of the ISA contains subscription ID",
[self._dss.participant_id],
) as check:

subs_to_deleted_isa = {}
for returned_subscriber in deleted_isa.dss_query.subscribers:
for sub_in_subscriber in returned_subscriber.raw.subscriptions:
subscriptions_to_deleted_isa.append(
subs_to_deleted_isa[
sub_in_subscriber.subscription_id
)
] = sub_in_subscriber

if created_subscription.subscription.id not in subscriptions_to_deleted_isa:
if created_subscription.subscription.id not in subs_to_deleted_isa:
check.record_failed(
summary="ISA deletion response does not contain expected subscription ID",
severity=Severity.High,
Expand All @@ -197,6 +242,27 @@ def _check_subscription_behaviors(self):
query_timestamps=[notification.query.request.timestamp],
)

subs_after_deletion = subs_to_deleted_isa.get(
created_subscription.subscription.id
)
if subs_after_deletion is not None:
with self.check(
"Subscription to an ISA has its notification index incremented after deletion",
[self._dss.participant_id],
) as check:
if (
subs_after_deletion.notification_index
<= sub_to_mutated_isa.notification_index
):
check.record_failed(
summary="Subscription notification_index has not been incremented",
severity=Severity.High,
participants=[self._dss.participant_id],
details=f"The subscription created for the area {self._isa_area} is expected to have its notification increased after the subscription was deleted."
f"The returned subscription has a notification_index of {subs_after_deletion.notification_index}, whilte the previous notification_index for that subscription was {sub_to_mutated_isa.notification_index}",
query_timestamps=[created_subscription.query.request.timestamp],
)

# Delete the subscription
with self.check(
"Successful subscription deletion",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ When a pre-existing ISA needs to be deleted to ensure a clean workspace, any sub

#### Successful subscription query check

**[astm.f3411.v19.DSS0030,f](../../../../../requirements/astm/f3411/v19.md)** requires the implementation of the DSS endpoint to allow callers to retrieve the subscriptions they created.
**[interuss.f3411.dss_endpoints.SearchSubscriptions](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires the implementation of the DSS endpoint to allow callers to retrieve the subscriptions they created.

#### Successful subscription deletion check

Expand All @@ -51,16 +51,22 @@ When a pre-existing ISA needs to be deleted to ensure a clean workspace, any sub
This test case will do the following, using the DSS being tested:

1. Create an ISA with the configured footprint,
2. Create a subscription for the ISA's area, and expect to find the created ISA mentioned in the reply,
3. Modify the ISA, and expect to find the created subscription in the reply,
4. Delete the ISA, and expect to find the created subscription in the reply,
2. Create a subscription for the ISA's area, and expect:
- to find the created ISA mentioned in the reply
- the notification index of the subscription to be 0
3. Modify the ISA, and expect:
- to find the created subscription in the reply
- the notification index of the subscription to be greater than 0
4. Delete the ISA, and expect:
- to find the created subscription in the reply
- the notification index of the subscription to be greater than it was after the mutation
5. Delete the subscription.

### ISA Subscription Interactions test step

#### Create an ISA check

If the ISA cannot be created, the PUT DSS endpoint in **[astm.f3411.v22a.DSS0030,a](../../../../../requirements/astm/f3411/v22a.md)** is likely not implemented correctly.
If the ISA cannot be created, the PUT DSS endpoint in **[astm.f3411.v19.DSS0030,a](../../../../../requirements/astm/f3411/v19.md)** is likely not implemented correctly.

#### Create a subscription within the ISA footprint check

Expand All @@ -71,16 +77,43 @@ The DSS should allow the creation of a subscription within the ISA footprint, ot
A subscription that is created for a volume that intersects with the previously created ISA should mention
the previously created ISA. If not, the serving DSS is in violation of **[astm.f3411.v19.DSS0030,c](../../../../../requirements/astm/f3411/v19.md)**.

#### Newly created subscription has a notification_index of 0 check

A newly created subscription is expected to have a notification index of 0, otherwise the DSS implementation under
test does not comply with **[interuss.f3411.dss_endpoints.CreateSubscription](../../../../../requirements/interuss/f3411/dss_endpoints.md)**

#### Mutate the ISA check

If the ISA cannot be mutated, **[interuss.f3411.dss_endpoints.PutISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** is likely not implemented correctly.

#### Response to the mutation of the ISA contains subscription ID check

When an ISA is mutated, the DSS must return the identifiers for any subscription that was made to the ISA,
or be in violation of **[astm.f3411.v19.DSS0030,a](../../../../../requirements/astm/f3411/v19.md)**.

#### Subscription to an ISA has its notification index incremented after mutation check

When an ISA is mutated, the DSS must increment the notification index of any subscription to that ISA,
and return the up-to-date subscription in the response to the query mutating the ISA.

Failure to do so means that the DSS is not properly implementing **[interuss.f3411.dss_endpoints.PutISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)**.

#### Delete the ISA check

If that ISA cannot be deleted, the **[astm.f3411.v19.DSS0030,d](../../../../../requirements/astm/f3411/v19.md)** requirement to implement the ISA deletion endpoint might not be met.

#### Response to the deletion of the ISA contains subscription ID check

When an ISA is deleted, the DSS must return the identifiers for any subscription that was made to the ISA,
or be in violation of **[astm.f3411.v19.DSS0030,b](../../../../../requirements/astm/f3411/v19.md)**.

#### Subscription to an ISA has its notification index incremented after deletion check

When an ISA is deleted, the DSS must increment the notification index of any subscription to that ISA,
and return the up-to-date subscription in the response to the query deleting the ISA.

Failure to do so means that the DSS is not properly implementing **[interuss.f3411.dss_endpoints.PutISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)**.

#### Successful subscription deletion check

**[astm.f3411.v19.DSS0030,d](../../../../../requirements/astm/f3411/v19.md)** requires the implementation of the DSS endpoint to allow callers to delete subscriptions they created.
Expand Down Expand Up @@ -108,7 +141,7 @@ When a pre-existing ISA needs to be deleted to ensure a clean workspace, any sub

#### Successful subscription query check

**[astm.f3411.v19.DSS0030,f](../../../../../requirements/astm/f3411/v19.md)** requires the implementation of the DSS endpoint to allow callers to retrieve the subscriptions they created.
**[interuss.f3411.dss_endpoints.SearchSubscriptions](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires the implementation of the DSS endpoint to allow callers to retrieve the subscriptions they created.

#### Successful subscription deletion check

Expand Down
Loading

0 comments on commit 1ab70e6

Please sign in to comment.