forked from mtusi2026/mtusi2026lab5
Исправить замечания перепроверки: непредусмотренные ошибки worker, pull_policy, тест окна D
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
и staging-объект убирает janitor после grace.
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
@@ -34,12 +35,22 @@ def find_by_filename(name):
|
||||
|
||||
|
||||
def raw_upload(c, actor, chat, name, fault):
|
||||
"""Процесс API умирает посреди запроса: ответ формирует LB (без X-Instance-Id),
|
||||
поэтому здесь urllib напрямую, а не проверяющий контракт Client.call."""
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
req = urllib.request.Request(
|
||||
c.base + "/api/v1/chats/%s/attachments?filename=%s" % (chat["id"], name), data=SAMPLE_PNG, method="POST",
|
||||
headers={"Content-Type": "image/png", "X-Fault-Inject": fault, "Authorization": "Bearer " + actor["token"]})
|
||||
try:
|
||||
r = c.call("POST", "/api/v1/chats/%s/attachments?filename=%s" % (chat["id"], name), [502, 503, 504],
|
||||
actor=actor, raw=SAMPLE_PNG, headers={"Content-Type": "image/png", "X-Fault-Inject": fault})
|
||||
return "http %d" % r["status"]
|
||||
except Failure as exc:
|
||||
return str(exc)
|
||||
with urllib.request.urlopen(req, timeout=30) as r:
|
||||
return {"http": r.status, "x_instance_id": r.headers.get("X-Instance-Id")}
|
||||
except urllib.error.HTTPError as e:
|
||||
body = e.read(2000)
|
||||
return {"http": e.code, "x_instance_id": e.headers.get("X-Instance-Id"),
|
||||
"error_code": json.loads(body)["error"]["code"] if body.startswith(b"{") else None}
|
||||
except OSError as exc:
|
||||
return {"connection_error": type(exc).__name__}
|
||||
|
||||
|
||||
def main():
|
||||
@@ -121,8 +132,7 @@ def main():
|
||||
"--grace-seconds", "2").stdout
|
||||
real = compose("exec", "-T", "janitor", "python", "/app/src/janitor.py", "--once",
|
||||
"--grace-seconds", "2").stdout
|
||||
import json as _j
|
||||
dry, real = _j.loads(dry.strip().splitlines()[-1]), _j.loads(real.strip().splitlines()[-1])
|
||||
dry, real = json.loads(dry.strip().splitlines()[-1]), json.loads(real.strip().splitlines()[-1])
|
||||
gone = find_by_filename(name) is None
|
||||
check(row[0] in dry["abandoned_ids"] and gone, "E: janitor did not clean")
|
||||
res["E"] = {"attachment_id": row[0], "janitor_dry_run": {k: dry[k] for k in ("abandoned_pending", "orphan_objects",
|
||||
|
||||
Reference in New Issue
Block a user