Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix issue with out of space during logs attachment #879

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions neofs-testlib/neofs_testlib/env/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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}",
Expand Down Expand Up @@ -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}")
Expand Down
3 changes: 1 addition & 2 deletions pytest_tests/lib/helpers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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)
70 changes: 60 additions & 10 deletions pytest_tests/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
1 change: 1 addition & 0 deletions pytest_tests/tests/failovers/test_failover_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pytest_tests/tests/s3/test_s3_locking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading