test: prepare isolated clean-clone verification and stronger cache checks

This commit is contained in:
2026-11-07 08:19:20 +03:00
parent 171b6de9c8
commit 7466a09178
8 changed files with 312 additions and 2 deletions
+21
View File
@@ -64,6 +64,12 @@ def main():
with httpx.Client(base_url=BASE, trust_env=False, timeout=15) as client:
user, password, session = actor(client)
headers = auth(session)
expiry_query = (
"SELECT expires_at::text FROM sessions WHERE user_id='"
+ user["id"]
+ "'"
)
expires_before = sql(expiry_query)
chat = client.post(
"/api/v1/chats",
headers=headers,
@@ -80,6 +86,7 @@ def main():
command(["sh", "scripts/restart.sh"])
ready()
after = instances()
assert sql(expiry_query) == expires_before
for role in before:
assert before[role]["started_at"] != after[role]["started_at"]
assert (
@@ -87,6 +94,7 @@ def main():
== message_id
)
receipt["persistence"] = {
"absolute_expiry_unchanged": True,
"same_token": True,
"same_message": True,
"before": before,
@@ -177,6 +185,18 @@ def main():
)
receipt["cache_flush_preserves_truth"] = True
for mode in ["pause", "stop"]:
# Дожидаемся окончания circuit backoff и доказываем cache hit
# непосредственно перед отказом источника истины.
for _ in range(30):
assert (
client.get("/api/v1/users/me", headers=headers).status_code
== 200
)
if cache("EXISTS", "user:" + user["id"]) == "1":
break
time.sleep(0.25)
else:
raise AssertionError("User cache not primed before PG fault")
compose(mode, "postgres")
try:
started = time.perf_counter()
@@ -190,6 +210,7 @@ def main():
)
assert client.get("/health/live").status_code == 200
receipt["postgres_" + mode] = {
"cache_card_present_before_failure": True,
"status": result.status_code,
"seconds": elapsed,
"cached_identity_not_trusted": True,