Реализовать асинхронную обработку вложений
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prove that a committed outbox survives publisher downtime."""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from client import Client, arguments, check, run
|
||||
|
||||
|
||||
def main():
|
||||
def configure(parser):
|
||||
parser.add_argument('--stop-publisher-script', required=True)
|
||||
parser.add_argument('--start-publisher-script', required=True)
|
||||
|
||||
args = arguments('Transactional outbox recovery', configure)
|
||||
stop = Path(args.stop_publisher_script).resolve()
|
||||
start = Path(args.start_publisher_script).resolve()
|
||||
check(all(path.is_file() and os.access(path, os.X_OK) for path in (stop, start)), 'scripts must be executable')
|
||||
client = Client(args.base_url, args.ca_file)
|
||||
alice, bob, _eve, chat = client.bootstrap()
|
||||
subprocess.run([str(stop)], check=True)
|
||||
attachment, _content = client.attachment(alice, chat)
|
||||
time.sleep(1)
|
||||
queued = client.call(
|
||||
'GET', f'/api/v1/attachments/{attachment["id"]}', actor=bob, schema='Attachment'
|
||||
)['json']
|
||||
check(queued['status'] == 'queued', 'job escaped outbox while publisher was stopped')
|
||||
subprocess.run([str(start)], check=True)
|
||||
ready = client.wait_ready(bob, attachment)
|
||||
check(ready['status'] == 'ready', 'outbox did not recover committed job')
|
||||
print('PASS: COMMIT-before-publish recovered without a new upload')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(main)
|
||||
Reference in New Issue
Block a user