async def run(servers, tests, quic_log=False, secrets_log_file=None) -> None: for server in servers: if server.structured_logging: server.result |= Result.L for test_name, test_func in tests: print("\n=== %s %s ===\n" % (server.name, test_name)) configuration = QuicConfiguration( alpn_protocols=H3_ALPN + H0_ALPN, is_client=True, quic_logger=QuicDirectoryLogger(quic_log) if quic_log else QuicLogger(), secrets_log_file=secrets_log_file, verify_mode=server.verify_mode, ) if test_name == "test_throughput": timeout = 120 else: timeout = 10 try: await asyncio.wait_for( test_func(server, configuration), timeout=timeout ) except Exception as exc: print(exc) print("") print_result(server) # print summary if len(servers) > 1: print("SUMMARY") for server in servers: print_result(server)
help="increase logging verbosity") args = parser.parse_args() logging.basicConfig( format="%(asctime)s %(levelname)s %(name)s %(message)s", level=logging.DEBUG if args.verbose else logging.INFO, ) # import ASGI application module_str, attr_str = args.app.split(":", maxsplit=1) module = importlib.import_module(module_str) application = getattr(module, attr_str) # create QUIC logger if args.quic_log: quic_logger = QuicDirectoryLogger(args.quic_log) else: quic_logger = None # open SSL log file if args.secrets_log: secrets_log_file = open(args.secrets_log, "a") else: secrets_log_file = None configuration = QuicConfiguration( alpn_protocols=H3_ALPN + H0_ALPN + ["siduck"], is_client=False, max_datagram_frame_size=65536, quic_logger=quic_logger, secrets_log_file=secrets_log_file,
is_client=True, alpn_protocols=H0_ALPN if args.legacy_http else H3_ALPN) if args.ca_certs: configuration.load_verify_locations(args.ca_certs) if args.cipher_suites: configuration.cipher_suites = [ CipherSuite[s] for s in args.cipher_suites.split(",") ] if args.insecure: configuration.verify_mode = ssl.CERT_NONE if args.max_data: configuration.max_data = args.max_data if args.max_stream_data: configuration.max_stream_data = args.max_stream_data if args.quic_log: configuration.quic_logger = QuicDirectoryLogger(args.quic_log) if args.secrets_log: configuration.secrets_log_file = open(args.secrets_log, "a") if args.session_ticket: try: with open(args.session_ticket, "rb") as fp: configuration.session_ticket = pickle.load(fp) except FileNotFoundError: pass if uvloop is not None: uvloop.install() loop = asyncio.get_event_loop() loop.run_until_complete( run( configuration=configuration,