diff --git a/src/test_workflow/test_args.py b/src/test_workflow/test_args.py index 7ad709342c..2a9a15de6a 100644 --- a/src/test_workflow/test_args.py +++ b/src/test_workflow/test_args.py @@ -28,7 +28,7 @@ def __init__(self) -> None: parser = argparse.ArgumentParser(description="Test an OpenSearch Bundle") parser.add_argument("test_manifest_path", type=TestArgsPathValidator.validate, help="Specify a test manifest path.") parser.add_argument("-p", "--paths", nargs='*', action=TestKwargs, default={}, help="Specify paths for OpenSearch and OpenSearch Dashboards.") - # e.g. --base-path https://ci.opensearch.org/ci/dbc/integ-test/2.7.0/7771/linux/x64/tar/ with trailing slash because of the property of urljoin + # e.g. --base-path https://ci.opensearch.org/ci/dbc/integ-test/2.7.0/7771/linux/x64/tar/ parser.add_argument("--base-path", type=str, default="", help="Specify base paths for the integration test logs.") parser.add_argument("--test-run-id", type=int, help="The unique execution id for the test") parser.add_argument("--component", type=str, dest="components", nargs='*', help="Test a specific component or components instead of the entire distribution.") diff --git a/src/test_workflow/test_recorder/test_recorder.py b/src/test_workflow/test_recorder/test_recorder.py index 5afed60568..64da8643aa 100644 --- a/src/test_workflow/test_recorder/test_recorder.py +++ b/src/test_workflow/test_recorder/test_recorder.py @@ -142,6 +142,7 @@ def save_test_result_data(self, test_result_data: TestResultData) -> None: class TestResultsLogs(LogRecorder): + __test__ = False # type:ignore parent_class: TestRecorder def __init__(self, parent_class: TestRecorder) -> None: diff --git a/tests/tests_test_workflow/test_recorder/test_test_recorder.py b/tests/tests_test_workflow/test_recorder/test_test_recorder.py index 245afbe41f..faf93a9948 100644 --- a/tests/tests_test_workflow/test_recorder/test_test_recorder.py +++ b/tests/tests_test_workflow/test_recorder/test_test_recorder.py @@ -11,7 +11,7 @@ from typing import Any from unittest.mock import MagicMock, Mock, call, mock_open, patch -from test_workflow.test_recorder.test_recorder import LocalClusterLogs, TestRecorder +from test_workflow.test_recorder.test_recorder import LocalClusterLogs, TestRecorder, TestResultsLogs @patch("os.makedirs") @@ -146,3 +146,34 @@ def test(self) -> None: logs.save_test_result_data(mock_test_result_data) mock_parent_class._copy_log_files.assert_called_once_with(mock_test_result_data.log_files, dest_directory) + + +class TestTestResultsLogs(unittest.TestCase): + + def test(self) -> None: + mock_parent_class = MagicMock() + + mock_parent_class._create_base_folder_structure.return_value = "test_base" + + mock_parent_class._copy_log_files = MagicMock() + + logs = TestResultsLogs(mock_parent_class) + + mock_test_result_data = MagicMock() + + dest_directory = "test_base" + + source_file_1 = "stdout.txt" + source_file_2 = "stderr.txt" + + mock_test_result_data.log_files = { + source_file_1, + source_file_2 + } + mock_test_result_data.component_name = "sql" + mock_test_result_data.component_test_config = "with-security" + + logs.save_test_result_data(mock_test_result_data) + + mock_parent_class._copy_log_files.assert_called_once_with(mock_test_result_data.log_files, dest_directory) + mock_parent_class._generate_yml.assert_called_once_with(mock_test_result_data, dest_directory)