pr / done (pull_request) Canceled after 0s
2026-11-12~13 백엔드 runner에서 흔들린 시험은 넷이다. 그런데 기록이 공유 노트와 세션 메시지에 흩어져 있다. 같은 모양(벽시계 상한, 스레드 시작 순서)이 다시 들어와도 리뷰 기준에는 「스레드 없음」 단언만 적혀 있어서 막을 근거가 없다. - `docs/ledger/flaky-tests.jsonl`: 흔들림 하나가 한 줄이다. 칸과 범주의 정본은 design-docs `ci/manual.md` 8.5절이다. 첫 네 줄: - compose 기동 경쟁(run 100, #13으로 고침) - gRPC 서버 deadline(run 221, #34) - HTTP client slow drip JDK(run 228, #34) - JPA 동시 writer replay 순서(run 260, #39 열림) `.gitattributes`에 `merge=union`을 준다. `scripts/tests/test_ledger.py`가 칸·범주·날짜 형식을 본다. - review-criteria.md 「타이밍에 기대지 않나」: 벽시계 상한 단언과 스레드 시작 순서 단언을 더하고, 매뉴얼 8.4절을 가리킨다. - gates.md 「원래 있던 실패 가리기」: 반복마다 시작 부하를 적게 한다. runner 실패면 그 시각에 잠금 아래 돈 desktop 실행도 적는다(runner는 잠금 밖이다). 흔들림이면 장부에 한 줄을 더하고, 상한을 늘리거나 재시도를 붙이지 않고 8.4절대로 고친다. PR #12가 실패했다는 HTTP/2 흔들림은 넣지 않았다. 그 PR의 runner run은 모두 cancelled라 어느 시험인지 특정할 수 없다. 검증: scripts/verify.sh docs(노트북) rc=0. test_ledger의 새 시험이 잘못된 범주를 잡는지 한 줄을 바꿔 실패를 확인하고 되돌렸다. Refs: design-docs ci/03-time-reduction-plan.md FLAKY-1
72 lines
3.3 KiB
Python
72 lines
3.3 KiB
Python
"""docs/ledger/의 장부 두 파일이 정해진 형식인지 본다(estimates.jsonl은 docs/ledger/README.md,
|
|
flaky-tests.jsonl은 design-docs ci/manual.md 8.5절).
|
|
|
|
python3 -m unittest discover -s scripts/tests
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import unittest
|
|
from datetime import date, datetime
|
|
from pathlib import Path
|
|
|
|
REPO = Path(__file__).resolve().parent.parent.parent
|
|
LEDGER = REPO / "docs/ledger/estimates.jsonl"
|
|
KINDS = {"estimate", "actual", "retro"}
|
|
COMMON = ("schema", "kind", "task", "recorded_at")
|
|
RANGES = ("minutes", "calls", "output_tokens")
|
|
FLAKY = REPO / "docs/ledger/flaky-tests.jsonl"
|
|
FLAKY_FIELDS = {"date", "test", "category", "first_run", "verdict", "quarantined_until", "fixed_by"}
|
|
FLAKY_CATEGORIES = {"fixed-time", "concurrency-order", "resource-io", "test-order", "external"}
|
|
|
|
|
|
def lines() -> list[dict]:
|
|
return [json.loads(line) for line in LEDGER.read_text(encoding="utf-8").splitlines() if line.strip()]
|
|
|
|
|
|
class LedgerTest(unittest.TestCase):
|
|
def test_every_line_is_json_with_the_common_fields(self) -> None:
|
|
for number, entry in enumerate(lines(), start=1):
|
|
self.assertTrue(set(COMMON) <= entry.keys(), f"line {number}: {sorted(set(COMMON) - entry.keys())}")
|
|
self.assertEqual(entry["schema"], 1, number)
|
|
self.assertIn(entry["kind"], KINDS, number)
|
|
datetime.fromisoformat(entry["recorded_at"])
|
|
|
|
def test_an_estimate_has_ordered_ranges_and_a_basis(self) -> None:
|
|
for entry in (e for e in lines() if e["kind"] == "estimate"):
|
|
for field in RANGES:
|
|
values = entry[field]
|
|
self.assertLessEqual(values["p30"], values["p50"], (entry["task"], field))
|
|
self.assertLessEqual(values["p50"], values["p80"], (entry["task"], field))
|
|
self.assertTrue(entry["basis"].strip(), entry["task"])
|
|
|
|
def test_an_actual_follows_its_estimate_and_names_the_band_it_fell_in(self) -> None:
|
|
entries = lines()
|
|
for position, entry in enumerate(entries):
|
|
if entry["kind"] != "actual":
|
|
continue
|
|
estimates = [e for e in entries[:position] if e["kind"] == "estimate" and e["task"] == entry["task"]]
|
|
self.assertTrue(estimates, f"{entry['task']}: an actual line needs an earlier estimate line")
|
|
bands = estimates[-1]["minutes"]
|
|
expected = next((band for band in ("p30", "p50", "p80") if entry["active_minutes"] <= bands[band]), "over")
|
|
self.assertEqual(entry["within"], expected, entry["task"])
|
|
|
|
|
|
class FlakyLedgerTest(unittest.TestCase):
|
|
def test_every_flaky_line_has_exactly_the_manual_fields_and_a_known_category(self) -> None:
|
|
for number, line in enumerate(FLAKY.read_text(encoding="utf-8").splitlines(), start=1):
|
|
if not line.strip():
|
|
continue
|
|
entry = json.loads(line)
|
|
self.assertEqual(entry.keys(), FLAKY_FIELDS, f"line {number}")
|
|
self.assertIn(entry["category"], FLAKY_CATEGORIES, f"line {number}")
|
|
date.fromisoformat(entry["date"])
|
|
if entry["quarantined_until"]:
|
|
date.fromisoformat(entry["quarantined_until"])
|
|
self.assertTrue(entry["test"].strip() and entry["verdict"].strip(), f"line {number}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|