From e9fdf6a31796217c1c5f27afaa11d6495e17f30d Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Wed, 23 Aug 2023 15:09:38 +0200 Subject: [PATCH] fixed review comments --- .../layer_tests_summary/run_conformance.py | 18 ++++++------- .../layer_tests_summary/run_parallel.py | 26 +++++++++++-------- .../layer_tests_summary/utils/constants.py | 3 +++ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py index 9e8041ce54b..8c64a0eeb9d 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_conformance.py @@ -231,15 +231,15 @@ class Conformance: f"--report_unique_name", f'--output_folder="{parallel_report_dir}"', f'--gtest_filter=\"{self._gtest_filter}\"', f'--config_path="{self._ov_config_path}"', f'--shape_mode={self._special_mode}'] - conformance = TestParallelRunner(exec_file_path = f"{conformance_path}", - test_command_line = command_line_args, - worker_num = self._workers, - working_dir = logs_dir, - cache_path = self._cache_path, - split_unit="test", - repeat_failed = 1, - is_parallel_devices = self._is_parallel_over_devices, - excluded_tests = self._expected_failures if not self._expected_failures_update else set()) + conformance = TestParallelRunner(exec_file_path=f"{conformance_path}", + test_command_line=command_line_args, + worker_num=self._workers, + working_dir=logs_dir, + cache_path=self._cache_path, + split_unit=constants.TEST_UNIT_NAME, + repeat_failed=1, + is_parallel_devices=self._is_parallel_over_devices, + excluded_tests=self._expected_failures if not self._expected_failures_update else set()) conformance.run() conformance.postprocess_logs() diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py index aed04c92e6f..a29cb01bb06 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/run_parallel.py @@ -56,11 +56,11 @@ def parse_arguments(): parser.add_argument("-e", "--exec_file", help=exec_file_path_help, type=str, required=True) parser.add_argument("-c", "--cache_path", help=cache_path_help, type=str, required=False, default="") - parser.add_argument("-j", "--workers", help=worker_num_help, type=int, required=False, default=(os.cpu_count()) if os.cpu_count() > 2 else 1) + parser.add_argument("-j", "--workers", help=worker_num_help, type=int, required=False, default=os.cpu_count()) parser.add_argument("-p", "--parallel_devices", help=parallel_help, type=int, required=False, default=0) parser.add_argument("-w", "--working_dir", help=working_dir_num_help, type=str, required=False, default=".") parser.add_argument("-t", "--process_timeout", help=process_timeout_help, type=int, required=False, default=DEFAULT_PROCESS_TIMEOUT) - parser.add_argument("-s", "--split_unit", help=split_unit_help, type=str, required=False, default="suite") + parser.add_argument("-s", "--split_unit", help=split_unit_help, type=str, required=False, default=constants.SUITE_UNIT_NAME) parser.add_argument("-rf", "--repeat_failed", help=repeat_help, type=int, required=False, default=1) return parser.parse_args() @@ -235,7 +235,11 @@ class TestParallelRunner: if not os.path.exists(head): os.mkdir(head) self._is_save_cache = True - self._split_unit = split_unit + if split_unit in constants.UNIT_NAMES: + self._split_unit = split_unit + else: + logger.error(f"Incorrect split_unit argument: {split_unit}. Please use the following values: {','.join(constants.UNIT_NAMES)}") + sys.exit(-1) self._repeat_failed = repeat_failed self._disabled_tests = list() self._total_test_cnt = 0 @@ -278,7 +282,7 @@ class TestParallelRunner: input_string = input_string.replace(symbol, '*') return input_string - def __get_test_list_by_runtime(self, test_unit = "test"): + def __get_test_list_by_runtime(self, test_unit = constants.TEST_UNIT_NAME): self._total_test_cnt = 0 self._disabled_tests.clear() test_list_file_name = os.path.join(self._working_dir, "test_list.lst") @@ -312,10 +316,10 @@ class TestParallelRunner: real_test_name = test_suite + "." + (test_name[2:pos-1] if pos > 0 else test_name[2:]) if constants.DISABLED_PREFIX in real_test_name: self._disabled_tests.append(real_test_name) - elif (test_unit == "test"): + elif test_unit == constants.TEST_UNIT_NAME: tests_dict[real_test_name] = 1 self._total_test_cnt += 1 - elif (test_unit == "suite"): + elif test_unit == constants.SUITE_UNIT_NAME: tests_dict[test_suite] = tests_dict.get(test_suite, 0) + 1 self._total_test_cnt += 1 test_list_file.close() @@ -337,11 +341,11 @@ class TestParallelRunner: test_name = line[pos+1:].replace("\n", "") test_suite = test_name[:test_name.find(".")] - if (self._split_unit == "test"): + if self._split_unit == constants.TEST_UNIT_NAME: if constants.DISABLED_PREFIX not in test_name: if (time != -1): tests_dict_cache[test_name] = tests_dict_cache.get(test_name, 0) + time - elif (self._split_unit == "suite"): + elif self._split_unit == constants.SUITE_UNIT_NAME: if constants.DISABLED_PREFIX not in test_suite: if (time == -1): tests_dict_cache[test_suite] = tests_dict_cache.get(test_suite, -1) @@ -387,7 +391,7 @@ class TestParallelRunner: test_pattern = f'{self.__replace_restricted_symbols(test_pattern)}' # fix the suite filters to execute the right amount of the tests - if (self._split_unit == "suite"): + if (self._split_unit == constants.SUITE_UNIT_NAME): test_pattern = get_suite_filter(self._gtest_filter, test_pattern) + "*" # add quotes and pattern splitter test_pattern = f'"{test_pattern}":' @@ -500,7 +504,7 @@ class TestParallelRunner: worker_cnt += self.__execute_tests(test_filters, worker_cnt) # 15m for one test in one process if TaskManager.process_timeout == -1 or TaskManager.process_timeout == DEFAULT_PROCESS_TIMEOUT: - TaskManager.process_timeout = DEFAULT_SUITE_TIMEOUT if self._split_unit == "suite" else DEFAULT_TEST_TIMEOUT + TaskManager.process_timeout = DEFAULT_SUITE_TIMEOUT if self._split_unit == constants.SUITE_UNIT_NAME else DEFAULT_TEST_TIMEOUT not_runned_tests, interapted_tests = self.__find_not_runned_tests() if (self._repeat_failed > 0): @@ -633,7 +637,7 @@ class TestParallelRunner: if __save_log(logs_dir, dir, test_name): interapted_tests.add(test_name) - if (split_unit == "suite"): + if (split_unit == constants.SUITE_UNIT_NAME): test_cnt_real = len(test_suites) else: test_cnt_real = test_cnt_real_saved_now diff --git a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 825e599d52e..906229228cc 100644 --- a/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/src/tests/test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -16,6 +16,9 @@ DISABLED_PREFIX = "DISABLED_" PG_ERR = "PG ERROR" PG_WARN = "PG WARN" REF_COEF = "[ CONFORMANCE ] Influence coefficient: " +TEST_UNIT_NAME = "test" +SUITE_UNIT_NAME = "suite" +UNIT_NAMES = [TEST_UNIT_NAME, SUITE_UNIT_NAME] IS_WIN = "windows" in platform or "win32" in platform IS_MACOS = "darwin" in platform