forked from mtusi2026/mtusi2026lab3
19 lines
939 B
Python
19 lines
939 B
Python
"""Run the unchanged public make targets with executable Linux action hooks."""
|
|
import argparse
|
|
from pathlib import Path
|
|
import subprocess
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
p = argparse.ArgumentParser()
|
|
p.add_argument('target', choices=['check', 'validate', 'test', 'test-own', 'test-race', 'test-persistence', 'test-failover'])
|
|
args = p.parse_args()
|
|
command = ['docker', 'run', '--rm', '--network', 'mtusi-lab3_default',
|
|
'--mount', 'type=bind,source='+str(root)+',target=/workspace']
|
|
hooks = {'test-persistence': 'scripts/restart.sh', 'test-failover': 'scripts/stop-one.sh'}
|
|
if args.target in hooks:
|
|
command += ['--mount', 'type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock']
|
|
command += ['mtusi-messenger:lab3-tests', 'make', args.target, 'BASE_URL=http://lb:8080']
|
|
if args.target in hooks:
|
|
command += ['ACTION_SCRIPT='+hooks[args.target]]
|
|
raise SystemExit(subprocess.call(command, cwd=root))
|