diff --git a/neofs-testlib/neofs_testlib/env/env.py b/neofs-testlib/neofs_testlib/env/env.py index 64e0f7e38..950486d43 100644 --- a/neofs-testlib/neofs_testlib/env/env.py +++ b/neofs-testlib/neofs_testlib/env/env.py @@ -155,12 +155,13 @@ def deploy_inner_ring_nodes(self, count=1, with_main_chain=False): ir_node.start(wait_until_ready=False, with_main_chain=with_main_chain) with allure.step("Wait until all IR nodes are READY"): - for ir_node in self.inner_ring_nodes: + for ir_node_idx, ir_node in enumerate(self.inner_ring_nodes): logger.info(f"Wait until IR: {ir_node} is READY") try: ir_node._wait_until_ready() except Exception as e: - allure.attach.file(ir_node.stderr, name="ir node logs", extension="txt") + allure.attach.file(ir_node.stderr, name=f"ir{ir_node_idx} node stderr", extension="txt") + allure.attach.file(ir_node.stdout, name=f"ir{ir_node_idx} node stdout", extension="txt") raise e @allure.step("Deploy storage node") @@ -177,7 +178,13 @@ def deploy_storage_nodes(self, count=1, node_attrs: Optional[dict] = None): for t in deploy_threads: t.start() logger.info("Wait until storage nodes are deployed") - self._wait_until_all_storage_nodes_are_ready() + try: + self._wait_until_all_storage_nodes_are_ready() + except Exception as e: + for sn in self.storage_nodes: + allure.attach.file(sn.stderr, name=f"sn{sn.sn_number} stderr", extension="txt") + allure.attach.file(sn.stdout, name=f"sn{sn.sn_number} stdout", extension="txt") + raise e # tick epoch to speed up storage nodes bootstrap self.neofs_adm().morph.force_new_epoch( rpc_endpoint=f"http://{self.morph_rpc}", @@ -327,7 +334,7 @@ def kill(self): ir.process.kill() def persist(self) -> str: - persisted_path = self._generate_temp_file(self._env_dir, prefix="persisted_env") + persisted_path = self._generate_temp_file(os.path.dirname(self._env_dir), prefix="persisted_env") with open(persisted_path, "wb") as fp: pickle.dump(self, fp) logger.info(f"Persist env at: {persisted_path}") diff --git a/pytest_tests/lib/helpers/common.py b/pytest_tests/lib/helpers/common.py index 6624bef42..8c84fec56 100644 --- a/pytest_tests/lib/helpers/common.py +++ b/pytest_tests/lib/helpers/common.py @@ -25,7 +25,6 @@ NEOFS_CONTRACT = os.getenv("NEOFS_IR_CONTRACTS_NEOFS") TEST_RUN_DIR = f"test-run-{datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d-%H-%M-%S-%f")}" -ASSETS_DIR = f"TemporaryDir-{datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%d-%H-%M-%S-%f")}" TEST_FILES_DIR = os.getenv("TEST_FILES_DIR", "TestFilesDir") TEST_OBJECTS_DIR = os.getenv("TEST_OBJECTS_DIR", "TestObjectsDir") DEVENV_PATH = os.getenv("DEVENV_PATH", os.path.join("..", "neofs-dev-env")) @@ -68,4 +67,4 @@ def get_assets_dir_path() -> str: - return os.path.join(os.getcwd(), TEST_RUN_DIR, ASSETS_DIR) + return os.path.join(os.getcwd(), TEST_RUN_DIR) diff --git a/pytest_tests/tests/conftest.py b/pytest_tests/tests/conftest.py index 5047c24c7..dd00e44d1 100644 --- a/pytest_tests/tests/conftest.py +++ b/pytest_tests/tests/conftest.py @@ -46,18 +46,66 @@ def neofs_env(temp_directory, artifacts_directory, request): if not request.config.getoption("--load-env"): neofs_env.kill() - if request.session.testsfailed: - env_files_path = os.path.join(os.getcwd(), neofs_env._env_dir) - env_files_archived = shutil.make_archive( - os.path.join(get_assets_dir_path(), f"neofs_env_{neofs_env._id}"), "zip", env_files_path - ) - allure.attach.file(env_files_archived, name="neofs env files", extension="zip") + if request.session.testsfailed and not request.config.getoption("--persist-env"): + neofs_env.shell.exec("df -h") + neofs_env.shell.exec("df -h /tmp") + neofs_env.shell.exec("df -i") + neofs_env.shell.exec(f"du -h {neofs_env._env_dir}") + neofs_env.shell.exec(f"ls -lah {neofs_env._env_dir}") + + for ir in neofs_env.inner_ring_nodes: + os.remove(ir.ir_storage_path) + for sn in neofs_env.storage_nodes: + for shard in sn.shards: + os.remove(shard.metabase_path) + os.remove(shard.blobovnicza_path) + shutil.rmtree(shard.fstree_path, ignore_errors=True) + os.remove(shard.pilorama_path) + os.remove(shard.wc_path) - temp_files_path = os.path.join(get_assets_dir_path()) - temp_files_archived = shutil.make_archive( - os.path.join(get_assets_dir_path(), "temp_files"), "zip", temp_files_path + neofs_env.shell.exec("df -h") + neofs_env.shell.exec("df -i") + neofs_env.shell.exec(f"du -h {neofs_env._env_dir}") + neofs_env.shell.exec(f"ls -lah {neofs_env._env_dir}") + + shutil.make_archive( + os.path.join(get_assets_dir_path(), f"neofs_env_{neofs_env._id}"), "zip", neofs_env._env_dir ) - allure.attach.file(temp_files_archived, name="tests temp files", extension="zip") + + neofs_env.shell.exec("df -h") + neofs_env.shell.exec("df -i") + neofs_env.shell.exec(f"du -h {neofs_env._env_dir}") + neofs_env.shell.exec(f"ls -lah {neofs_env._env_dir}") + allure.attach.file(os.path.join(get_assets_dir_path(), f"neofs_env_{neofs_env._id}.zip"), name="neofs env files", extension="zip") + + # allure.attach.file(neofs_env.inner_ring_nodes[0].stderr, name=os.path.basename(ir.stderr), extension="txt") + + # for ir in neofs_env.inner_ring_nodes: + # allure.attach.file(ir.stderr, name=os.path.basename(ir.stderr), extension="txt") + # allure.attach.file(ir.stdout, name=os.path.basename(ir.stdout), extension="txt") + + # for sn in neofs_env.storage_nodes: + # allure.attach.file(sn.stderr, name=os.path.basename(sn.stderr), extension="txt") + # allure.attach.file(sn.stdout, name=os.path.basename(sn.stdout), extension="txt") + + # allure.attach.file(neofs_env.s3_gw.stderr, name=os.path.basename(neofs_env.s3_gw.stderr), extension="txt") + # allure.attach.file(neofs_env.s3_gw.stdout, name=os.path.basename(neofs_env.s3_gw.stdout), extension="txt") + + # allure.attach.file(neofs_env.rest_gw.stderr, name=os.path.basename(neofs_env.rest_gw.stderr), extension="txt") + # allure.attach.file(neofs_env.rest_gw.stdout, name=os.path.basename(neofs_env.rest_gw.stdout), extension="txt") + + shutil.rmtree(neofs_env._env_dir, ignore_errors=True) + + neofs_env.shell.exec("df -h") + neofs_env.shell.exec(f"du -h {get_assets_dir_path()}") + neofs_env.shell.exec(f"ls -lah {get_assets_dir_path()}") + + # temp_files_archived = shutil.make_archive( + # os.path.join(get_assets_dir_path(), "temp_files"), "zip", get_assets_dir_path() + # ) + # neofs_env.shell.exec(f"ls -lah {get_assets_dir_path()}") + # neofs_env.shell.exec("df -h") + # allure.attach.file(temp_files_archived, name="tests temp files", extension="zip") @pytest.fixture(scope="session") @@ -249,6 +297,8 @@ def cleanup_temp_files(): def file_system_monitor(neofs_env: NeoFSEnv): with allure.step("Get fs usage before test"): neofs_env.shell.exec("df -h") + neofs_env.shell.exec("df -i") yield with allure.step("Get fs usage after test"): neofs_env.shell.exec("df -h") + neofs_env.shell.exec("df -i") diff --git a/pytest_tests/tests/failovers/test_failover_network.py b/pytest_tests/tests/failovers/test_failover_network.py index c008a8312..caaaab00a 100644 --- a/pytest_tests/tests/failovers/test_failover_network.py +++ b/pytest_tests/tests/failovers/test_failover_network.py @@ -47,6 +47,7 @@ def test_block_storage_node_traffic(self, default_wallet, simple_object_size, re """ Block storage nodes traffic using iptables and wait for replication for objects. """ + raise AssertionError("Invoke allure attachments") wallet = default_wallet placement_rule = "REP 2 IN X CBF 2 SELECT 2 FROM * AS X" wakeup_node_timeout = 10 # timeout to let nodes detect that traffic has blocked diff --git a/pytest_tests/tests/s3/test_s3_locking.py b/pytest_tests/tests/s3/test_s3_locking.py index 5c9821279..867170b14 100644 --- a/pytest_tests/tests/s3/test_s3_locking.py +++ b/pytest_tests/tests/s3/test_s3_locking.py @@ -160,6 +160,7 @@ def test_s3_mode_governance(self, version_id, simple_object_size): @allure.title("Test S3: Checking if an Object Cannot Be Locked") def test_s3_legal_hold(self, version_id, simple_object_size): + raise AssertionError() file_path = generate_file(simple_object_size) file_name = object_key_from_file_path(file_path) diff --git a/pytest_tests/tests/session_token/test_static_session_token_container.py b/pytest_tests/tests/session_token/test_static_session_token_container.py index 497e2d89a..3b394f116 100644 --- a/pytest_tests/tests/session_token/test_static_session_token_container.py +++ b/pytest_tests/tests/session_token/test_static_session_token_container.py @@ -473,6 +473,7 @@ def test_static_session_token_container_set_eacl_only_trusted_party_proved_by_th temp_directory: str, not_owner_wallet, ): + raise AssertionError() with allure.step("Create container"): cid = create_container( owner_wallet.path,