ci(atlasbot): fix test-case metric label escaping
This commit is contained in:
parent
8f3d3c2550
commit
9e15badcb1
@ -23,6 +23,11 @@ from pathlib import Path
|
||||
QUALITY_SUCCESS_STATES = {"ok", "pass", "passed", "success", "compliant"}
|
||||
|
||||
|
||||
def _escape_label(value: str) -> str:
|
||||
"""Escape Prometheus label values safely."""
|
||||
return value.replace("\\", "\\\\").replace("\n", "\\n").replace('"', '\\"')
|
||||
|
||||
|
||||
def _as_int(node: ET.Element, name: str) -> int:
|
||||
raw = node.attrib.get(name) or "0"
|
||||
try:
|
||||
@ -270,6 +275,10 @@ def main() -> int:
|
||||
) + "\n"
|
||||
else:
|
||||
payload += f'platform_quality_gate_test_case_result{{suite="{suite}",test="__no_test_cases__",status="skipped"}} 1\n'
|
||||
payload += "\n".join(
|
||||
f'platform_quality_gate_test_case_result{{suite="{suite}",test="{_escape_label(test_name)}",status="{_escape_label(test_status)}"}} 1'
|
||||
for test_name, test_status in test_cases
|
||||
) + "\n"
|
||||
payload += "\n".join(
|
||||
f'atlasbot_quality_gate_checks_total{{suite="{suite}",check="{check_name}",result="{check_status}"}} 1'
|
||||
for check_name, check_status in checks.items()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user