From 6e4c3c33a5041f028f30d401f3c5518060f67a24 Mon Sep 17 00:00:00 2001 From: Kirill Sosnovskikh Date: Tue, 16 Jul 2024 13:43:59 +0300 Subject: [PATCH] [#270] Move alluredir check to start of fixture Signed-off-by: Kirill Sosnovskikh --- pytest_tests/testsuites/conftest.py | 40 ++++++++--------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/pytest_tests/testsuites/conftest.py b/pytest_tests/testsuites/conftest.py index 3baab89..b10bcf5 100644 --- a/pytest_tests/testsuites/conftest.py +++ b/pytest_tests/testsuites/conftest.py @@ -15,12 +15,7 @@ from frostfs_testlib.credentials.interfaces import CredentialsProvider, User from frostfs_testlib.healthcheck.interfaces import Healthcheck from frostfs_testlib.hosting import Hosting from frostfs_testlib.reporter import AllureHandler, StepsLogger -from frostfs_testlib.resources.common import ( - ASSETS_DIR, - COMPLEX_OBJECT_CHUNKS_COUNT, - COMPLEX_OBJECT_TAIL_SIZE, - SIMPLE_OBJECT_SIZE, -) +from frostfs_testlib.resources.common import ASSETS_DIR, COMPLEX_OBJECT_CHUNKS_COUNT, COMPLEX_OBJECT_TAIL_SIZE, SIMPLE_OBJECT_SIZE from frostfs_testlib.s3 import AwsCliClient, Boto3ClientWrapper, S3ClientWrapper, VersioningStatus from frostfs_testlib.shell import LocalShell, Shell from frostfs_testlib.steps.cli.container import DEFAULT_EC_PLACEMENT_RULE, DEFAULT_PLACEMENT_RULE @@ -210,9 +205,7 @@ def complex_object_size(max_object_size: int) -> ObjectSize: scope="session", params=[pytest.param("simple", marks=pytest.mark.simple), pytest.param("complex", marks=pytest.mark.complex)], ) -def object_size( - simple_object_size: ObjectSize, complex_object_size: ObjectSize, request: pytest.FixtureRequest -) -> ObjectSize: +def object_size(simple_object_size: ObjectSize, complex_object_size: ObjectSize, request: pytest.FixtureRequest) -> ObjectSize: if request.param == "simple": return simple_object_size @@ -269,17 +262,13 @@ def s3_policy(request: pytest.FixtureRequest): @pytest.fixture(scope="session") @allure.title("[Session] Create healthcheck object") def healthcheck(cluster: Cluster) -> Healthcheck: - healthcheck_cls = plugins.load_plugin( - "frostfs.testlib.healthcheck", cluster.cluster_nodes[0].host.config.healthcheck_plugin_name - ) + healthcheck_cls = plugins.load_plugin("frostfs.testlib.healthcheck", cluster.cluster_nodes[0].host.config.healthcheck_plugin_name) return healthcheck_cls() @pytest.fixture(scope="session") -def cluster_state_controller_session( - client_shell: Shell, cluster: Cluster, healthcheck: Healthcheck -) -> ClusterStateController: +def cluster_state_controller_session(client_shell: Shell, cluster: Cluster, healthcheck: Healthcheck) -> ClusterStateController: controller = ClusterStateController(client_shell, cluster, healthcheck) return controller @@ -315,9 +304,7 @@ def s3_client( credentials_provider.S3.provide(default_user, node, s3_policy) s3_client_cls = request.param - client = s3_client_cls( - default_user.s3_credentials.access_key, default_user.s3_credentials.secret_key, cluster.default_s3_gate_endpoint - ) + client = s3_client_cls(default_user.s3_credentials.access_key, default_user.s3_credentials.secret_key, cluster.default_s3_gate_endpoint) return client @@ -388,6 +375,10 @@ def two_buckets(buckets_pool: list[str], s3_client: S3ClientWrapper) -> list[str @allure.title("[Autouse/Session] Collect binary versions") @pytest.fixture(scope="session", autouse=True) def collect_binary_versions(hosting: Hosting, client_shell: Shell, request: pytest.FixtureRequest): + environment_dir = request.config.getoption("--alluredir") + if not environment_dir: + return None + local_versions = version_utils.get_local_binaries_versions(client_shell) remote_versions = version_utils.get_remote_binaries_versions(hosting) remote_versions_keys = list(remote_versions.keys()) @@ -401,10 +392,6 @@ def collect_binary_versions(hosting: Hosting, client_shell: Shell, request: pyte }, } - environment_dir = request.config.getoption("--alluredir") - if not environment_dir: - return None - file_path = f"{environment_dir}/environment.properties" env_utils.save_env_properties(file_path, all_versions) @@ -439,10 +426,7 @@ def after_deploy_healthcheck(cluster: Cluster): @wait_for_success(60 * SERVICE_ACTIVE_TIME * 3, 60, title="Wait for {cluster_node} readiness") def readiness_on_node(cluster_node: ClusterNode): - if ( - "skip_readiness_check" in cluster_node.host.config.attributes - and cluster_node.host.config.attributes["skip_readiness_check"] - ): + if "skip_readiness_check" in cluster_node.host.config.attributes and cluster_node.host.config.attributes["skip_readiness_check"]: return # TODO: Move to healtcheck classes @@ -452,9 +436,7 @@ def readiness_on_node(cluster_node: ClusterNode): assert "active" == result.stdout.strip(), f"Service {svc_name} should be in active state" with reporter.step(f"Check service {svc_name} is active more than {SERVICE_ACTIVE_TIME} minutes"): - result = cluster_node.host.get_shell().exec( - f"systemctl show {svc_name} --property ActiveEnterTimestamp | cut -d '=' -f 2" - ) + result = cluster_node.host.get_shell().exec(f"systemctl show {svc_name} --property ActiveEnterTimestamp | cut -d '=' -f 2") start_time = parser.parse(result.stdout.strip()) current_time = datetime.now(tz=timezone.utc) active_time = current_time - start_time