diff --git a/restler-quick-start.py b/restler-quick-start.py old mode 100644 new mode 100755 index f7040cb7..d9b1f72e --- a/restler-quick-start.py +++ b/restler-quick-start.py @@ -42,9 +42,11 @@ def compile_spec(api_spec_path, restler_dll_path): print(f"command: {command}") subprocess.run(command, shell=True) -def add_common_settings(ip, port, host, use_ssl, command): +def add_common_settings(ip, port, host, use_ssl, use_http2, command): if not use_ssl: command = f"{command} --no_ssl" + if use_http2 is not None: + command = f"{command} --http2" if ip is not None: command = f"{command} --target_ip {ip}" if port is not None: @@ -53,18 +55,18 @@ def add_common_settings(ip, port, host, use_ssl, command): command = f"{command} --host {host}" return command -def replay_bug(ip, port, host, use_ssl, restler_dll_path, replay_log): +def replay_bug(ip, port, host, use_ssl, use_http2, restler_dll_path, replay_log): """ Runs RESTler's replay mode on the specified replay file """ with usedir(RESTLER_TEMP_DIR): command = ( f"dotnet \"{restler_dll_path}\" replay --replay_log \"{replay_log}\"" ) - command = add_common_settings(ip, port, host, use_ssl, command) + command = add_common_settings(ip, port, host, use_ssl, use_http2, command) print(f"command: {command}\n") subprocess.run(command, shell=True) -def replay_from_dir(ip, port, host, use_ssl, restler_dll_path, replay_dir): +def replay_from_dir(ip, port, host, use_ssl, use_http2, restler_dll_path, replay_dir): import glob from pathlib import Path # get all the 500 replay files in the bug buckets directory @@ -74,10 +76,10 @@ def replay_from_dir(ip, port, host, use_ssl, restler_dll_path, replay_dir): if "bug_buckets" in os.path.basename(file_path): continue print(f"Testing replay file: {file_path}") - replay_bug(ip, port, host, use_ssl, restler_dll_path, Path(file_path).absolute()) + replay_bug(ip, port, host, use_ssl, use_http2, restler_dll_path, Path(file_path).absolute()) pass -def test_spec(ip, port, host, use_ssl, restler_dll_path, task): +def test_spec(ip, port, host, use_ssl, use_http2, restler_dll_path, task): """ Runs RESTler's test mode on a specified Compile directory @param ip: The IP of the service to test @@ -88,6 +90,8 @@ def test_spec(ip, port, host, use_ssl, restler_dll_path, task): @type host: Str @param use_ssl: If False, set the --no_ssl parameter when executing RESTler @type use_ssl: Boolean + @param use_http2: If True, set the --http2 parameter when executing RESTler + @type use_http2: Boolean @param restler_dll_path: The absolute path to the RESTler driver's dll @type restler_dll_path: Str @@ -107,7 +111,7 @@ def test_spec(ip, port, host, use_ssl, restler_dll_path, task): f" --settings \"{settings_file_path}\"" ) print(f"command: {command}\n") - command = add_common_settings(ip, port, host, use_ssl, command) + command = add_common_settings(ip, port, host, use_ssl, use_http2, command) subprocess.run(command, shell=True) @@ -129,6 +133,9 @@ def test_spec(ip, port, host, use_ssl, restler_dll_path, task): parser.add_argument('--use_ssl', help='Set this flag if you want to use SSL validation for the socket', action='store_true') + parser.add_argument('--use_http2', + help='Set this flag if you want to use HTTP2', + action='store_true') parser.add_argument('--host', help='The hostname of the service to test', type=str, required=False, default=None) @@ -146,13 +153,13 @@ def test_spec(ip, port, host, use_ssl, restler_dll_path, task): print(f"\nrestler_dll_path: {restler_dll_path}\n") if args.task == "replay": - replay_from_dir(args.ip, args.port, args.host, args.use_ssl, restler_dll_path.absolute(), args.replay_bug_buckets_dir) + replay_from_dir(args.ip, args.port, args.host, args.use_ssl, args.use_http2, restler_dll_path.absolute(), args.replay_bug_buckets_dir) else: if args.api_spec_path is None: print("api_spec_path is required for all tasks except the replay task.") exit(-1) api_spec_path = os.path.abspath(args.api_spec_path) compile_spec(api_spec_path, restler_dll_path.absolute()) - test_spec(args.ip, args.port, args.host, args.use_ssl, restler_dll_path.absolute(), args.task) + test_spec(args.ip, args.port, args.host, args.use_ssl, args.use_http2, restler_dll_path.absolute(), args.task) print(f"Test complete.\nSee {os.path.abspath(RESTLER_TEMP_DIR)} for results.")