Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add opensearch cluster stdout and stderr logs to test results manifest #4352

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/manifests/test_report_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ 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
cluster_stdout:
- URL or local path to the OpenSearch cluster logs
cluster_stderr:
- URL or local path to the OpenSearch cluster error logs
"""

SCHEMA = {
Expand Down Expand Up @@ -61,6 +65,8 @@ class TestReportManifest(ComponentManifest['TestReportManifest', 'TestComponents
"name": {"type": "string"},
"status": {"type": "string"},
"yml": {"type": "string"},
"cluster_stdout": {"type": "list"},
"cluster_stderr": {"type": "list"}
}
},
},
Expand Down Expand Up @@ -140,12 +146,16 @@ def __init__(self, data: dict) -> None:
self.name = data["name"]
self.status = data["status"]
self.yml = data["yml"]
self.cluster_stdout = data["cluster_stdout"]
self.cluster_stderr = data["cluster_stderr"]

def __to_dict__(self) -> dict:
return {
"name": self.name,
"status": self.status,
"yml": self.yml
"yml": self.yml,
"cluster_stdout": self.cluster_stdout,
"cluster_stderr": self.cluster_stderr
}


Expand Down
34 changes: 31 additions & 3 deletions src/report_workflow/test_report_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import logging
import os
import typing
import urllib.request
from typing import Any
from urllib.error import HTTPError
Expand Down Expand Up @@ -100,6 +101,8 @@
component_yml_ref = "URL not available"
config_dict["yml"] = component_yml_ref
config_dict["status"] = test_result
config_dict["cluster_stdout"] = get_os_cluster_logs(self.base_path, str(self.test_run_id), self.test_type, 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, component_name, config, self.name)[1]
component["configs"].append(config_dict)
return component

Expand All @@ -120,11 +123,14 @@
return templates[template_type]


def generate_component_yml_ref(base_path: str, test_number: str, test_type: str, component_name: str, config: str) -> str:
def generate_component_yml_ref(base_path: str, test_number: str, test_type: str, component_name: str,
config: str) -> str:
if base_path.startswith("https://"):
return "/".join([base_path.strip("/"), "test-results", test_number, test_type, component_name, config, f"{component_name}.yml"])
return "/".join([base_path.strip("/"), "test-results", test_number, test_type, component_name, config,
f"{component_name}.yml"])
else:
return os.path.join(base_path, "test-results", test_number, test_type, component_name, config, f"{component_name}.yml")
return os.path.join(base_path, "test-results", test_number, test_type, component_name, config,

Check warning on line 132 in src/report_workflow/test_report_runner.py

View check run for this annotation

Codecov / codecov/patch

src/report_workflow/test_report_runner.py#L132

Added line #L132 was not covered by tests
f"{component_name}.yml")


def generate_test_command(test_type: str, test_manifest_path: str, artifacts_path: str, component: str = "") -> str:
Expand All @@ -135,4 +141,26 @@
return command


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 = []
os_stderr: list = []
cluster_ids: list

if product_name == 'opensearch':
cluster_ids = ['id-0'] if config == 'with-security' else ['id-1']
else:
cluster_ids = ['id-0', 'id-1'] if config == 'with-security' else ['id-2', 'id-3']

for ids in cluster_ids:
if base_path.startswith("https://"):
os_stdout.append("/".join([base_path.strip("/"), "test-results", test_number, test_type, component_name, config, f"local-cluster-logs/{ids}/stdout.txt"]))
os_stderr.append("/".join([base_path.strip("/"), "test-results", test_number, test_type, component_name, config, f"local-cluster-logs/{ids}/stderr.txt"]))
else:
os_stdout.append(os.path.join(base_path, "test-results", test_number, test_type, component_name, config, f"local-cluster-logs/{ids}/stdout.txt"))
os_stderr.append(os.path.join(base_path, "test-results", test_number, test_type, component_name, config, f"local-cluster-logs/{ids}/stderr.txt"))

Check warning on line 161 in src/report_workflow/test_report_runner.py

View check run for this annotation

Codecov / codecov/patch

src/report_workflow/test_report_runner.py#L160-L161

Added lines #L160 - L161 were not covered by tests

return [os_stdout, os_stderr]


TestReportRunner.__test__ = False # type:ignore
Loading
Loading