From aae25e24432f733ed4c5f90287845af0113775ee Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Sat, 9 Oct 2021 19:18:03 +0200 Subject: [PATCH] address review comments for #27622 (#27659) --- test/cpp/qps/json_run_localhost_scenario_gen.py | 2 +- test/cpp/qps/qps_json_driver_scenario_gen.py | 2 +- test/cpp/qps/scenario_generator_helper.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/cpp/qps/json_run_localhost_scenario_gen.py b/test/cpp/qps/json_run_localhost_scenario_gen.py index 0b0f1058a19..c7c5028f5a0 100755 --- a/test/cpp/qps/json_run_localhost_scenario_gen.py +++ b/test/cpp/qps/json_run_localhost_scenario_gen.py @@ -17,7 +17,7 @@ import os import sys -script_dir = os.path.dirname(sys.argv[0]) +script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(script_dir) import scenario_generator_helper as gen diff --git a/test/cpp/qps/qps_json_driver_scenario_gen.py b/test/cpp/qps/qps_json_driver_scenario_gen.py index 43a40b3845e..76bff59f2c8 100755 --- a/test/cpp/qps/qps_json_driver_scenario_gen.py +++ b/test/cpp/qps/qps_json_driver_scenario_gen.py @@ -17,7 +17,7 @@ import os import sys -script_dir = os.path.dirname(sys.argv[0]) +script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(script_dir) import scenario_generator_helper as gen diff --git a/test/cpp/qps/scenario_generator_helper.py b/test/cpp/qps/scenario_generator_helper.py index 9c6db78ecf5..40e4f85ebc7 100755 --- a/test/cpp/qps/scenario_generator_helper.py +++ b/test/cpp/qps/scenario_generator_helper.py @@ -45,6 +45,7 @@ _COPYRIGHT = """# Copyright 2021 The gRPC Authors def _mutate_scenario(scenario_json): + """Modifies vanilla benchmark scenario config to make it more suitable for running as a unit test.""" # tweak parameters to get fast test times scenario_json = dict(scenario_json) scenario_json['warmup_seconds'] = 0 @@ -53,11 +54,11 @@ def _mutate_scenario(scenario_json): if scenario_json['client_config'][ 'client_type'] == 'SYNC_CLIENT' or scenario_json['server_config'][ 'server_type'] == 'SYNC_SERVER': + # reduce the number of threads needed for scenarios that use synchronous API outstanding_rpcs_divisor = 10 scenario_json['client_config']['outstanding_rpcs_per_channel'] = max( - 1, - int(scenario_json['client_config']['outstanding_rpcs_per_channel'] / - outstanding_rpcs_divisor)) + 1, scenario_json['client_config']['outstanding_rpcs_per_channel'] // + outstanding_rpcs_divisor) return scenario_config.remove_nonproto_fields(scenario_json)