From 5b2bdbeb134054df67dd8de62a94f178affc81c0 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Mon, 30 Oct 2023 16:20:23 +0000 Subject: [PATCH] Make aggregate scenarios normal scenarios --- .../resources/interuss/report.py | 19 ------- .../scenarios/astm/dss/crdb_access.py | 3 +- .../astm/netrid/common/aggregate_checks.py | 20 +++---- .../astm/netrid/common/dss/isa_expiry.py | 3 +- .../astm/netrid/common/dss/isa_simple.py | 3 +- .../astm/netrid/common/dss/isa_validation.py | 4 +- .../common/dss/subscription_validation.py | 3 +- .../netrid/common/dss_interoperability.py | 3 +- .../astm/netrid/common/misbehavior.py | 3 +- .../astm/netrid/common/nominal_behavior.py | 3 +- .../netrid/common/operator_interactions.py | 3 +- .../astm/netrid/v19/aggregate_checks.py | 4 +- .../astm/netrid/v22a/aggregate_checks.py | 4 +- .../scenarios/astm/utm/aggregate_checks.py | 19 +++---- .../astm/utm/dss_interoperability.py | 3 +- .../flight_intent_validation.py | 3 +- .../scenarios/astm/utm/interuss/__init__.py | 1 - .../conflict_equal_priority_not_permitted.py | 4 +- .../conflict_higher_priority.py | 4 +- .../uss_qualifier/scenarios/dev/noop.py | 3 +- .../eurocae/ed269/source_data_model.py | 3 +- .../faa/uft/message_signing_finalize.py | 3 +- .../faa/uft/message_signing_start.py | 3 +- .../flight_planning/record_planners.py | 3 +- .../scenarios/interuss/evaluation_scenario.py | 33 ------------ .../general_flight_authorization.py | 4 +- .../geospatial_feature_comprehension.py | 4 +- .../interuss/mock_uss/configure_locality.py | 3 +- .../interuss/mock_uss/unconfigure_locality.py | 3 +- .../scenarios/interuss/unit_test.py | 3 +- .../uss_qualifier/scenarios/scenario.py | 9 +++- .../uspace/flight_auth/validation.py | 3 +- .../versioning/get_system_versions.py | 3 +- .../suites/astm/netrid/f3411_19.yaml | 12 ++--- .../suites/astm/netrid/f3411_22a.yaml | 12 ++--- .../suites/astm/utm/f3548_21.yaml | 8 +-- .../uss_qualifier/suites/definitions.py | 5 +- .../suites/documentation/documentation.py | 26 --------- .../suites/interuss/dss/all_tests.yaml | 12 ++--- monitoring/uss_qualifier/suites/suite.py | 54 ++++++------------- .../definitions/TestSuiteDefinition.json | 11 ---- 41 files changed, 122 insertions(+), 207 deletions(-) delete mode 100644 monitoring/uss_qualifier/resources/interuss/report.py delete mode 100644 monitoring/uss_qualifier/scenarios/astm/utm/interuss/__init__.py delete mode 100644 monitoring/uss_qualifier/scenarios/interuss/evaluation_scenario.py diff --git a/monitoring/uss_qualifier/resources/interuss/report.py b/monitoring/uss_qualifier/resources/interuss/report.py deleted file mode 100644 index 732178fb83..0000000000 --- a/monitoring/uss_qualifier/resources/interuss/report.py +++ /dev/null @@ -1,19 +0,0 @@ -import json - -from implicitdict import ImplicitDict - -from monitoring.uss_qualifier.reports.report import TestSuiteReport -from monitoring.uss_qualifier.resources.resource import Resource - - -class TestSuiteReportResource(Resource[TestSuiteReport]): - report: TestSuiteReport - - def __init__( - self, - specification: TestSuiteReport, - ): - self.report = ImplicitDict.parse( - json.loads(json.dumps(specification)), - TestSuiteReport, - ) diff --git a/monitoring/uss_qualifier/scenarios/astm/dss/crdb_access.py b/monitoring/uss_qualifier/scenarios/astm/dss/crdb_access.py index 447ea1aac9..2ddcb48f79 100644 --- a/monitoring/uss_qualifier/scenarios/astm/dss/crdb_access.py +++ b/monitoring/uss_qualifier/scenarios/astm/dss/crdb_access.py @@ -1,11 +1,12 @@ from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class CRDBAccess(GenericTestScenario): def __init__(self): super().__init__() - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() # TODO: Implement self.end_test_scenario() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/aggregate_checks.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/aggregate_checks.py index c140345f64..b5c13acf21 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/aggregate_checks.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/aggregate_checks.py @@ -8,11 +8,7 @@ from monitoring.uss_qualifier.configurations.configuration import ParticipantID from monitoring.uss_qualifier.resources.astm.f3411 import DSSInstancesResource from monitoring.uss_qualifier.resources.astm.f3411.dss import DSSInstance -from monitoring.uss_qualifier.scenarios.interuss.evaluation_scenario import ( - ReportEvaluationScenario, -) -from monitoring.uss_qualifier.resources.interuss.report import TestSuiteReportResource from monitoring.uss_qualifier.resources.netrid import ( NetRIDServiceProviders, NetRIDObserversResource, @@ -24,8 +20,11 @@ from loguru import logger +from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext + -class AggregateChecks(ReportEvaluationScenario): +class AggregateChecks(GenericTestScenario): _rid_version: RIDVersion _service_providers: List[NetRIDServiceProvider] _observers: List[RIDSystemObserver] @@ -38,13 +37,11 @@ class AggregateChecks(ReportEvaluationScenario): def __init__( self, - report_resource: TestSuiteReportResource, service_providers: NetRIDServiceProviders, observers: NetRIDObserversResource, dss_instances: DSSInstancesResource, ): - super().__init__(report_resource) - self._queries = self.report.queries() + super().__init__() self._service_providers = service_providers.service_providers self._observers = observers.observers self._dss_instances = dss_instances.dss_instances @@ -71,6 +68,9 @@ def __init__( if dss.local_debug: self._debug_mode_usses.add(dss.participant_id) + def _init_queries(self, context: ExecutionContext): + self._queries = list(context.sibling_queries()) + # collect and classify queries by participant self._queries_by_participant = { participant: list() @@ -93,7 +93,9 @@ def __init__( participant_queries.append(query) self._queries_by_participant[query.participant_id] = participant_queries - def run(self): + def run(self, context: ExecutionContext): + self._init_queries(context) + self.begin_test_scenario() self.record_note("participants", str(self._participants_by_base_url)) diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_expiry.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_expiry.py index 0188cb2eed..df1c209d04 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_expiry.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_expiry.py @@ -12,6 +12,7 @@ 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 +from monitoring.uss_qualifier.suites.suite import ExecutionContext class ISAExpiry(GenericTestScenario): @@ -43,7 +44,7 @@ def __init__( 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): + def run(self, context: ExecutionContext): self.begin_test_scenario() self._setup_case() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_simple.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_simple.py index c1d6dc5ae1..4ac12505e8 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_simple.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_simple.py @@ -14,6 +14,7 @@ from monitoring.uss_qualifier.resources import VerticesResource from monitoring.uss_qualifier.scenarios.astm.netrid.dss_wrapper import DSSWrapper from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class ISASimple(GenericTestScenario): @@ -47,7 +48,7 @@ def __init__( v.as_s2sphere() for v in problematically_big_area.specification.vertices ] - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self._setup_case() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_validation.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_validation.py index 174ef0c357..210c97deec 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_validation.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/isa_validation.py @@ -4,6 +4,8 @@ import arrow import s2sphere + +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.astm.f3411 import v19, v22a from monitoring.monitorlib.fetch import query_and_describe @@ -69,7 +71,7 @@ def __init__( else: ValueError(f"Unsupported RID version '{self._dss.rid_version}'") - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self._setup_case() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py index fda32ab3e3..4d279a37e4 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss/subscription_validation.py @@ -21,6 +21,7 @@ from typing import Dict +from monitoring.uss_qualifier.suites.suite import ExecutionContext _24H_MIN_TOLERANCE_S = 23 * 3600 + 59 * 60 # 23 hours and 59 minutes _24H_MAX_TOLERANCE_S = 24 * 3600 + 1 # 24 hours sharp, plus a second @@ -54,7 +55,7 @@ def __init__( self._sub_id = id_generator.id_factory.make_id(self.SUB_TYPE) self._isa = isa.specification - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self._setup_case() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss_interoperability.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss_interoperability.py index e10e3bad75..a99f880147 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss_interoperability.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/dss_interoperability.py @@ -18,6 +18,7 @@ ) from monitoring.uss_qualifier.scenarios.astm.netrid.dss_wrapper import DSSWrapper from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext VERTICES: List[s2sphere.LatLng] = [ s2sphere.LatLng.from_degrees(lng=130.6205, lat=-23.6558), @@ -88,7 +89,7 @@ def _get_entities_by_prefix(self, prefix: str) -> Dict[str, TestEntity]: all_entities[entity.uuid] = entity return all_entities - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Prerequisites") diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py index f442c336c8..fac17a0464 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py @@ -31,6 +31,7 @@ VirtualObserver, ) from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class Misbehavior(GenericTestScenario): @@ -69,7 +70,7 @@ def _rid_version(self) -> RIDVersion: "Misbehavior test scenario subclass must specify _rid_version" ) - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Unauthenticated requests") diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/nominal_behavior.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/nominal_behavior.py index 3ddd6af00c..e20e3487ef 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/nominal_behavior.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/nominal_behavior.py @@ -28,6 +28,7 @@ VirtualObserver, ) from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class NominalBehavior(GenericTestScenario): @@ -61,7 +62,7 @@ def _rid_version(self) -> RIDVersion: "NominalBehavior test scenario subclass must specify _rid_version" ) - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Nominal flight") diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/operator_interactions.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/operator_interactions.py index d61199bfcc..a29155e655 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/operator_interactions.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/operator_interactions.py @@ -1,11 +1,12 @@ from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class OperatorInteractions(GenericTestScenario): def __init__(self): super().__init__() - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() # TODO: Implement self.end_test_scenario() diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/v19/aggregate_checks.py b/monitoring/uss_qualifier/scenarios/astm/netrid/v19/aggregate_checks.py index 7744c3056a..9ff9b66ec6 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/v19/aggregate_checks.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/v19/aggregate_checks.py @@ -1,6 +1,5 @@ from monitoring.monitorlib.rid import RIDVersion from monitoring.uss_qualifier.resources.astm.f3411 import DSSInstancesResource -from monitoring.uss_qualifier.resources.interuss.report import TestSuiteReportResource from monitoring.uss_qualifier.resources.netrid import ( NetRIDServiceProviders, NetRIDObserversResource, @@ -14,10 +13,9 @@ class AggregateChecks(TestScenario, CommonAggregateChecks): def __init__( self, - report_resource: TestSuiteReportResource, service_providers: NetRIDServiceProviders, observers: NetRIDObserversResource, dss_instances: DSSInstancesResource, ): - super().__init__(report_resource, service_providers, observers, dss_instances) + super().__init__(service_providers, observers, dss_instances) self._rid_version = RIDVersion.f3411_19 diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/aggregate_checks.py b/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/aggregate_checks.py index 5da19d53e4..a38e71c701 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/aggregate_checks.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/v22a/aggregate_checks.py @@ -1,6 +1,5 @@ from monitoring.monitorlib.rid import RIDVersion from monitoring.uss_qualifier.resources.astm.f3411 import DSSInstancesResource -from monitoring.uss_qualifier.resources.interuss.report import TestSuiteReportResource from monitoring.uss_qualifier.resources.netrid import ( NetRIDServiceProviders, NetRIDObserversResource, @@ -14,10 +13,9 @@ class AggregateChecks(TestScenario, CommonAggregateChecks): def __init__( self, - report_resource: TestSuiteReportResource, service_providers: NetRIDServiceProviders, observers: NetRIDObserversResource, dss_instances: DSSInstancesResource, ): - super().__init__(report_resource, service_providers, observers, dss_instances) + super().__init__(service_providers, observers, dss_instances) self._rid_version = RIDVersion.f3411_22a diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/aggregate_checks.py b/monitoring/uss_qualifier/scenarios/astm/utm/aggregate_checks.py index 218b2cbd54..dca6567f50 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/aggregate_checks.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/aggregate_checks.py @@ -5,31 +5,27 @@ from monitoring.uss_qualifier.common_data_definitions import Severity from monitoring.uss_qualifier.configurations.configuration import ParticipantID from monitoring.uss_qualifier.resources.flight_planning import FlightPlannersResource -from monitoring.uss_qualifier.scenarios.interuss.evaluation_scenario import ( - ReportEvaluationScenario, -) +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.astm.f3548.v21 import constants -from monitoring.uss_qualifier.resources.interuss.report import TestSuiteReportResource - - from monitoring.uss_qualifier.scenarios.scenario import TestScenario -class AggregateChecks(TestScenario, ReportEvaluationScenario): +class AggregateChecks(TestScenario): _queries: List[fetch.Query] _attributed_queries: Dict[ParticipantID, Dict[QueryType, List[fetch.Query]]] = {} def __init__( self, - report_resource: TestSuiteReportResource, flight_planners: FlightPlannersResource, ): - super().__init__(report_resource) + super().__init__() self.flight_planners = flight_planners - self._queries = self.report.queries() + + def _init_queries(self, context: ExecutionContext): + self._queries = list(context.sibling_queries()) # collect and classify queries by participant, only participants part of flight_planners are considered self._attributed_queries = { @@ -54,7 +50,8 @@ def __init__( query ) - def run(self): + def run(self, context: ExecutionContext): + self._init_queries(context) self.begin_test_scenario() self.record_note("all_queries", f"{len(self._queries)}") diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/dss_interoperability.py b/monitoring/uss_qualifier/scenarios/astm/utm/dss_interoperability.py index 5dab518aad..06aa4002e4 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/dss_interoperability.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/dss_interoperability.py @@ -3,6 +3,7 @@ from typing import List from urllib.parse import urlparse +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.astm.f3548.v21.api import Volume4D, Volume3D, Polygon, LatLngPoint from monitoring.uss_qualifier.common_data_definitions import Severity @@ -39,7 +40,7 @@ def __init__( if not dss.is_same_as(primary_dss_instance.dss) ] - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py b/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py index f97af01bda..c4541480df 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/flight_intent_validation/flight_intent_validation.py @@ -2,6 +2,7 @@ from monitoring.monitorlib.geotemporal import Volume4DCollection from monitoring.uss_qualifier.common_data_definitions import Severity +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.astm.f3548.v21.api import OperationalIntentState from uas_standards.astm.f3548.v21.constants import OiMaxPlanHorizonDays @@ -141,7 +142,7 @@ def __init__( f"`{self.me()}` TestScenario requirements for flight_intents not met: {e}" ) - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.record_note( "Tested USS", diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/interuss/__init__.py b/monitoring/uss_qualifier/scenarios/astm/utm/interuss/__init__.py deleted file mode 100644 index 8b13789179..0000000000 --- a/monitoring/uss_qualifier/scenarios/astm/utm/interuss/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py index 1d7dd6fdbd..06e9c7d22f 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_equal_priority_not_permitted/conflict_equal_priority_not_permitted.py @@ -1,6 +1,8 @@ from typing import Optional import arrow + +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.astm.f3548.v21.api import ( OperationalIntentReference, ) @@ -213,7 +215,7 @@ def __init__( f"`{self.me()}` TestScenario requirements for flight_intents not met: {e}" ) - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.record_note( diff --git a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py index 0aa29e08d5..5dc63a9219 100644 --- a/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py +++ b/monitoring/uss_qualifier/scenarios/astm/utm/nominal_planning/conflict_higher_priority/conflict_higher_priority.py @@ -1,6 +1,8 @@ from typing import Optional, Tuple import arrow + +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.astm.f3548.v21.api import ( OperationalIntentReference, ) @@ -192,7 +194,7 @@ def __init__( f"`{self.me()}` TestScenario requirements for flight_intents not met: {e}" ) - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.record_note( diff --git a/monitoring/uss_qualifier/scenarios/dev/noop.py b/monitoring/uss_qualifier/scenarios/dev/noop.py index 1db9077178..e938233313 100644 --- a/monitoring/uss_qualifier/scenarios/dev/noop.py +++ b/monitoring/uss_qualifier/scenarios/dev/noop.py @@ -3,6 +3,7 @@ from monitoring.uss_qualifier.resources.dev import NoOpResource from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class NoOp(TestScenario): @@ -10,7 +11,7 @@ def __init__(self, noop_config: NoOpResource): super().__init__() self.sleep_secs = noop_config.sleep_secs - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Sleep") self.begin_test_step("Sleep") diff --git a/monitoring/uss_qualifier/scenarios/eurocae/ed269/source_data_model.py b/monitoring/uss_qualifier/scenarios/eurocae/ed269/source_data_model.py index 1408a45ba9..3baa318dee 100644 --- a/monitoring/uss_qualifier/scenarios/eurocae/ed269/source_data_model.py +++ b/monitoring/uss_qualifier/scenarios/eurocae/ed269/source_data_model.py @@ -6,6 +6,7 @@ SourceDocument, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.eurocae_ed269 import UASZoneVersion @@ -23,7 +24,7 @@ def __init__(self, source_document: SourceDocument): super().__init__() self.source_document = source_document - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.record_note( diff --git a/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_finalize.py b/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_finalize.py index d819ce33fa..5e63bf8aaa 100644 --- a/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_finalize.py +++ b/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_finalize.py @@ -4,6 +4,7 @@ MockUSSClient, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class FinalizeMessageSigningReport(TestScenario): @@ -13,7 +14,7 @@ def __init__(self, mock_uss: MockUSSResource): super().__init__() self._mock_uss = mock_uss.mock_uss - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Finalize message signing") diff --git a/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_start.py b/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_start.py index 2180aadd28..7848eb70da 100644 --- a/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_start.py +++ b/monitoring/uss_qualifier/scenarios/faa/uft/message_signing_start.py @@ -4,6 +4,7 @@ MockUSSClient, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class StartMessageSigningReport(TestScenario): @@ -13,7 +14,7 @@ def __init__(self, mock_uss: MockUSSResource): super().__init__() self._mock_uss = mock_uss.mock_uss - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Start message signing") diff --git a/monitoring/uss_qualifier/scenarios/flight_planning/record_planners.py b/monitoring/uss_qualifier/scenarios/flight_planning/record_planners.py index 68c4aa2234..9578aa8eaa 100644 --- a/monitoring/uss_qualifier/scenarios/flight_planning/record_planners.py +++ b/monitoring/uss_qualifier/scenarios/flight_planning/record_planners.py @@ -1,5 +1,6 @@ from monitoring.uss_qualifier.resources.flight_planning import FlightPlannersResource from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class RecordPlanners(TestScenario): @@ -9,7 +10,7 @@ def __init__(self, flight_planners: FlightPlannersResource): super().__init__() self._flight_planners = flight_planners - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.record_note( diff --git a/monitoring/uss_qualifier/scenarios/interuss/evaluation_scenario.py b/monitoring/uss_qualifier/scenarios/interuss/evaluation_scenario.py deleted file mode 100644 index 3d4b58c01a..0000000000 --- a/monitoring/uss_qualifier/scenarios/interuss/evaluation_scenario.py +++ /dev/null @@ -1,33 +0,0 @@ -from typing import Dict - -from monitoring.uss_qualifier.reports.report import TestSuiteReport -from monitoring.uss_qualifier.resources.definitions import ResourceID -from monitoring.uss_qualifier.resources.interuss.report import TestSuiteReportResource -from monitoring.uss_qualifier.resources.resource import ResourceType -from monitoring.uss_qualifier.scenarios.scenario import ( - GenericTestScenario, -) - - -REPORT_RESOURCE_ID: ResourceID = "report_resource" - - -class ReportEvaluationScenario(GenericTestScenario): - - report: TestSuiteReport - - def __init__( - self, - report_resource: TestSuiteReportResource, - ): - super().__init__() - self.report = report_resource.report - - @staticmethod - def inject_report_resource( - resources_mapping: Dict[ResourceID, ResourceID], - resources: Dict[ResourceID, ResourceType], - report: TestSuiteReport, - ): - resources_mapping[REPORT_RESOURCE_ID] = REPORT_RESOURCE_ID - resources[REPORT_RESOURCE_ID] = TestSuiteReportResource(report) diff --git a/monitoring/uss_qualifier/scenarios/interuss/flight_authorization/general_flight_authorization.py b/monitoring/uss_qualifier/scenarios/interuss/flight_authorization/general_flight_authorization.py index 81f5fb4928..94e9b80036 100644 --- a/monitoring/uss_qualifier/scenarios/interuss/flight_authorization/general_flight_authorization.py +++ b/monitoring/uss_qualifier/scenarios/interuss/flight_authorization/general_flight_authorization.py @@ -14,7 +14,7 @@ TestCheckDocumentation, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario - +from monitoring.uss_qualifier.suites.suite import ExecutionContext _ACCEPT_CHECK_NAME = "Allowed flight" _REJECT_CHECK_NAME = "Disallowed flight" @@ -38,7 +38,7 @@ def __init__( super().__init__() self.table = table.table - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Flight planning") diff --git a/monitoring/uss_qualifier/scenarios/interuss/geospatial_map/geospatial_feature_comprehension.py b/monitoring/uss_qualifier/scenarios/interuss/geospatial_map/geospatial_feature_comprehension.py index 1ba899cd98..fe45c724ea 100644 --- a/monitoring/uss_qualifier/scenarios/interuss/geospatial_map/geospatial_feature_comprehension.py +++ b/monitoring/uss_qualifier/scenarios/interuss/geospatial_map/geospatial_feature_comprehension.py @@ -13,7 +13,7 @@ TestCheckDocumentation, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario - +from monitoring.uss_qualifier.suites.suite import ExecutionContext _BLOCK_CHECK_NAME = "Blocking geospatial features present" _ADVISE_CHECK_NAME = "Advisory geospatial features present" @@ -35,7 +35,7 @@ def __init__( super().__init__() self.table = table.table - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Map query") diff --git a/monitoring/uss_qualifier/scenarios/interuss/mock_uss/configure_locality.py b/monitoring/uss_qualifier/scenarios/interuss/mock_uss/configure_locality.py index fea51bb90c..cb52f10ea6 100644 --- a/monitoring/uss_qualifier/scenarios/interuss/mock_uss/configure_locality.py +++ b/monitoring/uss_qualifier/scenarios/interuss/mock_uss/configure_locality.py @@ -14,6 +14,7 @@ unconfigure_stack, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class ConfigureLocality(TestScenario): @@ -29,7 +30,7 @@ def __init__( self.locality_code = locality.locality_code self.to_unconfigure = [] - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Set locality") diff --git a/monitoring/uss_qualifier/scenarios/interuss/mock_uss/unconfigure_locality.py b/monitoring/uss_qualifier/scenarios/interuss/mock_uss/unconfigure_locality.py index 18ffaafb28..636b86de5a 100644 --- a/monitoring/uss_qualifier/scenarios/interuss/mock_uss/unconfigure_locality.py +++ b/monitoring/uss_qualifier/scenarios/interuss/mock_uss/unconfigure_locality.py @@ -5,6 +5,7 @@ from monitoring.uss_qualifier.common_data_definitions import Severity from monitoring.uss_qualifier.resources.interuss.mock_uss.client import MockUSSClient from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext @dataclass @@ -20,7 +21,7 @@ class MockUSSLocalityConfiguration(object): class UnconfigureLocality(TestScenario): - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() if not unconfigure_stack: diff --git a/monitoring/uss_qualifier/scenarios/interuss/unit_test.py b/monitoring/uss_qualifier/scenarios/interuss/unit_test.py index 768995e19b..a123ea8b64 100644 --- a/monitoring/uss_qualifier/scenarios/interuss/unit_test.py +++ b/monitoring/uss_qualifier/scenarios/interuss/unit_test.py @@ -1,6 +1,7 @@ from typing import Callable from monitoring.uss_qualifier.scenarios.definitions import TestScenarioDeclaration from monitoring.uss_qualifier.scenarios.scenario import GenericTestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class UnitTestScenario(GenericTestScenario): @@ -12,7 +13,7 @@ def __init__(self, step_under_test: Callable[["UnitTestScenario"], None]): ) super().__init__() - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Case under test") self.begin_test_step("Step under test") diff --git a/monitoring/uss_qualifier/scenarios/scenario.py b/monitoring/uss_qualifier/scenarios/scenario.py index a08028f000..c903e0fc0c 100644 --- a/monitoring/uss_qualifier/scenarios/scenario.py +++ b/monitoring/uss_qualifier/scenarios/scenario.py @@ -37,7 +37,6 @@ from monitoring.uss_qualifier.resources.definitions import ResourceTypeName, ResourceID from monitoring.uss_qualifier.scenarios.documentation.parsing import get_documentation - _STOP_FAST_FLAG = "USS_QUALIFIER_STOP_FAST" STOP_FAST = os.environ.get(_STOP_FAST_FLAG, "").strip().lower() == "true" @@ -229,7 +228,13 @@ def make_test_scenario( return scenario @abstractmethod - def run(self): + def run(self, context): + """Execute the test scenario. + + Args: + context: Execution context with type monitoring.uss_qualifier.suites.suite.ExecutionContext. Type hint is + not annotated because doing so would create a circular reference. + """ raise NotImplementedError( "A concrete test scenario must implement `run` method" ) diff --git a/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py b/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py index 8a362342d1..d1b4451533 100644 --- a/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py +++ b/monitoring/uss_qualifier/scenarios/uspace/flight_auth/validation.py @@ -1,6 +1,7 @@ from typing import List from monitoring.monitorlib.fetch import QueryError +from monitoring.uss_qualifier.suites.suite import ExecutionContext from uas_standards.interuss.automated_testing.scd.v1.api import ( InjectFlightResponseResult, ) @@ -67,7 +68,7 @@ def __init__( f"`{self.me()}` TestScenario requires all flight intents except the last to have invalid flight authorisation data. Instead, intent {fID} had valid flight authorisation data." ) - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.record_note("Planner", self.ussp.participant_id) diff --git a/monitoring/uss_qualifier/scenarios/versioning/get_system_versions.py b/monitoring/uss_qualifier/scenarios/versioning/get_system_versions.py index 0d2b7d3636..e5837da030 100644 --- a/monitoring/uss_qualifier/scenarios/versioning/get_system_versions.py +++ b/monitoring/uss_qualifier/scenarios/versioning/get_system_versions.py @@ -5,6 +5,7 @@ VersionProvidersResource, ) from monitoring.uss_qualifier.scenarios.scenario import TestScenario +from monitoring.uss_qualifier.suites.suite import ExecutionContext class GetSystemVersions(TestScenario): @@ -17,7 +18,7 @@ def __init__( self._version_providers = version_providers.version_providers self._system_identity = system_identity.system_identity - def run(self): + def run(self, context: ExecutionContext): self.begin_test_scenario() self.begin_test_case("Get versions") self.begin_test_step("Get versions") diff --git a/monitoring/uss_qualifier/suites/astm/netrid/f3411_19.yaml b/monitoring/uss_qualifier/suites/astm/netrid/f3411_19.yaml index 2e754ecdd7..8c2d0cfc19 100644 --- a/monitoring/uss_qualifier/suites/astm/netrid/f3411_19.yaml +++ b/monitoring/uss_qualifier/suites/astm/netrid/f3411_19.yaml @@ -52,12 +52,12 @@ actions: scenario_type: scenarios.astm.netrid.v19.OperatorInteractions resources: {} on_failure: Continue -report_evaluation_scenario: - scenario_type: scenarios.astm.netrid.v19.AggregateChecks - resources: - service_providers: service_providers - observers: observers - dss_instances: dss_instances + - test_scenario: + scenario_type: scenarios.astm.netrid.v19.AggregateChecks + resources: + service_providers: service_providers + observers: observers + dss_instances: dss_instances participant_verifiable_capabilities: - id: service_provider name: NetRID Service Provider diff --git a/monitoring/uss_qualifier/suites/astm/netrid/f3411_22a.yaml b/monitoring/uss_qualifier/suites/astm/netrid/f3411_22a.yaml index b651bbd8c8..b9147b79d5 100644 --- a/monitoring/uss_qualifier/suites/astm/netrid/f3411_22a.yaml +++ b/monitoring/uss_qualifier/suites/astm/netrid/f3411_22a.yaml @@ -52,12 +52,12 @@ actions: scenario_type: scenarios.astm.netrid.v22a.OperatorInteractions resources: {} on_failure: Continue -report_evaluation_scenario: - scenario_type: scenarios.astm.netrid.v22a.AggregateChecks - resources: - service_providers: service_providers - observers: observers - dss_instances: dss_instances + - test_scenario: + scenario_type: scenarios.astm.netrid.v22a.AggregateChecks + resources: + service_providers: service_providers + observers: observers + dss_instances: dss_instances participant_verifiable_capabilities: - id: service_provider name: NetRID Service Provider diff --git a/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml b/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml index 41dbededa3..18bd252b7b 100644 --- a/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml +++ b/monitoring/uss_qualifier/suites/astm/utm/f3548_21.yaml @@ -91,10 +91,10 @@ actions: - uss1 - uss2 on_failure: Continue -report_evaluation_scenario: - scenario_type: scenarios.astm.utm.AggregateChecks - resources: - flight_planners: flight_planners +- test_scenario: + scenario_type: scenarios.astm.utm.AggregateChecks + resources: + flight_planners: flight_planners participant_verifiable_capabilities: - id: scd name: Strategic Conflict Detection diff --git a/monitoring/uss_qualifier/suites/definitions.py b/monitoring/uss_qualifier/suites/definitions.py index f96c39d4c9..dd98ee1ca6 100644 --- a/monitoring/uss_qualifier/suites/definitions.py +++ b/monitoring/uss_qualifier/suites/definitions.py @@ -1,4 +1,6 @@ from __future__ import annotations + +from abc import ABC, abstractmethod from enum import Enum from typing import Dict, List, Optional @@ -150,9 +152,6 @@ class TestSuiteDefinition(ImplicitDict): actions: List[TestSuiteActionDeclaration] """The actions to take when running the test suite. Components will be executed in order.""" - report_evaluation_scenario: Optional[TestScenarioDeclaration] - """The scenario executed after all the actions that evaluates the test suite report. Must be a ReportEvaluationScenario.""" - participant_verifiable_capabilities: Optional[List[ParticipantCapabilityDefinition]] """Definitions of capabilities verified by this test suite for individual participants.""" diff --git a/monitoring/uss_qualifier/suites/documentation/documentation.py b/monitoring/uss_qualifier/suites/documentation/documentation.py index ad5fce1e7e..d20647e36e 100644 --- a/monitoring/uss_qualifier/suites/documentation/documentation.py +++ b/monitoring/uss_qualifier/suites/documentation/documentation.py @@ -115,23 +115,6 @@ def make_test_suite_documentation( ), ) ) - if ( - "report_evaluation_scenario" in suite_def - and suite_def.report_evaluation_scenario - ): - lines.extend( - _render_scenario( - suite_def.report_evaluation_scenario.scenario_type, - TestSuiteRenderContext( - parent_yaml_file=suite_yaml_file, - parent_doc_file=suite_doc_file, - base_path=base_path, - list_index=i + 2, - indent=0, - test_suites=test_suites, - ), - ) - ) lines.append("") lines.append( @@ -355,15 +338,6 @@ def combine(new_reqs: Dict[RequirementID, RequirementInSuite]) -> None: for action in suite_def.actions: combine(_collect_requirements_from_action(action)) - if ( - "report_evaluation_scenario" in suite_def - and suite_def.report_evaluation_scenario - ): - combine( - _collect_requirements_from_scenario( - suite_def.report_evaluation_scenario.scenario_type - ) - ) return reqs diff --git a/monitoring/uss_qualifier/suites/interuss/dss/all_tests.yaml b/monitoring/uss_qualifier/suites/interuss/dss/all_tests.yaml index e12522e2b6..58e634fdc2 100644 --- a/monitoring/uss_qualifier/suites/interuss/dss/all_tests.yaml +++ b/monitoring/uss_qualifier/suites/interuss/dss/all_tests.yaml @@ -49,9 +49,9 @@ actions: dss_instance_id: dss on_failure: Continue # TODO: enable usage of aggregate checks when there are no service providers or observers -#report_evaluation_scenario: -# scenario_type: scenarios.astm.netrid.v19.AggregateChecks -# resources: -# service_providers: service_providers -# observers: observers -# dss_instances: dss_instances +#- test_scenario: +# scenario_type: scenarios.astm.netrid.v19.AggregateChecks +# resources: +# service_providers: service_providers +# observers: observers +# dss_instances: dss_instances diff --git a/monitoring/uss_qualifier/suites/suite.py b/monitoring/uss_qualifier/suites/suite.py index af6726b941..e6dcca1705 100644 --- a/monitoring/uss_qualifier/suites/suite.py +++ b/monitoring/uss_qualifier/suites/suite.py @@ -9,11 +9,12 @@ import arrow -from implicitdict import StringBasedDateTime, ImplicitDict +from implicitdict import StringBasedDateTime from loguru import logger import yaml from monitoring.monitorlib.dicts import JSONAddress +from monitoring.monitorlib.fetch import Query from monitoring.monitorlib.inspection import fullname from monitoring.monitorlib.versioning import repo_url_of from monitoring.uss_qualifier.action_generators.action_generator import ( @@ -24,16 +25,11 @@ from monitoring.uss_qualifier.configurations.configuration import ( ExecutionConfiguration, TestSuiteActionSelectionCondition, - AncestorSelectionCondition, - NthInstanceCondition, ) from monitoring.uss_qualifier.fileio import resolve_filename from monitoring.uss_qualifier.reports.capabilities import ( evaluate_condition_for_test_suite, ) -from monitoring.uss_qualifier.scenarios.interuss.evaluation_scenario import ( - ReportEvaluationScenario, -) from monitoring.uss_qualifier.reports.report import ( ActionGeneratorReport, TestScenarioReport, @@ -128,7 +124,9 @@ def run(self, context: ExecutionContext) -> TestSuiteActionReport: report = TestSuiteActionReport(skipped_action=skip_report) else: if self.test_scenario: - report = TestSuiteActionReport(test_scenario=self._run_test_scenario()) + report = TestSuiteActionReport( + test_scenario=self._run_test_scenario(context) + ) elif self.test_suite: report = TestSuiteActionReport(test_suite=self._run_test_suite(context)) elif self.action_generator: @@ -142,14 +140,14 @@ def run(self, context: ExecutionContext) -> TestSuiteActionReport: context.end_action(self, report) return report - def _run_test_scenario(self) -> TestScenarioReport: + def _run_test_scenario(self, context: ExecutionContext) -> TestScenarioReport: scenario = self.test_scenario logger.info(f'Running "{scenario.documentation.name}" scenario...') scenario.on_failed_check = _print_failed_check try: try: - scenario.run() + scenario.run(context) except (ScenarioCannotContinueError, TestRunCannotContinueError): pass scenario.go_to_cleanup() @@ -270,31 +268,6 @@ def __init__( ) self.actions = actions - def _make_report_evaluation_action( - self, report: TestSuiteReport - ) -> TestSuiteAction: - """Create the action wrapping the ReportEvaluationScenario and inject the required resources.""" - - ReportEvaluationScenario.inject_report_resource( - self.definition.report_evaluation_scenario.resources, - self.local_resources, - report, - ) - action_declaration = ImplicitDict.parse( - dict( - test_scenario=self.definition.report_evaluation_scenario, - ), - TestSuiteActionDeclaration, - ) - action = TestSuiteAction( - action=action_declaration, resources=self.local_resources - ) - if not issubclass(action.test_scenario.__class__, ReportEvaluationScenario): - raise ValueError( - f"Scenario type {action.test_scenario.__class__} is not a subclass of the ReportEvaluationScenario base class" - ) - return action - def run(self, context: ExecutionContext) -> TestSuiteReport: report = TestSuiteReport( name=self.definition.name, @@ -308,9 +281,6 @@ def run(self, context: ExecutionContext) -> TestSuiteReport: def actions() -> Iterator[Union[TestSuiteAction, SkippedActionReport]]: for a in self.actions: yield a - # Execute report evaluation scenario as last action if specified, otherwise break loop - if self.definition.has_field_with_value("report_evaluation_scenario"): - yield self._make_report_evaluation_action(report) _run_actions(actions(), context, report) @@ -379,6 +349,7 @@ class ActionStackFrame(object): action: TestSuiteAction parent: Optional[ActionStackFrame] children: List[ActionStackFrame] + report: Optional[TestSuiteActionReport] = None def address(self) -> JSONAddress: if self.action.test_scenario is not None: @@ -417,6 +388,14 @@ def __init__(self, config: Optional[ExecutionConfiguration]): self.top_frame = None self.current_frame = None + def sibling_queries(self) -> Iterator[Query]: + if self.current_frame.parent is None: + return + for child in self.current_frame.parent.children: + if child.report is not None: + for q in child.report.queries(): + yield q + def _compute_n_of( self, target: TestSuiteAction, condition: TestSuiteActionSelectionCondition ) -> int: @@ -595,4 +574,5 @@ def end_action( raise RuntimeError( f"Action {self.current_frame.action.declaration.get_action_type()} {self.current_frame.action.declaration.get_child_type()} was started, but a different action {action.declaration.get_action_type()} {action.declaration.get_child_type()} was ended" ) + self.current_frame.report = report self.current_frame = self.current_frame.parent diff --git a/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDefinition.json b/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDefinition.json index 070c94d92e..1ae7cf9c82 100644 --- a/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDefinition.json +++ b/schemas/monitoring/uss_qualifier/suites/definitions/TestSuiteDefinition.json @@ -44,17 +44,6 @@ "null" ] }, - "report_evaluation_scenario": { - "description": "The scenario executed after all the actions that evaluates the test suite report. Must be a ReportEvaluationScenario.", - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "../../scenarios/definitions/TestScenarioDeclaration.json" - } - ] - }, "resources": { "additionalProperties": { "type": "string"