Skip to content

Commit

Permalink
Gradle Reports
Browse files Browse the repository at this point in the history
Signed-off-by: Prudhvi Godithi <[email protected]>
  • Loading branch information
prudhvigodithi committed Oct 10, 2024
1 parent 7ae361f commit 245cedc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test_workflow/integ_test/integ_test_suite_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

0 comments on commit 245cedc

Please sign in to comment.