Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# *******************************************************************************
import logging
from tests.utils.testing_utils.run_until_file_deployed import run_until_file_deployed
from tests.utils.testing_utils.setup_test import setup_test
from tests.utils.testing_utils.setup_test import setup_test, download_core_dumps
from tests.utils.testing_utils.test_results import assert_test_results
from attribute_plugin import add_test_properties

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/smoke/smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# *******************************************************************************
import logging
from tests.utils.testing_utils.run_until_file_deployed import run_until_file_deployed
from tests.utils.testing_utils.setup_test import setup_test
from tests.utils.testing_utils.setup_test import setup_test, download_core_dumps
from tests.utils.testing_utils.test_results import assert_test_results
from attribute_plugin import add_test_properties

Expand Down
8 changes: 8 additions & 0 deletions tests/utils/plugins/localhost.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import time
from pathlib import Path
from typing import List
import resource

import pytest

Expand Down Expand Up @@ -127,6 +128,12 @@ def download(self, remote_path: str, local_path: str) -> None:
def execute_async(
self, binary_path: str, args=None, cwd: str = "/", **kwargs
) -> LocalAsyncProcess:
def _set_core_unlimited():
"""Function to set core dump limit in the subshell."""
resource.setrlimit(
resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY)
)

cmd = ["fakeroot", "--", binary_path] + (args or [])
cmd_logger = logging.getLogger(Path(binary_path).name)
output_lines: List[str] = []
Expand All @@ -135,6 +142,7 @@ def execute_async(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
preexec_fn=_set_core_unlimited,
cwd=cwd,
start_new_session=True, # Start under a new process group
)
Expand Down
21 changes: 21 additions & 0 deletions tests/utils/testing_utils/setup_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,24 @@ def setup_test(request, target):
assert res == 0, f"Couldn't extract tar {remote_tar}"

logger.info("Test case setup finished")


@pytest.fixture(autouse=True, scope="function")
def download_core_dumps(target, remote_test_dir, test_output_dir):
"""Downloads any core dump files from the remote after a test completes."""
yield

res, stdout = target.execute(f"find {remote_test_dir} -name 'core*' -type f")
if res != 0:
return
core_files = stdout.decode().strip().splitlines()
for remote_path in core_files:
remote_path = remote_path.strip()
if not remote_path:
continue
local_path = test_output_dir / Path(remote_path).name
try:
target.download(remote_path, str(local_path))
logger.info(f"Downloaded core dump: {remote_path} -> {local_path}")
except Exception as e:
logger.warning(f"Failed to download core dump {remote_path}: {e}")
Loading