forked from mtusi2026/mtusi2026lab5
Grade 5
This commit is contained in:
@@ -92,7 +92,7 @@ else:
|
||||
''', fault=fault)
|
||||
|
||||
|
||||
def main():
|
||||
def main(outbox_only=False):
|
||||
client = Client(os.getenv('BASE_URL', 'http://127.0.0.1:8080'))
|
||||
alice, bob, eve, chat = client.bootstrap()
|
||||
try:
|
||||
@@ -103,7 +103,9 @@ def main():
|
||||
check(not state(aid)['published'], 'outbox was already published')
|
||||
client.message(alice, chat, '', attachments=[aid])
|
||||
client.call('GET', f'/api/v1/attachments/{aid}/content', 409, actor=bob)
|
||||
compose('restart', 'api')
|
||||
# Hard crash after durable COMMIT while dispatcher is stopped: no publish yet.
|
||||
compose('kill', '-s', 'SIGKILL', 'api')
|
||||
compose('start', 'api')
|
||||
ready(client)
|
||||
check(state(aid)['status'] == 'queued', 'API restart lost upload')
|
||||
compose('start', 'dispatcher')
|
||||
@@ -119,6 +121,8 @@ def main():
|
||||
check(download['headers'].get_content_type() == variant['content_type'], 'variant MIME mismatch')
|
||||
check(client.call('GET', f'/api/v1/attachments/{aid}/content', actor=bob)['bytes'] == content, 'original changed')
|
||||
print('PASS: outbox COMMIT/publish gap, stopped worker, API and broker restart', flush=True)
|
||||
if outbox_only:
|
||||
return
|
||||
|
||||
for fault in ('after_objects', 'after_commit'):
|
||||
compose('stop', 'worker')
|
||||
@@ -194,4 +198,7 @@ else:
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--outbox-only', action='store_true', help='Only the COMMIT/publish crash scenario')
|
||||
main(parser.parse_args().outbox_only)
|
||||
|
||||
Reference in New Issue
Block a user