From 245cedc5f3af8a95dd4d25e0edca4bb329c08119 Mon Sep 17 00:00:00 2001 From: Prudhvi Godithi Date: Wed, 9 Oct 2024 18:27:13 -0700 Subject: [PATCH] Gradle Reports Signed-off-by: Prudhvi Godithi --- .../integ_test/integ_test_suite_opensearch.py | 16 ++++-- .../test_integ_test_suite_opensearch.py | 53 +++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/test_workflow/integ_test/integ_test_suite_opensearch.py b/src/test_workflow/integ_test/integ_test_suite_opensearch.py index d6abc87c74..071df19cc6 100644 --- a/src/test_workflow/integ_test/integ_test_suite_opensearch.py +++ b/src/test_workflow/integ_test/integ_test_suite_opensearch.py @@ -139,8 +139,18 @@ def custom_node_endpoint_encoder(node_endpoint: NodeEndpoint) -> dict: logging.info(f"{script} does not exist. Skipping integ tests for {self.component.name}") return 0 + @property + def additional_test_report_dirs(self) -> list[str]: + return ["integrationTest", "integTestRemote"] + @property def test_artifact_files(self) -> dict: - return { - "opensearch-integ-test": os.path.join(self.repo_work_dir, "build", "reports", "tests", "integTest") - } + default_report_path = os.path.join(self.repo_work_dir, "build", "reports", "tests", "integTest") + if os.path.exists(default_report_path): + return {"opensearch-integ-test": default_report_path} + for root, dirs, files in os.walk(self.repo_work_dir): + for test_report_dir in self.additional_test_report_dirs: + potential_path = os.path.join(root, "build", "reports", "tests", test_report_dir) + if os.path.exists(potential_path): + return {"opensearch-integ-test": potential_path} + return {"opensearch-integ-test": default_report_path} diff --git a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_integ_test_suite_opensearch.py b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_integ_test_suite_opensearch.py index 3e27504c61..14b04fd3be 100644 --- a/tests/tests_test_workflow/test_integ_workflow/integ_test/test_integ_test_suite_opensearch.py +++ b/tests/tests_test_workflow/test_integ_workflow/integ_test/test_integ_test_suite_opensearch.py @@ -244,3 +244,56 @@ def test_multi_execute_integtest_sh(self, mock_execute: Mock, mock_git: Mock, mo assert(mock_test_result_data.return_value in integ_test_suite.result_data) self.assertEqual(integ_test_suite.additional_cluster_config, None) + + @patch("os.path.exists", return_value=True) + @patch("os.walk", return_value=[(os.path.join("/some", "path"), ["build"], ["integTest", "integrationTest", "integTestRemote"])]) + def test_test_artifact_files_default(self, *mocks: Any) -> None: + dependency_installer = MagicMock() + test_config, component = self.__get_test_config_and_bundle_component("job-scheduler") + integ_test_suite = IntegTestSuiteOpenSearch( + dependency_installer, + component, + test_config, + self.bundle_manifest, + self.build_manifest, + self.work_dir, + MagicMock() + ) + integ_test_suite.repo_work_dir = os.path.join("/some", "path") + expected_path = { + "opensearch-integ-test": os.path.join("/some", "path", "build", "reports", "tests", "integTest") + } + result = integ_test_suite.test_artifact_files + self.assertEqual(result, expected_path) + + @patch("os.path.exists", return_value=False) + @patch("os.walk", return_value=[]) + def test_test_artifact_files_no_default_path(self, *mocks: Any) -> None: + dependency_installer = MagicMock() + test_config, component = self.__get_test_config_and_bundle_component("job-scheduler") + integ_test_suite = IntegTestSuiteOpenSearch( + dependency_installer, + component, + test_config, + self.bundle_manifest, + self.build_manifest, + self.work_dir, + MagicMock() + ) + integ_test_suite.repo_work_dir = os.path.join("/some", "path") + default_path = os.path.join(integ_test_suite.repo_work_dir, "build", "reports", "tests", "integTest") + expected_path = {"opensearch-integ-test": default_path} + result = integ_test_suite.test_artifact_files + self.assertEqual(result, expected_path) + + def test_test_report_dirs(self, *mocks: Any) -> None: + integ_test_suite = IntegTestSuiteOpenSearch( + MagicMock(), + MagicMock(), + MagicMock(), + self.bundle_manifest, + self.build_manifest, + self.work_dir, + MagicMock() + ) + self.assertEqual(integ_test_suite.additional_test_report_dirs, ["integrationTest", "integTestRemote"])