From 4e6bbaca64304c8ea54cbb61bfc1f877bf48a265 Mon Sep 17 00:00:00 2001 From: Andrey Berezin Date: Fri, 18 Nov 2022 14:24:40 +0300 Subject: [PATCH] Fix too long logs dir for analyze logs Signed-off-by: Andrey Berezin --- pytest_tests/helpers/file_helper.py | 12 ------------ pytest_tests/testsuites/conftest.py | 5 +++-- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/pytest_tests/helpers/file_helper.py b/pytest_tests/helpers/file_helper.py index e231171..c036b7f 100644 --- a/pytest_tests/helpers/file_helper.py +++ b/pytest_tests/helpers/file_helper.py @@ -164,15 +164,3 @@ def get_file_content( content = file.read() return content - - -def sanitize_for_file_name(string: str) -> str: - """ - Returns string with only alpha num string with all other characters replaced by '_' - which is valid string to use as file name - - Args: - string: string to sanitize - """ - - return "".join(character if character.isalnum() else "_" for character in string).strip("_") diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 2b6dcd7..cbd8e41 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -11,7 +11,6 @@ import yaml from binary_version_helper import get_local_binaries_versions, get_remote_binaries_versions from common import ASSETS_DIR, FREE_STORAGE, HOSTING_CONFIG_FILE, NEOFS_NETMAP_DICT, WALLET_PASS from env_properties import save_env_properties -from file_helper import sanitize_for_file_name from neofs_testlib.hosting import Hosting from neofs_testlib.reporter import AllureHandler, get_reporter from neofs_testlib.shell import LocalShell, Shell @@ -106,7 +105,9 @@ def analyze_logs(prepare_tmp_dir: str, hosting: Hosting, request: FixtureRequest with allure.step("Skip analyze logs due to no_log_analyze mark"): return - logs_dir = os.path.join(prepare_tmp_dir, f"logs_{sanitize_for_file_name(request.node.name)}") + # Test name may exceed os NAME_MAX (255 bytes), so we use test start datetime instead + start_time_str = start_time.strftime("%Y_%m_%d_%H_%M_%S_%f") + logs_dir = os.path.join(prepare_tmp_dir, f"logs_{start_time_str}") dump_logs(hosting, logs_dir, start_time, end_time) check_logs(logs_dir)