Реализовать лабораторную 7
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import os
|
||||
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
|
||||
|
||||
|
||||
def compose(*args):
|
||||
subprocess.run(["docker", "compose", *args], check=True, timeout=90,
|
||||
stdout=subprocess.DEVNULL)
|
||||
|
||||
|
||||
def main():
|
||||
client = Client()
|
||||
owner, member, _, chat = client.bootstrap()
|
||||
compose("stop", "worker", "dispatcher")
|
||||
attachment, original = client.attachment(owner, chat)
|
||||
client.message(owner, chat, "", attachments=[attachment["id"]])
|
||||
path = "/api/v1/attachments/" + attachment["id"]
|
||||
client.call("GET", path + "/content", 409, actor=owner)
|
||||
compose("restart", "api-a", "api-b", "broker")
|
||||
compose("start", "dispatcher", "worker")
|
||||
ready = client.wait_ready(member, attachment)
|
||||
check(client.call("GET", path + "/content", actor=member)["bytes"] == original,
|
||||
"original changed")
|
||||
check({v["name"] for v in ready["variants"]} == {"thumbnail", "crop", "optimized"},
|
||||
"missing variants")
|
||||
for variant in ready["variants"]:
|
||||
downloaded = client.call("GET", path + "/content?variant=" + variant["name"], actor=member)
|
||||
import hashlib
|
||||
check(hashlib.sha256(downloaded["bytes"]).hexdigest() == variant["sha256"], "variant checksum")
|
||||
print("PASS: queued attachment survives API/broker restart, 3 variants ready")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user