diff --git a/pyproject.toml b/pyproject.toml index fe5ac8c024..10400c4a79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,4 +13,4 @@ warn_return_any = true warn_unused_configs = true strict_optional = false show_error_codes = true -ignore_missing_imports = true \ No newline at end of file +ignore_missing_imports = true diff --git a/src/manifests/test_report_manifest.py b/src/manifests/test_report_manifest.py index db67c1f444..7fd6a64405 100644 --- a/src/manifests/test_report_manifest.py +++ b/src/manifests/test_report_manifest.py @@ -37,6 +37,8 @@ class TestReportManifest(ComponentManifest['TestReportManifest', 'TestComponents - name: with-security status: the status of the test run with this config. e.g. pass/fail yml: URL or local path to the component yml file + test_stdout: URL or local path to the test stdout log + test_stderr: URL or local path to the test stderr log cluster_stdout: - URL or local path to the OpenSearch cluster logs cluster_stderr: @@ -83,6 +85,8 @@ class TestReportManifest(ComponentManifest['TestReportManifest', 'TestComponents "name": {"type": "string"}, "status": {"type": "string"}, "yml": {"type": "string"}, + "test_stdout": {"type": "string"}, + "test_stderr": {"type": "string"}, "cluster_stdout": {"type": "list"}, "cluster_stderr": {"type": "list"} } @@ -176,6 +180,8 @@ def __init__(self, data: dict) -> None: self.name = data["name"] self.status = data["status"] self.yml = data["yml"] + self.test_stdout = data["test_stdout"] + self.test_stderr = data["test_stderr"] self.cluster_stdout = data["cluster_stdout"] self.cluster_stderr = data["cluster_stderr"] @@ -184,6 +190,8 @@ def __to_dict__(self) -> dict: "name": self.name, "status": self.status, "yml": self.yml, + "test_stdout": self.test_stdout, + "test_stderr": self.test_stderr, "cluster_stdout": self.cluster_stdout, "cluster_stderr": self.cluster_stderr } diff --git a/src/report_workflow/test_report_runner.py b/src/report_workflow/test_report_runner.py index dd001bdc98..d05498b65c 100644 --- a/src/report_workflow/test_report_runner.py +++ b/src/report_workflow/test_report_runner.py @@ -117,6 +117,8 @@ def component_entry(self, component_name: str, ci_group: int = None) -> Any: component_yml_ref = "URL not available" config_dict["yml"] = component_yml_ref config_dict["status"] = test_result + config_dict["test_stdout"] = get_test_logs(self.base_path, str(self.test_run_id), self.test_type, test_report_component_name, config, self.name)[0] + config_dict["test_stderr"] = get_test_logs(self.base_path, str(self.test_run_id), self.test_type, test_report_component_name, config, self.name)[1] config_dict["cluster_stdout"] = get_os_cluster_logs(self.base_path, str(self.test_run_id), self.test_type, test_report_component_name, config, self.name)[0] config_dict["cluster_stderr"] = get_os_cluster_logs(self.base_path, str(self.test_run_id), self.test_type, test_report_component_name, config, self.name)[1] component["configs"].append(config_dict) @@ -164,6 +166,16 @@ def generate_test_command(test_type: str, test_manifest_path: str, artifacts_pat return command +def get_test_logs(base_path: str, test_number: str, test_type: str, component_name: str, config: str, + product_name: str) -> typing.List[str]: + if base_path.startswith("https://"): + return ["/".join([base_path.strip("/"), "test-results", test_number, test_type, component_name, config, "stdout.txt"]), + "/".join([base_path.strip("/"), "test-results", test_number, test_type, component_name, config, "stderr.txt"])] + else: + return [os.path.join(base_path, "test-results", test_number, test_type, component_name, config, "stdout.txt"), + os.path.join(base_path, "test-results", test_number, test_type, component_name, config, "stderr.txt")] + + def get_os_cluster_logs(base_path: str, test_number: str, test_type: str, component_name: str, config: str, product_name: str) -> typing.List[list]: os_stdout: list = [] diff --git a/tests/tests_report_workflow/test_test_report_runner.py b/tests/tests_report_workflow/test_test_report_runner.py index a190b8f647..64aea0bc5e 100644 --- a/tests/tests_report_workflow/test_test_report_runner.py +++ b/tests/tests_report_workflow/test_test_report_runner.py @@ -117,12 +117,19 @@ def test_runner_component_entry_url(self, report_args_mock: MagicMock, validator self.assertEqual(test_run_component_dict.get("configs")[0]["name"], "with-security") self.assertEqual(test_run_component_dict.get("configs")[0]["yml"], "https://ci.opensearch.org/ci/dbc/mock/test-results/123/integ-test/geospatial/with-security/geospatial.yml") + self.assertEqual(test_run_component_dict.get("configs")[0]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/with-security/stdout.txt") + self.assertEqual(test_run_component_dict.get("configs")[0]["test_stderr"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/with-security/stderr.txt") self.assertEqual(test_run_component_dict.get("configs")[0]["cluster_stdout"][0], "https://ci.opensearch.org/ci" "/dbc/mock/test-results/123/integ-test/geospatial/with-security/local-cluster-logs/id-0/stdout.txt") self.assertEqual(test_run_component_dict.get("configs")[0]["cluster_stderr"][0], "https://ci.opensearch.org/ci" "/dbc/mock/test-results/123/integ-test/geospatial/with-security/local-cluster-logs/id-0/stderr.txt") - self.assertEqual(test_run_component_dict.get("configs")[1]["name"], "without-security") + self.assertEqual(test_run_component_dict.get("configs")[1]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/without-security/stdout.txt") + self.assertEqual(test_run_component_dict.get("configs")[1]["test_stderr"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/without-security/stderr.txt") self.assertEqual(test_run_component_dict.get("configs")[1]["cluster_stdout"][0], "https://ci.opensearch.org/ci" "/dbc/mock/test-results/123/integ-test/geospatial/without-security/local-cluster-logs/id-1/stdout.txt") self.assertEqual(test_run_component_dict.get("configs")[1]["cluster_stderr"][0], "https://ci.opensearch.org/ci" @@ -154,6 +161,8 @@ def test_runner_component_entry_local(self, report_args_mock: MagicMock, validat "https://ci.opensearch.org/ci/dbc/mock/test-results/123/integ-test/geospatial/with-security/geospatial.yml") self.assertEqual(test_run_component_dict.get("configs")[0]["cluster_stdout"][0], "https://ci.opensearch.org/ci" "/dbc/mock/test-results/123/integ-test/geospatial/with-security/local-cluster-logs/id-0/stdout.txt") + self.assertEqual(test_run_component_dict.get("configs")[0]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/with-security/stdout.txt") @patch("yaml.safe_load") @patch("validators.url") @@ -172,6 +181,10 @@ def test_runner_component_entry_url_invalid(self, report_args_mock: MagicMock, v self.assertEqual(test_run_component_dict.get("configs")[0]["status"], "Not Available") self.assertEqual(test_run_component_dict.get("configs")[0]["name"], "with-security") self.assertEqual(test_run_component_dict.get("configs")[0]["yml"], "URL not available") + self.assertEqual(test_run_component_dict.get("configs")[0]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/with-security/stdout.txt") + self.assertEqual(test_run_component_dict.get("configs")[1]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/without-security/stdout.txt") self.assertEqual(test_run_component_dict.get("configs")[0]["cluster_stdout"][0], "https://ci.opensearch.org/ci" "/dbc/mock/test-results/123/integ-test/geospatial/with-security/local-cluster-logs/id-0/stdout.txt") self.assertEqual(test_run_component_dict.get("configs")[1]["cluster_stdout"][0], "https://ci.opensearch.org/ci" @@ -200,6 +213,10 @@ def test_runner_component_entry_local_invalid(self, report_args_mock: MagicMock, self.assertEqual(test_run_component_dict.get("configs")[0]["status"], "Not Available") self.assertEqual(test_run_component_dict.get("configs")[0]["name"], "with-security") self.assertEqual(test_run_component_dict.get("configs")[0]["yml"], "URL not available") + self.assertEqual(test_run_component_dict.get("configs")[0]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/with-security/stdout.txt") + self.assertEqual(test_run_component_dict.get("configs")[1]["test_stdout"], "https://ci.opensearch.org/ci" + "/dbc/mock/test-results/123/integ-test/geospatial/without-security/stdout.txt") self.assertEqual(test_run_component_dict.get("configs")[0]["cluster_stdout"][0], "https://ci.opensearch.org/ci" "/dbc/mock/test-results/123/integ-test/geospatial/with-security/local-cluster-logs/id-0/stdout.txt") self.assertEqual(test_run_component_dict.get("configs")[1]["cluster_stdout"][0], "https://ci.opensearch.org/ci"