-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[uss_qualifier] DSS0030 migrate isa expiry check from prober
- Loading branch information
Showing
17 changed files
with
394 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_expiry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import datetime | ||
import time | ||
from typing import Optional | ||
|
||
import arrow | ||
|
||
from monitoring.prober.infrastructure import register_resource_type | ||
from monitoring.uss_qualifier.common_data_definitions import Severity | ||
from monitoring.uss_qualifier.resources.astm.f3411.dss import DSSInstanceResource | ||
from monitoring.uss_qualifier.resources.interuss.id_generator import IDGeneratorResource | ||
from monitoring.uss_qualifier.resources.netrid.service_area import ServiceAreaResource | ||
from monitoring.uss_qualifier.scenarios.astm.netrid.common.dss import utils | ||
from monitoring.uss_qualifier.scenarios.astm.netrid.dss_wrapper import DSSWrapper | ||
from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario | ||
|
||
|
||
class ISAExpiry(GenericTestScenario): | ||
"""Based on test_isa_expiry.py from the legacy prober tool.""" | ||
|
||
ISA_TYPE = register_resource_type(369, "ISA") | ||
|
||
_create_isa_path: str | ||
|
||
_write_scope: str | ||
|
||
def __init__( | ||
self, | ||
dss: DSSInstanceResource, | ||
id_generator: IDGeneratorResource, | ||
isa: ServiceAreaResource, | ||
): | ||
super().__init__() | ||
self._dss = ( | ||
dss.dss_instance | ||
) # TODO: delete once _delete_isa_if_exists updated to use dss_wrapper | ||
self._dss_wrapper = DSSWrapper(self, dss.dss_instance) | ||
self._isa_id = id_generator.id_factory.make_id(ISAExpiry.ISA_TYPE) | ||
self._isa_version: Optional[str] = None | ||
self._isa = isa.specification | ||
|
||
now = arrow.utcnow().datetime | ||
self._isa_start_time = self._isa.shifted_time_start(now) | ||
self._isa_end_time = self._isa.shifted_time_end(now) | ||
self._isa_area = [vertex.as_s2sphere() for vertex in self._isa.footprint] | ||
|
||
def run(self): | ||
self.begin_test_scenario() | ||
|
||
self._setup_case() | ||
|
||
self.begin_test_case("ISA Expiry") | ||
self.begin_test_step("ISA Expiry") | ||
|
||
self._check_expiry_behaviors() | ||
|
||
self.end_test_step() | ||
self.end_test_case() | ||
self.end_test_scenario() | ||
|
||
def _check_expiry_behaviors(self): | ||
""" | ||
Once an ISA is expired, it may still be queried directly using its ID, | ||
but it should not appear in searches anymore. | ||
""" | ||
|
||
start_time = datetime.datetime.utcnow() | ||
end_time = start_time + datetime.timedelta(seconds=5) | ||
|
||
# Create a short-lived ISA of a few seconds | ||
with self.check("Create short-lived ISA", [self._dss.participant_id]) as check: | ||
created_isa = self._dss_wrapper.put_isa_expect_response_code( | ||
check=check, | ||
expected_error_codes={200}, | ||
area_vertices=self._isa_area, | ||
alt_lo=self._isa.altitude_min, | ||
alt_hi=self._isa.altitude_max, | ||
start_time=start_time, | ||
end_time=end_time, | ||
uss_base_url=self._isa.base_url, | ||
isa_id=self._isa_id, | ||
isa_version=None, | ||
) | ||
|
||
# Wait for it to expire | ||
time.sleep(5) | ||
|
||
# Search for ISAs: we should not find the expired one | ||
with self.check( | ||
"Expired ISAs are not part of search results", [self._dss.participant_id] | ||
) as check: | ||
isas = self._dss_wrapper.search_isas_expect_response_code( | ||
main_check=check, | ||
expected_error_codes={200}, | ||
area=self._isa_area, | ||
) | ||
if self._isa_id in isas.isas.keys(): | ||
check.record_failed( | ||
summary=f"Expired ISA {self._isa_id} found in search results", | ||
severity=Severity.Medium, | ||
participants=[self._dss.participant_id], | ||
details=f"Searched for area {self._isa_area} with unspecified end and start time.", | ||
query_timestamps=[ | ||
created_isa.dss_query.query.request.timestamp, | ||
isas.query.request.timestamp, | ||
], | ||
) | ||
|
||
with self.check( | ||
"An expired ISA can be queried by its ID", [self._dss.participant_id] | ||
) as check: | ||
self._dss_wrapper.get_isa(check, self._isa_id) | ||
|
||
def _setup_case(self): | ||
self.begin_test_case("Setup") | ||
|
||
def _ensure_clean_workspace_step(): | ||
self.begin_test_step("Ensure clean workspace") | ||
|
||
self._delete_isa_if_exists() | ||
|
||
self.end_test_step() | ||
|
||
_ensure_clean_workspace_step() | ||
|
||
self.end_test_case() | ||
|
||
def _delete_isa_if_exists(self): | ||
utils.delete_isa_if_exists( | ||
self, | ||
isa_id=self._isa_id, | ||
rid_version=self._dss.rid_version, | ||
session=self._dss.client, | ||
participant_id=self._dss_wrapper.participant_id, | ||
) | ||
|
||
def cleanup(self): | ||
self.begin_cleanup() | ||
|
||
self._delete_isa_if_exists() | ||
|
||
self.end_cleanup() |
1 change: 1 addition & 0 deletions
1
monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .isa_simple import ISASimple | ||
from .isa_validation import ISAValidation | ||
from .isa_expiry import ISAExpiry | ||
from .subscription_validation import SubscriptionValidation | ||
from .crdb_access import CRDBAccess |
73 changes: 73 additions & 0 deletions
73
monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/isa_expiry.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# ASTM NetRID DSS: ISA Expiry test scenario | ||
|
||
## Overview | ||
|
||
Perform basic operations on a single DSS instance in order to verify that it handles ISA expiry correctly. | ||
|
||
## Resources | ||
|
||
### dss | ||
|
||
[`DSSInstanceResource`](../../../../../resources/astm/f3411/dss.py) to be tested in this scenario. | ||
|
||
### id_generator | ||
|
||
[`IDGeneratorResource`](../../../../../resources/interuss/id_generator.py) providing the ISA ID for this scenario. | ||
|
||
### isa | ||
|
||
[`ServiceAreaResource`](../../../../../resources/netrid/service_area.py) describing an ISA to be created. | ||
|
||
## Setup test case | ||
|
||
### Ensure clean workspace test step | ||
|
||
This scenario creates an ISA with a known ID. This step ensures that the ISA does not exist when the main part of the test starts. | ||
|
||
#### Successful ISA query check | ||
|
||
**[interuss.f3411.dss_endpoints.GetISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires the implementation of the DSS endpoint enabling retrieval of information about a specific ISA; if the individual ISA cannot be retrieved and the error isn't a 404, then this requirement isn't met. | ||
|
||
#### Removed pre-existing ISA check | ||
|
||
If an ISA with the intended ID is already present in the DSS, it needs to be removed before proceeding with the test. If that ISA cannot be deleted, then the **[astm.f3411.v19.DSS0030,b](../../../../../requirements/astm/f3411/v19.md)** requirement to implement the ISA deletion endpoint might not be met. | ||
|
||
#### Notified subscriber check | ||
|
||
When a pre-existing ISA needs to be deleted to ensure a clean workspace, any subscribers to ISAs in that area must be notified (as specified by the DSS). If a notification cannot be delivered, then the **[astm.f3411.v19.NET0730](../../../../../requirements/astm/f3411/v19.md)** requirement to implement the POST ISAs endpoint isn't met. | ||
|
||
## ISA Expiry test case | ||
|
||
This test case creates an ISA with a short lifetime and verifies that it is not returned in search results after it expires. | ||
|
||
### ISA Expiry test step | ||
|
||
#### Create short-lived ISA check | ||
|
||
Not allowing an ISA to be created violates **[astm.f3411.v19.DSS0030,a](../../../../../requirements/astm/f3411/v19.md)** | ||
|
||
#### An expired ISA can be queried by its ID check | ||
|
||
**[interuss.f3411.dss_endpoints.GetISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires that | ||
an ISA be returned in all cases when it is queried directly, even if it expired. | ||
|
||
#### Expired ISAs are not part of search results check | ||
|
||
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires | ||
that ISAs that are in the searched area but have expired should not be returned. | ||
|
||
## Cleanup | ||
|
||
The cleanup phase of this test scenario attempts to remove the ISA if the test ended prematurely. | ||
|
||
### Successful ISA query check | ||
|
||
**[interuss.f3411.dss_endpoints.GetISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires the implementation of the DSS endpoint enabling retrieval of information about a specific ISA; if the individual ISA cannot be retrieved and the error isn't a 404, then this requirement isn't met. | ||
|
||
### Removed pre-existing ISA check | ||
|
||
If an ISA with the intended ID is still present in the DSS, it needs to be removed before exiting the test. If that ISA cannot be deleted, then the **[astm.f3411.v19.DSS0030,b](../../../../../requirements/astm/f3411/v19.md)** requirement to implement the ISA deletion endpoint might not be met. | ||
|
||
### Notified subscriber check | ||
|
||
When an ISA is deleted, subscribers must be notified. If a subscriber cannot be notified, that subscriber USS did not correctly implement "POST Identification Service Area" in **[astm.f3411.v19.NET0730](../../../../../requirements/astm/f3411/v19.md)**. |
8 changes: 8 additions & 0 deletions
8
monitoring/uss_qualifier/scenarios/astm/netrid/v19/dss/isa_expiry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from monitoring.uss_qualifier.scenarios.astm.netrid.common.dss.isa_expiry import ( | ||
ISAExpiry as CommonISAExpiry, | ||
) | ||
from monitoring.uss_qualifier.scenarios.scenario import TestScenario | ||
|
||
|
||
class ISAExpiry(TestScenario, CommonISAExpiry): | ||
pass |
1 change: 1 addition & 0 deletions
1
monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from .isa_simple import ISASimple | ||
from .isa_validation import ISAValidation | ||
from .isa_expiry import ISAExpiry | ||
from .subscription_validation import SubscriptionValidation | ||
from .crdb_access import CRDBAccess |
73 changes: 73 additions & 0 deletions
73
monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/isa_expiry.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# ASTM NetRID DSS: ISA Expiry test scenario | ||
|
||
## Overview | ||
|
||
Perform basic operations on a single DSS instance in order to verify that it handles ISA expiry correctly. | ||
|
||
## Resources | ||
|
||
### dss | ||
|
||
[`DSSInstanceResource`](../../../../../resources/astm/f3411/dss.py) to be tested in this scenario. | ||
|
||
### id_generator | ||
|
||
[`IDGeneratorResource`](../../../../../resources/interuss/id_generator.py) providing the ISA ID for this scenario. | ||
|
||
### isa | ||
|
||
[`ServiceAreaResource`](../../../../../resources/netrid/service_area.py) describing an ISA to be created. | ||
|
||
## Setup test case | ||
|
||
### Ensure clean workspace test step | ||
|
||
This scenario creates an ISA with a known ID. This step ensures that the ISA does not exist when the main part of the test starts. | ||
|
||
#### Successful ISA query check | ||
|
||
**[interuss.f3411.dss_endpoints.GetISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires the implementation of the DSS endpoint enabling retrieval of information about a specific ISA; if the individual ISA cannot be retrieved and the error isn't a 404, then this requirement isn't met. | ||
|
||
#### Removed pre-existing ISA check | ||
|
||
If an ISA with the intended ID is already present in the DSS, it needs to be removed before proceeding with the test. If that ISA cannot be deleted, then the **[astm.f3411.v22a.DSS0030,b](../../../../../requirements/astm/f3411/v22a.md)** requirement to implement the ISA deletion endpoint might not be met. | ||
|
||
#### Notified subscriber check | ||
|
||
When a pre-existing ISA needs to be deleted to ensure a clean workspace, any subscribers to ISAs in that area must be notified (as specified by the DSS). If a notification cannot be delivered, then the **[astm.f3411.v22a.NET0730](../../../../../requirements/astm/f3411/v22a.md)** requirement to implement the POST ISAs endpoint isn't met. | ||
|
||
## ISA Expiry test case | ||
|
||
This test case creates an ISA with a short lifetime and verifies that it is not returned in search results after it expires. | ||
|
||
### ISA Expiry test step | ||
|
||
#### Create short-lived ISA check | ||
|
||
Not allowing an ISA to be created violates **[astm.f3411.v22a.DSS0030,a](../../../../../requirements/astm/f3411/v22a.md)** | ||
|
||
#### An expired ISA can be queried by its ID check | ||
|
||
**[interuss.f3411.dss_endpoints.GetISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires that | ||
an ISA be returned in all cases when it is queried directly, even if it expired. | ||
|
||
#### Expired ISAs are not part of search results check | ||
|
||
**[interuss.f3411.dss_endpoints.SearchISAs](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires | ||
that ISAs that are in the searched area but have expired should not be returned. | ||
|
||
## Cleanup | ||
|
||
The cleanup phase of this test scenario attempts to remove the ISA if the test ended prematurely. | ||
|
||
### Successful ISA query check | ||
|
||
**[interuss.f3411.dss_endpoints.GetISA](../../../../../requirements/interuss/f3411/dss_endpoints.md)** requires the implementation of the DSS endpoint enabling retrieval of information about a specific ISA; if the individual ISA cannot be retrieved and the error isn't a 404, then this requirement isn't met. | ||
|
||
### Removed pre-existing ISA check | ||
|
||
If an ISA with the intended ID is still present in the DSS, it needs to be removed before exiting the test. If that ISA cannot be deleted, then the **[astm.f3411.v22a.DSS0030](../../../../../requirements/astm/f3411/v22a.md)** requirement to implement the ISA deletion endpoint might not be met. | ||
|
||
### Notified subscriber check | ||
|
||
When an ISA is deleted, subscribers must be notified. If a subscriber cannot be notified, that subscriber USS did not correctly implement "POST Identification Service Area" in **[astm.f3411.v22a.NET0730](../../../../../requirements/astm/f3411/v22a.md)**. |
8 changes: 8 additions & 0 deletions
8
monitoring/uss_qualifier/scenarios/astm/netrid/v22a/dss/isa_expiry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from monitoring.uss_qualifier.scenarios.astm.netrid.common.dss.isa_expiry import ( | ||
ISAExpiry as CommonISAExpiry, | ||
) | ||
from monitoring.uss_qualifier.scenarios.scenario import TestScenario | ||
|
||
|
||
class ISAExpiry(TestScenario, CommonISAExpiry): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.