diff --git a/monitoring/monitorlib/fetch/__init__.py b/monitoring/monitorlib/fetch/__init__.py index 320c74a99c..b4f361ed59 100644 --- a/monitoring/monitorlib/fetch/__init__.py +++ b/monitoring/monitorlib/fetch/__init__.py @@ -2,20 +2,19 @@ import json import os import uuid -import jwt -from typing import Dict, Optional, List, Union - from enum import Enum +from typing import Dict, Optional, List, Union from urllib.parse import urlparse import flask -from loguru import logger +import jwt import requests import urllib3 import yaml +from implicitdict import ImplicitDict, StringBasedDateTime +from loguru import logger from yaml.representer import Representer -from implicitdict import ImplicitDict, StringBasedDateTime from monitoring.monitorlib import infrastructure from monitoring.monitorlib.errors import stacktrace_string from monitoring.monitorlib.rid import RIDVersion @@ -180,8 +179,8 @@ def describe_flask_response(resp: flask.Response, elapsed_s: float): class QueryType(str, Enum): - # ASTM F3411-19 and F3411-22a (RID) + # DSS endpoints F3411v19DSSSearchIdentificationServiceAreas = ( "astm.f3411.v19.dss.searchIdentificationServiceAreas" ) @@ -217,9 +216,6 @@ class QueryType(str, Enum): "astm.f3411.v22a.dss.deleteIdentificationServiceArea" ) - F3411v19DSSSearchFlights = "astm.f3411.v19.dss.searchFlights" - F3411v22aDSSSearchFlights = "astm.f3411.v22a.dss.searchFlights" - F3411v19DSSSearchSubscriptions = "astm.f3411.v19.dss.searchSubscriptions" F3411v22aDSSSearchSubscriptions = "astm.f3411.v22a.dss.searchSubscriptions" @@ -235,6 +231,10 @@ class QueryType(str, Enum): F3411v19DSSDeleteSubscription = "astm.f3411.v19.dss.deleteSubscription" F3411v22aDSSDeleteSubscription = "astm.f3411.v22a.dss.deleteSubscription" + # USS endpoints + F3411v19USSSearchFlights = "astm.f3411.v19.uss.searchFlights" + F3411v22aUSSSearchFlights = "astm.f3411.v22a.uss.searchFlights" + F3411v19USSPostIdentificationServiceArea = ( "astm.f3411.v19.uss.postIdentificationServiceArea" ) @@ -242,19 +242,8 @@ class QueryType(str, Enum): "astm.f3411.v22a.uss.postIdentificationServiceArea" ) - # Flight injection (test harness) - - F3411v19USSCreateTest = "rid.f3411.v19.sp.createTest" - F3411v22aUSSCreateTest = "rid.f3411.v22a.sp.createTest" - - F3411v19USSDeleteTest = "rid.f3411.v19.sp.deleteTest" - F3411v22aUSSDeleteTest = "rid.f3411.v22a.sp.deleteTest" - - # RID flight details endpoint that a USS provides (!= DSS) - F3411v22aUSSGetDisplayData = "rid.f3411.v22a.sp.getDisplayData" - F3411v19USSGetDisplayData = "rid.f3411.v19.sp.getDisplayData" - F3411v22aUSSGetFlightDetails = "rid.f3411.v22a.sp.getDetails" - F3411v19USSGetFlightDetails = "rid.f3411.v19.sp.getDetails" + F3411v22aUSSGetFlightDetails = "astm.f3411.v22a.uss.getFlightDetails" + F3411v19USSGetFlightDetails = "astm.f3411.v19.uss.getFlightDetails" # ASTM F3548-21 F3548v21DSSQueryOperationalIntentReferences = ( @@ -333,18 +322,18 @@ class QueryType(str, Enum): "interuss.automated_testing.rid.v1.observation.getDetails" ) + # Flight injection (test harness) + InterussRIDAutomatedTestingV1CreateTest = ( + "interuss.automated_testing.rid.v1.injection.createTest" + ) + + InterussRIDAutomatedTestingV1DeleteTest = ( + "interuss.automated_testing.rid.v1.injection.deleteTest" + ) + def __str__(self): return self.value - @staticmethod - def flight_details(rid_version: RIDVersion): - if rid_version == RIDVersion.f3411_19: - return QueryType.F3411v19USSGetFlightDetails - elif rid_version == RIDVersion.f3411_22a: - return QueryType.F3411v22aUSSGetFlightDetails - else: - raise ValueError(f"Unsupported RID version: {rid_version}") - @staticmethod def dss_get_isa(rid_version: RIDVersion): if rid_version == RIDVersion.f3411_19: @@ -381,24 +370,6 @@ def dss_delete_isa(rid_version: RIDVersion): else: raise ValueError(f"Unsupported RID version: {rid_version}") - @staticmethod - def sp_create_test(rid_version: RIDVersion): - if rid_version == RIDVersion.f3411_19: - return QueryType.F3411v19USSCreateTest - elif rid_version == RIDVersion.f3411_22a: - return QueryType.F3411v22aUSSCreateTest - else: - raise ValueError(f"Unsupported RID version: {rid_version}") - - @staticmethod - def sp_delete_test(rid_version: RIDVersion): - if rid_version == RIDVersion.f3411_19: - return QueryType.F3411v19USSDeleteTest - elif rid_version == RIDVersion.f3411_22a: - return QueryType.F3411v22aUSSDeleteTest - else: - raise ValueError(f"Unsupported RID version: {rid_version}") - class Query(ImplicitDict): request: RequestDescription diff --git a/monitoring/monitorlib/fetch/rid.py b/monitoring/monitorlib/fetch/rid.py index 7e5f0cfdb7..c6bcebc4fc 100644 --- a/monitoring/monitorlib/fetch/rid.py +++ b/monitoring/monitorlib/fetch/rid.py @@ -687,14 +687,6 @@ def set_participant_id(self, participant_id: str) -> None: else: raise NotImplementedError(f"Cannot set participant_id") - def set_query_type(self, query_type: QueryType) -> None: - if self.v19_query is not None: - self.v19_query.query_type = query_type - elif self.v22a_query is not None: - self.v22a_query.query_type = query_type - else: - raise NotImplementedError(f"Cannot set query_type") - class FetchedISA(RIDQuery): """Version-independent representation of an ISA read from the DSS.""" @@ -1035,7 +1027,7 @@ def uss_flights( else "false", }, scope=v19.constants.Scope.Read, - query_type=QueryType.F3411v19USSGetDisplayData, + query_type=QueryType.F3411v19USSSearchFlights, participant_id=participant_id, ) return FetchedUSSFlights(v19_query=query) @@ -1056,7 +1048,7 @@ def uss_flights( flights_url, params=params, scope=v22a.constants.Scope.DisplayProvider, - query_type=QueryType.F3411v22aUSSGetDisplayData, + query_type=QueryType.F3411v19USSSearchFlights, participant_id=participant_id, ) return FetchedUSSFlights(v22a_query=query) diff --git a/monitoring/uss_qualifier/resources/netrid/observers.py b/monitoring/uss_qualifier/resources/netrid/observers.py index 3af6851d6b..8b8e94ee44 100644 --- a/monitoring/uss_qualifier/resources/netrid/observers.py +++ b/monitoring/uss_qualifier/resources/netrid/observers.py @@ -35,7 +35,7 @@ def __init__( self.local_debug = local_debug def observe_system( - self, rect: s2sphere.LatLngRect, rid_version: RIDVersion + self, rect: s2sphere.LatLngRect ) -> Tuple[Optional[observation_api.GetDisplayDataResponse], fetch.Query]: url = "/display_data?view={},{},{},{}".format( rect.lo().lat().degrees, @@ -49,7 +49,7 @@ def observe_system( url, scope=Scope.Observe, participant_id=self.participant_id, - query_type=QueryType.flight_details(rid_version), + query_type=QueryType.InterUSSRIDObservationV1GetDisplayData, ) try: result = ( @@ -65,7 +65,7 @@ def observe_system( return result, query def observe_flight_details( - self, flight_id: str, rid_version: RIDVersion + self, flight_id: str ) -> Tuple[Optional[observation_api.GetDetailsResponse], fetch.Query]: query = fetch.query_and_describe( self.session, @@ -77,7 +77,6 @@ def observe_flight_details( ) # Record query metadata for later use in the aggregate checks query.participant_id = self.participant_id - query.query_type = QueryType.flight_details(rid_version) try: result = ( ImplicitDict.parse( diff --git a/monitoring/uss_qualifier/resources/netrid/service_providers.py b/monitoring/uss_qualifier/resources/netrid/service_providers.py index eceeb57458..00239979f0 100644 --- a/monitoring/uss_qualifier/resources/netrid/service_providers.py +++ b/monitoring/uss_qualifier/resources/netrid/service_providers.py @@ -60,9 +60,7 @@ def __init__( ) self.local_debug = local_debug - def submit_test( - self, request: CreateTestParameters, test_id: str, rid_version: RIDVersion - ) -> fetch.Query: + def submit_test(self, request: CreateTestParameters, test_id: str) -> fetch.Query: return fetch.query_and_describe( self.injection_client, "PUT", @@ -70,19 +68,17 @@ def submit_test( json=request, scope=SCOPE_RID_QUALIFIER_INJECT, participant_id=self.participant_id, - query_type=fetch.QueryType.sp_create_test(rid_version), + query_type=fetch.QueryType.InterussRIDAutomatedTestingV1CreateTest, ) - def delete_test( - self, test_id: str, version: str, rid_version: RIDVersion - ) -> fetch.Query: + def delete_test(self, test_id: str, version: str) -> fetch.Query: return fetch.query_and_describe( self.injection_client, "DELETE", url=f"/tests/{test_id}/{version}", scope=SCOPE_RID_QUALIFIER_INJECT, participant_id=self.participant_id, - query_type=fetch.QueryType.sp_delete_test(rid_version), + query_type=fetch.QueryType.InterussRIDAutomatedTestingV1DeleteTest, ) 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 b77831ca3a..a8269fd87b 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/aggregate_checks.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/aggregate_checks.py @@ -210,10 +210,7 @@ def _dp_display_data_details_times_step(self): if ( query.status_code == 200 and query.has_field_with_value("query_type") - and ( - query.query_type == QueryType.F3411v19USSGetFlightDetails - or query.query_type == QueryType.F3411v22aUSSGetFlightDetails - ) + and query.query_type == QueryType.InterUSSRIDObservationV1GetDetails ): relevant_queries.append(query) @@ -257,8 +254,8 @@ def _sp_flights_area_times_step(self): for query in all_queries: if query.has_field_with_value("query_type") and ( # TODO find a cleaner way than checking for version here - query.query_type == QueryType.F3411v19USSGetDisplayData - or query.query_type == QueryType.F3411v22aUSSGetDisplayData + query.query_type == QueryType.F3411v19USSSearchFlights + or query.query_type == QueryType.F3411v22aUSSSearchFlights ): relevant_queries.append(query) 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 4bedae5672..d78c2f1a61 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 @@ -247,17 +247,12 @@ def _isa_missing_outline(self, create_isa_url: str, json_body: Dict[str, Any]): url=create_isa_url, scope=self.write_scope, json=payload, + query_type=QueryType.dss_create_isa(self._dss.rid_version), ) if self._dss.rid_version == RIDVersion.f3411_19: rid_query = ChangedISA(v19_query=q) - rid_query.set_query_type( - QueryType.F3411v19DSSCreateIdentificationServiceArea - ) elif self._dss.rid_version == RIDVersion.f3411_22a: rid_query = ChangedISA(v22a_query=q) - rid_query.set_query_type( - QueryType.F3411v22aDSSCreateIdentificationServiceArea - ) else: raise ValueError(f"Unknown RID version: {self._dss.rid_version}") @@ -287,17 +282,12 @@ def _isa_missing_volume(self, create_isa_url: str, json_body: Dict[str, Any]): url=create_isa_url, scope=self.write_scope, json=payload, + query_type=QueryType.dss_create_isa(self._dss.rid_version), ) if self._dss.rid_version == RIDVersion.f3411_19: rid_query = ChangedISA(v19_query=q) - rid_query.set_query_type( - QueryType.F3411v19DSSCreateIdentificationServiceArea - ) elif self._dss.rid_version == RIDVersion.f3411_22a: rid_query = ChangedISA(v22a_query=q) - rid_query.set_query_type( - QueryType.F3411v22aDSSCreateIdentificationServiceArea - ) else: raise ValueError(f"Unknown RID version: {self._dss.rid_version}") @@ -324,17 +314,12 @@ def _isa_missing_extents(self, create_isa_url: str, json_body: Dict[str, Any]): url=create_isa_url, scope=self.write_scope, json=payload, + query_type=QueryType.dss_create_isa(self._dss.rid_version), ) if self._dss.rid_version == RIDVersion.f3411_19: rid_query = ChangedISA(v19_query=q) - rid_query.set_query_type( - QueryType.F3411v19DSSCreateIdentificationServiceArea - ) elif self._dss.rid_version == RIDVersion.f3411_22a: rid_query = ChangedISA(v22a_query=q) - rid_query.set_query_type( - QueryType.F3411v22aDSSCreateIdentificationServiceArea - ) else: raise ValueError(f"Unknown RID version: {self._dss.rid_version}") diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py b/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py index 618565ead9..2dd5744fc5 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/misbehavior.py @@ -89,7 +89,7 @@ def run(self, context: ExecutionContext): def _inject_flights(self): (self._injected_flights, self._injected_tests) = injection.inject_flights( - self, self._flights_data, self._service_providers, self._rid_version + self, self._flights_data, self._service_providers ) def _poll_unauthenticated_during_flights(self): @@ -238,9 +238,7 @@ def cleanup(self): sp = matching_sps[0] check = self.check("Successful test deletion", [sp.participant_id]) try: - query = sp.delete_test( - injected_test.test_id, injected_test.version, self._rid_version - ) + query = sp.delete_test(injected_test.test_id, injected_test.version) self.record_query(query) if query.status_code != 200: raise ValueError( 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 83bbde32d5..d98e120c2a 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/common/nominal_behavior.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/common/nominal_behavior.py @@ -77,7 +77,7 @@ def run(self, context: ExecutionContext): def _inject_flights(self): (self._injected_flights, self._injected_tests) = injection.inject_flights( - self, self._flights_data, self._service_providers, self._rid_version + self, self._flights_data, self._service_providers ) def _poll_during_flights(self): @@ -128,9 +128,7 @@ def cleanup(self): sp = matching_sps[0] check = self.check("Successful test deletion", [sp.participant_id]) try: - query = sp.delete_test( - injected_test.test_id, injected_test.version, self._rid_version - ) + query = sp.delete_test(injected_test.test_id, injected_test.version) self.record_query(query) if query.status_code != 200: raise ValueError( diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py b/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py index 1ab50c776a..f1795ceea7 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/display_data_evaluator.py @@ -258,7 +258,7 @@ def evaluate_system_instantaneously( if perform_observation: self._test_scenario.begin_test_step("Observer polling") for observer in observers: - (observation, query) = observer.observe_system(rect, self._rid_version) + (observation, query) = observer.observe_system(rect) self._test_scenario.record_query(query) self._evaluate_observation( observer, diff --git a/monitoring/uss_qualifier/scenarios/astm/netrid/injection.py b/monitoring/uss_qualifier/scenarios/astm/netrid/injection.py index afdb61ba51..ba55748db7 100644 --- a/monitoring/uss_qualifier/scenarios/astm/netrid/injection.py +++ b/monitoring/uss_qualifier/scenarios/astm/netrid/injection.py @@ -37,7 +37,6 @@ def inject_flights( test_scenario: TestScenario, flights_data_res: FlightDataResource, service_providers_res: NetRIDServiceProviders, - rid_version: RIDVersion, ) -> Tuple[List[InjectedFlight], List[InjectedTest]]: test_id = str(uuid.uuid4()) test_flights = flights_data_res.get_test_flights() @@ -55,7 +54,7 @@ def inject_flights( with test_scenario.check( "Successful injection", [target.participant_id] ) as check: - query = target.submit_test(p, test_id, rid_version) + query = target.submit_test(p, test_id) test_scenario.record_query(query) if query.status_code != 200: diff --git a/monitoring/uss_qualifier/scenarios/scenario.py b/monitoring/uss_qualifier/scenarios/scenario.py index ee09d44b48..6d676ad539 100644 --- a/monitoring/uss_qualifier/scenarios/scenario.py +++ b/monitoring/uss_qualifier/scenarios/scenario.py @@ -43,8 +43,8 @@ QueryType.F3411v19USSPostIdentificationServiceArea, QueryType.F3411v22aUSSPostIdentificationServiceArea, # When querying for display data and flight details, we don't always know the participant ID - QueryType.F3411v19USSGetDisplayData, - QueryType.F3411v22aUSSGetDisplayData, + QueryType.InterUSSRIDObservationV1GetDisplayData, + QueryType.InterUSSRIDObservationV1GetDetails, QueryType.F3411v19USSGetFlightDetails, QueryType.F3411v22aUSSGetFlightDetails, ] diff --git a/schemas/monitoring/monitorlib/fetch/Query.json b/schemas/monitoring/monitorlib/fetch/Query.json index e98ef0b1a1..f7a739fc76 100644 --- a/schemas/monitoring/monitorlib/fetch/Query.json +++ b/schemas/monitoring/monitorlib/fetch/Query.json @@ -27,8 +27,6 @@ "astm.f3411.v22a.dss.updateIdentificationServiceArea", "astm.f3411.v19.dss.deleteIdentificationServiceArea", "astm.f3411.v22a.dss.deleteIdentificationServiceArea", - "astm.f3411.v19.dss.searchFlights", - "astm.f3411.v22a.dss.searchFlights", "astm.f3411.v19.dss.searchSubscriptions", "astm.f3411.v22a.dss.searchSubscriptions", "astm.f3411.v19.dss.getSubscription", @@ -39,16 +37,12 @@ "astm.f3411.v22a.dss.updateSubscription", "astm.f3411.v19.dss.deleteSubscription", "astm.f3411.v22a.dss.deleteSubscription", + "astm.f3411.v19.uss.searchFlights", + "astm.f3411.v22a.uss.searchFlights", "astm.f3411.v19.uss.postIdentificationServiceArea", "astm.f3411.v22a.uss.postIdentificationServiceArea", - "rid.f3411.v19.sp.createTest", - "rid.f3411.v22a.sp.createTest", - "rid.f3411.v19.sp.deleteTest", - "rid.f3411.v22a.sp.deleteTest", - "rid.f3411.v22a.sp.getDisplayData", - "rid.f3411.v19.sp.getDisplayData", - "rid.f3411.v22a.sp.getDetails", - "rid.f3411.v19.sp.getDetails", + "astm.f3411.v22a.uss.getFlightDetails", + "astm.f3411.v19.uss.getFlightDetails", "astm.f3548.v21.dss.queryOperationalIntentReferences", "astm.f3548.v21.dss.getOperationalIntentReference", "astm.f3548.v21.dss.createOperationalIntentReference", @@ -79,7 +73,9 @@ "interuss.automated_testing.flight_planning.v1.UpsertFlightPlan", "interuss.automated_testing.flight_planning.v1.DeleteFlightPlan", "interuss.automated_testing.rid.v1.observation.getDisplayData", - "interuss.automated_testing.rid.v1.observation.getDetails" + "interuss.automated_testing.rid.v1.observation.getDetails", + "interuss.automated_testing.rid.v1.injection.createTest", + "interuss.automated_testing.rid.v1.injection.deleteTest" ], "type": [ "string",