forked from mtusi2026/mtusi2026lab2
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Доказывает корректное чтение после restart Redis."""
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests"))
|
|
from client import Client, check, run # noqa: E402
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def main() -> None:
|
|
client = Client()
|
|
alice, _bob, _eve, chat = client.bootstrap()
|
|
message = client.message(alice, chat, "survives Redis restart")["json"]
|
|
path = "/api/v1/chats/" + chat["id"] + "/messages?limit=100"
|
|
before = client.call("GET", path, actor=alice, schema="MessagePage")["json"]
|
|
check(before["items"] == [message], "initial cache fill failed")
|
|
subprocess.run(["docker", "compose", "restart", "redis"], cwd=ROOT, check=True)
|
|
time.sleep(1)
|
|
after = client.call("GET", path, actor=alice, schema="MessagePage")["json"]
|
|
check(after["items"] == [message], "history changed after Redis restart")
|
|
print("PASS: history remains correct after Redis restart")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(main)
|