Phase 27: Failure injection
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Qualify disposable Laravel failure boundaries and verify acceptance evidence."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
FAILURES = ("backup", "tamper", "health", "crash")
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def read(path):
|
||||
return json.loads(path.read_text())
|
||||
|
||||
|
||||
def require(condition, message):
|
||||
if not condition:
|
||||
raise RuntimeError(message)
|
||||
|
||||
|
||||
def inject(args):
|
||||
args.output.mkdir(mode=0o700)
|
||||
for scenario in FAILURES:
|
||||
with (args.output / f"{scenario}.json").open("x") as report:
|
||||
subprocess.run(
|
||||
[sys.executable, "-B", str(ROOT / "scripts/dev3-laravel.py"),
|
||||
"--dependencies", str(args.dependencies), "--php", str(args.php),
|
||||
"--root", str(args.output / scenario), "--scenario", scenario],
|
||||
stdout=report, stdin=subprocess.DEVNULL, check=True,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
modes = parser.add_subparsers(required=True)
|
||||
failure = modes.add_parser("inject")
|
||||
failure.add_argument("--output", type=Path, required=True)
|
||||
failure.add_argument("--dependencies", type=Path, required=True)
|
||||
failure.add_argument("--php", type=Path, required=True)
|
||||
failure.set_defaults(action=inject)
|
||||
args = parser.parse_args()
|
||||
os.umask(0o077)
|
||||
args.action(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user