def run_rid_tests(test_configuration: RIDQualifierTestConfiguration, auth_spec: str, flight_records: List[FullFlightRecord]) -> reports.Report: my_test_builder = TestBuilder(test_configuration=test_configuration, flight_records=flight_records) test_payloads = my_test_builder.build_test_payloads() test_id = str(uuid.uuid4()) report = reports.Report(setup=reports.Setup(configuration=test_configuration)) # Inject flights into all USSs injected_flights = [] for i, target in enumerate(test_configuration.injection_targets): uss_injection_harness = TestHarness( auth_spec=auth_spec, injection_base_url=target.injection_base_url) uss_injection_harness.submit_test(test_payloads[i], test_id, report.setup) for flight in test_payloads[i].requested_flights: injected_flights.append(InjectedFlight(uss=target, flight=flight)) # Create observers observers: List[display_data_evaluator.RIDSystemObserver] = [] for observer_config in test_configuration.observers: observer = display_data_evaluator.RIDSystemObserver( observer_config.name, DSSTestSession( observer_config.observation_base_url, make_auth_adapter(auth_spec))) observers.append(observer) # Evaluate observed RID system states display_data_evaluator.evaluate_system( injected_flights, observers, test_configuration.evaluation, report.findings) with open('../report.json', 'w') as f: json.dump(report, f) return report
def from_arguments(cls, args: argparse.Namespace): adapter: auth.AuthAdapter = auth.make_auth_adapter(args.auth) dss_client = infrastructure.DSSTestSession(args.dss, adapter) area: s2sphere.LatLngRect = geo.make_latlng_rect(args.area) start_time = datetime.datetime.fromisoformat(args.start_time) end_time = start_time + datetime.timedelta(hours=args.trace_hours) logger = tracerlog.Logger( args.output_folder) if args.output_folder else None return ResourceSet(dss_client, area, logger, start_time, end_time)
def __init__(self, name: str, config: InjectionTargetConfiguration, auth_spec: str): self.name = name self.config = config self.client = infrastructure.DSSTestSession( self.config.injection_base_url, auth.make_auth_adapter(auth_spec)) # Flights injected by this target. # Key: flight name # Value: flight id self.created_flight_ids: Dict[str, str] = {}
def main() -> int: args = parseArgs() adapter = auth.make_auth_adapter(args.auth) dss_clients: Dict[str, infrastructure.DSSTestSession] = {} for dss in args.DSS: dss_clients[dss] = infrastructure.DSSTestSession(dss, adapter) # Begin Tests tests = InterOpTestSuite(dss_clients) tests.startTest() return os.EX_OK
def make_session(pytestconfig, endpoint_suffix: str, auth_option: Optional[str] = None) -> Optional[DSSTestSession]: dss_endpoint = pytestconfig.getoption('dss_endpoint') if dss_endpoint is None: pytest.skip('dss-endpoint option not set') auth_adapter = None if auth_option: auth_spec = pytestconfig.getoption(auth_option) if not auth_spec: pytest.skip('%s option not set' % auth_option) auth_adapter = auth.make_auth_adapter(auth_spec) s = DSSTestSession(dss_endpoint + endpoint_suffix, auth_adapter) return s
def from_arguments(cls, args: argparse.Namespace): adapter: auth.AuthAdapter = auth.make_auth_adapter(args.auth) dss_client = infrastructure.DSSTestSession(args.dss, adapter) area: s2sphere.LatLngRect = geo.make_latlng_rect(args.area) start_time = datetime.datetime.fromisoformat(args.start_time) end_time = start_time + datetime.timedelta(hours=args.trace_hours) if args.kml_server and args.kml_folder is None: raise ValueError( 'If --kml-server is specified, --kml-folder must also be specified' ) kml_session = infrastructure.KMLGenerationSession( args.kml_server, args.kml_folder) if args.kml_server else None logger = tracerlog.Logger(args.output_folder, kml_session) if args.output_folder else None return ResourceSet(dss_client, area, logger, start_time, end_time)
def __init__(self, *args, **kwargs): super(USS, self).__init__(*args, **kwargs) auth_spec = os.environ.get("AUTH_SPEC") oauth_adapter = auth.make_auth_adapter( auth_spec) if auth_spec else None self.client = DSSClient(self.host, oauth_adapter) self.client._locust_environment = self.environment if not auth_spec: # logging after creation of client so that we surface the error in the UI e = Exception( "Missing AUTH_SPEC environment variable, please check README") self.client.log_exception("Initialization", "Create DSS Client", time.time(), e) # raising exception to not allow things to proceed further raise e # This is a load tester its acceptable to have all the scopes required to operate anything. # We are not testing if the scope is incorrect. We are testing if it can handle the load. self.client.default_scopes = [rid.SCOPE_WRITE, rid.SCOPE_READ]
from monitoring.monitorlib import auth, infrastructure from monitoring.mock_uss import webapp from . import config utm_client = infrastructure.DSSTestSession( webapp.config[config.KEY_DSS_URL], auth.make_auth_adapter(webapp.config[config.KEY_AUTH_SPEC]))
def get_access_token(spec: str, scopes: str, audience: str): adapter = auth.make_auth_adapter(spec) return adapter.issue_token(audience, scopes.split(' '))
def __init__(self, auth_spec:str, injection_base_url:str): auth_adapter = make_auth_adapter(auth_spec) self._base_url = injection_base_url self.uss_session = DSSTestSession(injection_base_url, auth_adapter)
from monitoring.monitorlib import auth, infrastructure from monitoring.mock_ridsp import webapp from . import config dss_client = infrastructure.DSSTestSession( webapp.config.get(config.KEY_DSS_URL), auth.make_auth_adapter(webapp.config.get(config.KEY_AUTH_SPEC)))