41 lines
2.0 KiB
Python
41 lines
2.0 KiB
Python
"""Run all checks and save actual outputs. Stop on the first failure."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
root=Path(__file__).resolve().parents[1]
|
|
os.chdir(root)
|
|
os.environ.setdefault('BASE_URL','http://localhost:8084')
|
|
(root/'evidence').mkdir(exist_ok=True)
|
|
|
|
def run(name, args, stdin=None):
|
|
result=subprocess.run(args,input=stdin,text=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
|
|
(root/'evidence'/name).write_text(result.stdout)
|
|
print(result.stdout,end='')
|
|
if result.returncode:
|
|
raise SystemExit(result.returncode)
|
|
|
|
run('check.txt',['make','check'])
|
|
run('unit.txt',[sys.executable,'student-tests/unit.py'])
|
|
run('smoke.txt',['make','test','BASE_URL='+os.environ['BASE_URL']])
|
|
run('student-tests.txt',[sys.executable,'student-tests/verify.py'])
|
|
subprocess.run(['docker','compose','stop','cleaner'],check=True)
|
|
try:
|
|
run('storage-checks.txt',['docker','compose','exec','-T','api1','python','-'],
|
|
(root/'student-tests/storage_checks.py').read_text())
|
|
finally:
|
|
subprocess.run(['docker','compose','start','cleaner'],check=True)
|
|
run('outage.txt',[sys.executable,'student-tests/outage.py'])
|
|
run('bootstrap-repeat.txt',['docker','compose','run','--rm','s3-init'])
|
|
run('containers-before.txt',['docker','compose','ps','--format','json'])
|
|
run('persistence.txt',['make','test-persistence','ACTION_SCRIPT=scripts/restart.sh','BASE_URL='+os.environ['BASE_URL']])
|
|
run('containers-after.txt',['docker','compose','ps','--format','json'])
|
|
try:
|
|
run('failover.txt',['make','test-failover','ACTION_SCRIPT=scripts/stop-one.sh','BASE_URL='+os.environ['BASE_URL']])
|
|
finally:
|
|
subprocess.run(['docker','compose','start','api1','api2'],check=True)
|
|
# Compose waits for the API's actual readiness after restoring the replica.
|
|
subprocess.run(['docker','compose','up','-d','--wait','api1','api2'],check=True)
|
|
run('memory.txt',[sys.executable,'student-tests/memory.py'])
|
|
print('All requested checks passed; actual results are in evidence/.')
|