ci(pegasus): emit test-case status metrics for flaky-test tracking
This commit is contained in:
parent
32a88efd9d
commit
5cec7b15c5
@ -8,6 +8,7 @@ Inputs:
|
|||||||
Outputs pushed:
|
Outputs pushed:
|
||||||
- platform_quality_gate_runs_total{suite="pegasus",status="ok|failed"}
|
- platform_quality_gate_runs_total{suite="pegasus",status="ok|failed"}
|
||||||
- pegasus_quality_gate_tests_total{suite="pegasus",result=*}
|
- pegasus_quality_gate_tests_total{suite="pegasus",result=*}
|
||||||
|
- platform_quality_gate_test_case_result{suite="pegasus",test=*,status=*}
|
||||||
- pegasus_quality_gate_coverage_percent{suite="pegasus"}
|
- pegasus_quality_gate_coverage_percent{suite="pegasus"}
|
||||||
- platform_quality_gate_workspace_line_coverage_percent{suite="pegasus"}
|
- platform_quality_gate_workspace_line_coverage_percent{suite="pegasus"}
|
||||||
- platform_quality_gate_source_lines_over_500_total{suite="pegasus"}
|
- platform_quality_gate_source_lines_over_500_total{suite="pegasus"}
|
||||||
@ -88,18 +89,20 @@ def _load_junit_cases(path: Path) -> list[tuple[str, str]]:
|
|||||||
|
|
||||||
cases: list[tuple[str, str]] = []
|
cases: list[tuple[str, str]] = []
|
||||||
for suite in suites:
|
for suite in suites:
|
||||||
for test_case in suite.findall("testcase"):
|
for case in suite.findall("testcase"):
|
||||||
case_name = (test_case.attrib.get("name") or "").strip()
|
name = (case.attrib.get("name") or "").strip()
|
||||||
class_name = (test_case.attrib.get("classname") or "").strip()
|
classname = (case.attrib.get("classname") or "").strip()
|
||||||
if not case_name:
|
if not name:
|
||||||
continue
|
continue
|
||||||
full_name = f"{class_name}.{case_name}" if class_name else case_name
|
test_id = f"{classname}::{name}" if classname else name
|
||||||
status = "passed"
|
status = "passed"
|
||||||
if test_case.find("failure") is not None or test_case.find("error") is not None:
|
if case.find("failure") is not None:
|
||||||
status = "failed"
|
status = "failed"
|
||||||
elif test_case.find("skipped") is not None:
|
elif case.find("error") is not None:
|
||||||
|
status = "error"
|
||||||
|
elif case.find("skipped") is not None:
|
||||||
status = "skipped"
|
status = "skipped"
|
||||||
cases.append((full_name, status))
|
cases.append((test_id, status))
|
||||||
return cases
|
return cases
|
||||||
|
|
||||||
|
|
||||||
@ -259,9 +262,7 @@ def main() -> int:
|
|||||||
|
|
||||||
b = _load_junit(backend_junit)
|
b = _load_junit(backend_junit)
|
||||||
f = _load_junit(frontend_junit)
|
f = _load_junit(frontend_junit)
|
||||||
backend_cases = _load_junit_cases(backend_junit)
|
test_cases = _load_junit_cases(backend_junit) + _load_junit_cases(frontend_junit)
|
||||||
frontend_cases = _load_junit_cases(frontend_junit)
|
|
||||||
test_cases = backend_cases + frontend_cases
|
|
||||||
totals = {
|
totals = {
|
||||||
"tests": b["tests"] + f["tests"],
|
"tests": b["tests"] + f["tests"],
|
||||||
"failures": b["failures"] + f["failures"],
|
"failures": b["failures"] + f["failures"],
|
||||||
@ -351,6 +352,7 @@ def main() -> int:
|
|||||||
"# TYPE pegasus_quality_gate_issues_total gauge",
|
"# TYPE pegasus_quality_gate_issues_total gauge",
|
||||||
f'pegasus_quality_gate_issues_total{{suite="{suite}"}} {len(gate_issues)}',
|
f'pegasus_quality_gate_issues_total{{suite="{suite}"}} {len(gate_issues)}',
|
||||||
"# TYPE pegasus_quality_gate_checks_total gauge",
|
"# TYPE pegasus_quality_gate_checks_total gauge",
|
||||||
|
"# TYPE platform_quality_gate_test_case_result gauge",
|
||||||
"# TYPE pegasus_quality_gate_build_info gauge",
|
"# TYPE pegasus_quality_gate_build_info gauge",
|
||||||
f"pegasus_quality_gate_build_info{_label_str(labels)} 1",
|
f"pegasus_quality_gate_build_info{_label_str(labels)} 1",
|
||||||
]
|
]
|
||||||
@ -358,7 +360,6 @@ def main() -> int:
|
|||||||
f'pegasus_quality_gate_checks_total{{suite="{suite}",check="{check_name}",result="{check_status}"}} 1'
|
f'pegasus_quality_gate_checks_total{{suite="{suite}",check="{check_name}",result="{check_status}"}} 1'
|
||||||
for check_name, check_status in checks.items()
|
for check_name, check_status in checks.items()
|
||||||
)
|
)
|
||||||
payload_lines.append("# TYPE platform_quality_gate_test_case_result gauge")
|
|
||||||
if test_cases:
|
if test_cases:
|
||||||
payload_lines.extend(
|
payload_lines.extend(
|
||||||
[
|
[
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user