test(observability): await measured recovery and verify store persistence

This commit is contained in:
2026-11-20 16:36:18 +03:00
parent ba1c658bd7
commit e11ee51e90
8 changed files with 11917 additions and 9 deletions
+18 -6
View File
@@ -268,19 +268,28 @@ def main():
json.dumps(report, ensure_ascii=False, indent=2) + "\n"
)
def hold(name, seconds):
def hold(name, seconds, *, until_clear=None, max_seconds=None):
load.phase = name
phase = {
"name": name,
"start": time.time(),
"planned_seconds": seconds,
"maximum_seconds": max_seconds or seconds,
}
report["phases"].append(phase)
deadline = time.monotonic() + seconds
minimum_end = time.monotonic() + seconds
deadline = time.monotonic() + (max_seconds or seconds)
start_index = len(report["samples"])
while time.monotonic() < deadline:
report["samples"].append(snapshot(name))
sample = snapshot(name)
report["samples"].append(sample)
save()
if (
until_clear is not None
and time.monotonic() >= minimum_end
and not until_clear.intersection(firing([sample]))
):
break
time.sleep(min(5, max(0, deadline - time.monotonic())))
phase["end"] = time.time()
phase["firing"] = sorted(firing(report["samples"][start_index:]))
@@ -352,14 +361,17 @@ def main():
restore_started = time.time()
restore()
restore_finished = time.time()
recovered = hold(
signal + "_recovery", 150 if signal == "api" else 240
)
expected = (
{"ApiFastBurn", "ApiSlowBurn", "ApiHighErrorRate"}
if signal == "api"
else {"ReadyFastBurn", "ReadySlowBurn", "QueueLagGrowing"}
)
recovered = hold(
signal + "_recovery",
150 if signal == "api" else 240,
until_clear=expected,
max_seconds=600,
)
assert expected <= set(degraded["firing"]), (
signal,
degraded["firing"],