Skip to content

Commit

Permalink
[uss_qualifier] Add PrepareFlightPlanners scenario (#331)
Browse files Browse the repository at this point in the history
* Add PrepareFlightPlanners scenarios

* Fix hygiene

* Fix check links
  • Loading branch information
BenjaminPelletier authored Nov 9, 2023
1 parent ceb1916 commit cf21826
Show file tree
Hide file tree
Showing 18 changed files with 453 additions and 32 deletions.
2 changes: 1 addition & 1 deletion monitoring/mock_uss/flight_planning/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def flight_planning_v1_clear_area() -> Tuple[str, int]:
resp = api.ClearAreaResponse(
outcome=api.ClearAreaOutcome(
success=clear_resp.success,
message="See `details`",
message="See `details` field in response for more information",
details=clear_resp,
)
)
Expand Down
2 changes: 1 addition & 1 deletion monitoring/mock_uss/scd_injection/routes_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def scdsc_clear_area() -> Tuple[str, int]:
resp = scd_api.ClearAreaResponse(
outcome=ClearAreaOutcome(
success=clear_resp.success,
message="See `details` field for more information",
message="See `details` field in response for more information",
timestamp=StringBasedDateTime(datetime.utcnow()),
),
)
Expand Down
2 changes: 1 addition & 1 deletion monitoring/monitorlib/clients/flight_planning/client_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ def clear_area(self, area: Volume4D) -> TestPreparationActivityResponse:
if resp.outcome.success:
errors = None
else:
errors = [f"[{resp.outcome.timestamp}]: {resp.outcome.message}"]
errors = [resp.outcome.message]

return TestPreparationActivityResponse(errors=errors, queries=[query])
10 changes: 8 additions & 2 deletions monitoring/monitorlib/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@ def get_module_object_by_name(parent_module, object_name: str):
def fullname(class_type: Type) -> str:
module = class_type.__module__
if module == "builtins":
return class_type.__qualname__ # avoid outputs like 'builtins.str'
return module + "." + class_type.__qualname__
if hasattr(class_type, "__qualname__"):
return class_type.__qualname__ # avoid outputs like 'builtins.str'
else:
return str(class_type)
if hasattr(class_type, "__qualname__"):
return module + "." + class_type.__qualname__
else:
return str(class_type)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ When a USS implements the [InterUSS flight_planning automated testing API](https

A USS must implement the endpoints defined in the API, accept requests in the data format prescribed in the API, and respond in the data format prescribed in the API. If there is a problem using the API such as a connection error, invalid response code, or invalid data, the USS will have failed to meet this requirement.

### <tt>Readiness</tt>

A USS must implement the readiness endpoint defined in the API and then respond that it is ready to respond with an appropriate API version.

### <tt>ClearArea</tt>

In order to conduct automated tests effectively, the USS must remove all of their existing flights from a particular area when instructed by the test director. This is not an action performed on behalf of an emulated user, but rather an action performed in any way appropriate to support automated testing -- therefore, fulfilling this request may cause actions on the implementing USS's system that no normal user would be able to perform.
Expand Down
1 change: 1 addition & 0 deletions monitoring/uss_qualifier/scenarios/astm/utm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
)
from .dss_interoperability import DSSInteroperability
from .aggregate_checks import AggregateChecks
from .prep_planners import PrepareFlightPlanners
69 changes: 69 additions & 0 deletions monitoring/uss_qualifier/scenarios/astm/utm/prep_planners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# ASTM F3548 flight planners preparation test scenario

## Description

This scenario prepares flight planner systems for execution of controlled test scenarios by checking planner systems' readiness and having them remove any existing flights that may already be in the test area.

## Resources

### flight_planners

FlightPlannersResource listing all USSs undergoing planning tests so that they can be checked for readiness and instructed to remove any existing flights from the area in this scenario.

### dss

DSSInstanceResource to check for lingering operational intents after the area has been cleared.

### flight_intents

FlightIntentsResource containing flight intents that will be used in subsequent tests, so all planners should be instructed to clear any area involved with any of these intents of flights it manages.

### flight_intents2

(Optional) If more than one FlightIntentsResource will be used in subsequent tests, additional intents may be specified with this resource.

### flight_intents3

(Optional) If more than one FlightIntentsResource will be used in subsequent tests, additional intents may be specified with this resource.

### flight_intents4

(Optional) If more than one FlightIntentsResource will be used in subsequent tests, additional intents may be specified with this resource.

## Preparation test case

### Check for flight planning readiness test step

All USSs are queried for their readiness to ensure later tests can proceed.

#### ⚠️ Valid response to readiness query check

**[interuss.automated_testing.flight_planning.ImplementAPI](../../../requirements/interuss/automated_testing/flight_planning.md)**

#### ⚠️ Flight planning USS ready check

This readiness indicates the USS's ability to inject test data, so if this check fails, not only has the USS not met **[interuss.automated_testing.flight_planning.Readiness](../../../requirements/interuss/automated_testing/flight_planning.md)**, but it also does not meet **[astm.f3548.v21.GEN0310](../../../requirements/astm/f3548/v21.md)**.

### Area clearing test step

All USSs are requested to remove all flights from the area under test.

#### ⚠️ Valid response to clearing query check

**[interuss.automated_testing.flight_planning.ImplementAPI](../../../requirements/interuss/automated_testing/flight_planning.md)**

#### ⚠️ Area cleared successfully check

**[interuss.automated_testing.flight_planning.ClearArea](../../../requirements/interuss/automated_testing/flight_planning.md)**

### Clear area validation test step

uss_qualifier verifies with the DSS that there are no operational intents remaining in the area

#### 🛑 DSS responses check

**[astm.f3548.v21.DSS0005](../../../requirements/astm/f3548/v21.md)**

#### 🛑 Area is clear check

If operational intents remain in the 4D area(s) following the preceding area clearing, then the current state of the test environment is not suitable to conduct tests so this check will fail.
88 changes: 88 additions & 0 deletions monitoring/uss_qualifier/scenarios/astm/utm/prep_planners.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from typing import Optional

from monitoring.uss_qualifier.common_data_definitions import Severity
from monitoring.uss_qualifier.resources.astm.f3548.v21 import DSSInstanceResource
from monitoring.uss_qualifier.resources.astm.f3548.v21.dss import DSSInstance
from monitoring.uss_qualifier.resources.flight_planning import (
FlightPlannersResource,
FlightIntentsResource,
)
from monitoring.uss_qualifier.scenarios.flight_planning.prep_planners import (
PrepareFlightPlanners as GenericPrepareFlightPlanners,
)


class PrepareFlightPlanners(GenericPrepareFlightPlanners):
dss: DSSInstance

def __init__(
self,
flight_planners: FlightPlannersResource,
dss: DSSInstanceResource,
flight_intents: FlightIntentsResource,
flight_intents2: Optional[FlightIntentsResource] = None,
flight_intents3: Optional[FlightIntentsResource] = None,
flight_intents4: Optional[FlightIntentsResource] = None,
):
super(PrepareFlightPlanners, self).__init__(
flight_planners,
flight_intents,
flight_intents2,
flight_intents3,
flight_intents4,
)
self.dss = dss.dss

def run(self, context):
self.begin_test_scenario(context)
self.begin_test_case("Preparation")

self.begin_test_step("Check for flight planning readiness")
self._check_readiness()
self.end_test_step()

self.begin_test_step("Area clearing")
self._clear_area()
self.end_test_step()

self.begin_test_step("Clear area validation")
self._validate_clear_area()
self.end_test_step()

self.end_test_case()
self.end_test_scenario()

def _validate_clear_area(self):
for area in self.areas:
with self.check("DSS responses", [self.dss.participant_id]) as check:
try:
op_intents, query = self.dss.find_op_intent(area.to_f3548v21())
except ValueError as e:
check.record_failed(
summary="Error parsing DSS response",
details=str(e),
severity=Severity.High,
)
self.record_query(query)
if op_intents is None:
check.record_failed(
summary="Error querying DSS for operational intents",
details="See query",
severity=Severity.High,
query_timestamps=[query.request.timestamp],
)
with self.check("Area is clear") as check:
if op_intents:
summary = f"{len(op_intents)} operational intent{'s' if len(op_intents) > 1 else ''} found in cleared area"
details = (
"The following operational intents were observed even after clearing the area:\n"
+ "\n".join(
f"* {oi.id} managed by {oi.manager}" for oi in op_intents
)
)
check.record_failed(
summary=summary,
details=details,
severity=Severity.High,
query_timestamps=[query.request.timestamp],
)
7 changes: 6 additions & 1 deletion monitoring/uss_qualifier/scenarios/documentation/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ def _get_anchors(
anchors = {}

if isinstance(value, marko.block.Heading):
base_anchor = "#" + text_of(value).lower().replace(" ", "-")
heading_text = text_of(value)
for s in Severity:
if heading_text.startswith(s.symbol):
heading_text = heading_text[len(s.symbol) :].lstrip()
break
base_anchor = "#" + heading_text.lower().replace(" ", "-")
if base_anchor not in header_counts:
anchors[value] = base_anchor
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .record_planners import RecordPlanners
from .prep_planners import PrepareFlightPlanners
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generic flight planners preparation test scenario

## Description

This scenario prepares flight planner systems for execution of controlled test scenarios by checking planner systems' readiness and having them remove any existing flights that may already be in the test area.

## Resources

### flight_planners

FlightPlannersResource listing all USSs undergoing planning tests so that they can be checked for readiness and instructed to remove any existing flights from the area in this scenario.

### flight_intents

FlightIntentsResource containing flight intents that will be used in subsequent tests, so all planners should be instructed to clear any area involved with any of these intents of flights it manages.

### flight_intents2

(Optional) If more than one FlightIntentsResource will be used in subsequent tests, additional intents may be specified with this resource.

### flight_intents3

(Optional) If more than one FlightIntentsResource will be used in subsequent tests, additional intents may be specified with this resource.

### flight_intents4

(Optional) If more than one FlightIntentsResource will be used in subsequent tests, additional intents may be specified with this resource.

## Preparation test case

### Check for flight planning readiness test step

All USSs are queried for their readiness to ensure later tests can proceed.

#### ⚠️ Valid response to readiness query check

**[interuss.automated_testing.flight_planning.ImplementAPI](../../requirements/interuss/automated_testing/flight_planning.md)**

#### ⚠️ Flight planning USS ready check

**[interuss.automated_testing.flight_planning.Readiness](../../requirements/interuss/automated_testing/flight_planning.md)**

### Area clearing test step

All USSs are requested to remove all flights from the area under test.

#### ⚠️ Valid response to clearing query check

**[interuss.automated_testing.flight_planning.ImplementAPI](../../requirements/interuss/automated_testing/flight_planning.md)**

#### ⚠️ Area cleared successfully check

**[interuss.automated_testing.flight_planning.ClearArea](../../requirements/interuss/automated_testing/flight_planning.md)**
Loading

0 comments on commit cf21826

Please sign in to comment.