feat(lab4): implement S3 attachments with fault tolerance
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
"""Explicit full lab4 validation; includes lab4-only restarts and fault injection."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
os.chdir(root)
|
||||
env = dict(os.environ, BASE_URL='http://localhost:8084')
|
||||
env['PATH'] = '/Applications/Docker.app/Contents/Resources/bin:' + env.get('PATH', '')
|
||||
compose = ['docker', 'compose', '--env-file', '.env']
|
||||
checks = [
|
||||
('check', ['make', 'check']),
|
||||
('validate', ['make', 'validate', 'PYTHON=.venv/bin/python']),
|
||||
('image-pull', ['docker', 'pull', 'bitnamilegacy/minio:2025.7.23-debian-12-r5@sha256:6dabb4a2088c9a79908de3bc05f4586c23ad2182c8908e7e3acbf61c1467fb20']),
|
||||
('compose-config', compose + ['config', '--quiet']),
|
||||
('build', compose + ['up', '-d', '--build']),
|
||||
('smoke', ['make', 'test', 'BASE_URL=http://localhost:8084']),
|
||||
('persistence', ['make', 'test-persistence', 'BASE_URL=http://localhost:8084', 'ACTION_SCRIPT=scripts/restart.sh']),
|
||||
('failover', ['make', 'test-failover', 'BASE_URL=http://localhost:8084', 'ACTION_SCRIPT=scripts/stop-one.sh']),
|
||||
('restore-after-failover', compose + ['start', 'api']),
|
||||
('negative', [sys.executable, 'student-tests/negative.py']),
|
||||
('faults', [sys.executable, 'student-tests/faults.py']),
|
||||
('attachment-failover', [sys.executable, 'student-tests/attachment-failover.py']),
|
||||
('upload-load', [sys.executable, 'student-tests/upload-load.py']),
|
||||
('cleanup', ['scripts/cleanup.sh']),
|
||||
('cleanup-repeat', ['scripts/cleanup.sh']),
|
||||
('storage-audit', [sys.executable, 'student-tests/audit-storage.py']),
|
||||
]
|
||||
results = []
|
||||
try:
|
||||
for name, command in checks:
|
||||
print('RUN:', name, flush=True)
|
||||
start = time.monotonic()
|
||||
with (root / 'evidence' / (name + '.txt')).open('w') as output:
|
||||
result = subprocess.run(command, env=env, stdout=output, stderr=subprocess.STDOUT)
|
||||
record = {'check': name, 'command': command, 'exit_code': result.returncode, 'seconds': round(time.monotonic()-start, 3)}
|
||||
results.append(record)
|
||||
(root / 'evidence/verification.json').write_text(json.dumps(results, indent=2) + '\n')
|
||||
print(('PASS:' if result.returncode == 0 else 'FAIL:'), name, 'seconds=', record['seconds'], flush=True)
|
||||
if result.returncode:
|
||||
print((root / 'evidence' / (name + '.txt')).read_text(), flush=True)
|
||||
raise SystemExit(result.returncode)
|
||||
if name in ('restore-after-failover', 'attachment-failover'):
|
||||
time.sleep(4)
|
||||
finally:
|
||||
subprocess.run(compose + ['start', 'postgres', 's3', 'api'], env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
Reference in New Issue
Block a user