forked from mtusi2026/mtusi2026lab7
fix: address telemetry-backends-tls verify findings
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -743,6 +743,46 @@ def test_gateway_bind_requires_client_tls13_and_crl() -> None:
|
||||
assert "server collector 127.0.0.1:14318" in config
|
||||
|
||||
|
||||
def _section(config: str, kind: str, name: str = "") -> list[str]:
|
||||
"""Строки раздела `<kind> [<name>]` без комментариев."""
|
||||
out: list[str] = []
|
||||
inside = False
|
||||
head = [kind, name] if name else [kind]
|
||||
for line in config.splitlines():
|
||||
if line and not line[0].isspace():
|
||||
inside = line.split()[: len(head)] == head
|
||||
continue
|
||||
stripped = line.strip()
|
||||
if inside and stripped and not stripped.startswith("#"):
|
||||
out.append(stripped)
|
||||
return out
|
||||
|
||||
|
||||
def test_gateway_collector_down_closes_without_response() -> None:
|
||||
"""Спек `observability`, «Потери SDK при недоступном Collector» (правки
|
||||
verify change `telemetry-backends-tls`, W2): остановленный Collector —
|
||||
закрытие соединения шлюзом без ответа HTTP, а не 503. SDK 1.45 считает
|
||||
ответ 503 завершённым экспортом без потери (`_ExportResult` без
|
||||
исключения), ошибку соединения — потерей. Бэкенды метрик Collector
|
||||
отвечают 503 по-прежнему: Prometheus сам считает его отказом scrape."""
|
||||
config = GATEWAY_CFG.read_text(encoding="utf-8")
|
||||
assert "errorfile 503 /dev/null" in _section(
|
||||
config,
|
||||
"backend",
|
||||
"collector",
|
||||
)
|
||||
for name in ("collector_own", "collector_app"):
|
||||
assert not any(
|
||||
line.startswith("errorfile")
|
||||
for line in _section(config, "backend", name)
|
||||
), name
|
||||
# только backend приёма: в defaults и frontend правило задело бы и порты
|
||||
# метрик
|
||||
for kind, name in (("defaults", ""), ("frontend", "otlp")):
|
||||
lines = _section(config, kind, name)
|
||||
assert not any(line.startswith("errorfile") for line in lines), kind
|
||||
|
||||
|
||||
# --- модули без телеметрии ----------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user