feat:report
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""После ready staging пуст (объект перенесён в final)."""
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
from tests.client import Client, check
|
||||
from student_tests.common import upload, wait_status, psql, docker, ok, fail
|
||||
|
||||
def main():
|
||||
c = Client()
|
||||
a, b, e, ch = c.bootstrap()
|
||||
content = Path('tests/fixtures/sample.png').read_bytes()
|
||||
att = upload(c, a, ch, content)
|
||||
staging = psql("SELECT staging_key FROM attachments WHERE id='%s'" % att['id'])
|
||||
check(staging.startswith('staging/'), 'staging_key does not start with staging/')
|
||||
att = wait_status(c, a, att['id'], 'ready')
|
||||
root_user = open('secrets/minio_root_user.txt').read().strip()
|
||||
root_pass = open('secrets/minio_root_password.txt').read().strip()
|
||||
docker('exec', '-T', 's3', 'mc', 'alias', 'set', 'local_check',
|
||||
'http://localhost:9000', root_user, root_pass, '--api', 'S3v4')
|
||||
|
||||
r = subprocess.run(
|
||||
['docker', 'compose', 'exec', '-T', 's3', 'mc', 'stat',
|
||||
'local_check/messenger-attachments/' + staging],
|
||||
capture_output=True, text=True)
|
||||
combined = ((r.stdout or '') + (r.stderr or '')).lower()
|
||||
check('does not exist' in combined or 'not found' in combined,
|
||||
'staging object still present: %s\n%s' % (staging, combined))
|
||||
ok('staging object removed after ready (mc rc=%d)' % r.returncode)
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except Exception as exc:
|
||||
fail(str(exc))
|
||||
Reference in New Issue
Block a user