Skip to content

Commit

Permalink
Add conditional check for report workflow to skip component not in bu…
Browse files Browse the repository at this point in the history
…ndle (#5090)

Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh authored Oct 10, 2024
1 parent d995744 commit 8168747
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/report_workflow/test_report_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def __init__(self, args: ReportArgs, test_manifest: TestManifest) -> None:
else os.path.join(self.args.artifact_paths[self.name], "dist", self.name, "manifest.yml")
self.test_components = self.test_manifest.components
self.bundle_manifest = BundleManifest.from_urlpath(self.dist_manifest)
self.bundle_components_list = []
for component in self.bundle_manifest.components.select(focus=self.args.components):
self.bundle_components_list.append(component.name)

def update_data(self) -> dict:
self.test_report_data["name"] = self.product_name
Expand All @@ -60,6 +63,9 @@ def update_data(self) -> dict:
self.test_report_data["rc"] = self.release_candidate
self.test_report_data["test-run"] = self.update_test_run_data()
for component in self.test_components.select(focus=self.args.components):
if component.name not in self.bundle_components_list:
logging.info(f"Skipping {component.name} as it's not included in the bundle manifest.")
continue
if self.test_manifest.components[component.name].__to_dict__().get(self.test_type) is not None:
component_ci_group = getattr(component, self.test_type.replace("-", "_")).get("ci-groups", None)
if component_ci_group:
Expand Down
9 changes: 9 additions & 0 deletions tests/tests_report_workflow/data/test_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,12 @@ components:
bwc-test:
test-configs:
- with-security

- name: opensearch-system-templates
integ-test:
test-configs:
- with-security
- without-security
additional-cluster-configs:
opensearch.experimental.feature.application_templates.enabled: true
cluster.application_templates.enabled: true
21 changes: 21 additions & 0 deletions tests/tests_report_workflow/test_test_report_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,27 @@ def test_generate_file(self, report_args_mock: MagicMock) -> None:
test_run_runner.generate_report(test_run_runner_data, path.name)
self.assertTrue(os.path.isfile(output_path))

@patch("report_workflow.report_args.ReportArgs")
def test_update_data_skip_component(self, report_args_mock: MagicMock) -> None:
report_args_mock.test_manifest_path = self.TEST_MANIFEST_PATH
report_args_mock.artifact_paths = {"opensearch": self.DATA_DIR}
report_args_mock.test_run_id = 123
report_args_mock.base_path = self.DATA_DIR
report_args_mock.test_type = "integ-test"
report_args_mock.release_candidate = "100"

test_report_runner = TestReportRunner(report_args_mock, self.TEST_MANIFEST)
test_report_runner_data = test_report_runner.update_data()

self.assertFalse("opensearch-system-templates" in test_report_runner.bundle_components_list)
self.assertEqual(len(test_report_runner_data["components"]), 6)

for i in range(len(self.TEST_MANIFEST.components.__to_dict__())):
if self.TEST_MANIFEST.components.__to_dict__()[i]["name"] == "opensearch-system-templates":
self.assertEqual(i, len(self.TEST_MANIFEST.components) - 1)
else:
self.assertEqual(self.TEST_MANIFEST.components.__to_dict__()[i]["name"], test_report_runner_data["components"][i]["name"])

@patch("report_workflow.report_args.ReportArgs")
@patch("manifests.test_manifest.TestManifest")
def test_runner_update_test_run_data_local(self, report_args_mock: MagicMock,
Expand Down

0 comments on commit 8168747

Please sign in to comment.