diff --git a/scripts/bench-spec-ab.py b/scripts/bench-spec-ab.py index 4984cc0..f22931b 100755 --- a/scripts/bench-spec-ab.py +++ b/scripts/bench-spec-ab.py @@ -39,6 +39,7 @@ constraint — it is draftless and is added to the chain unconditionally. """ import argparse import json +import os import re import subprocess import sys @@ -197,16 +198,20 @@ def main(): args = ap.parse_args() configs = parse_configs(args.configs) if args.configs else DEFAULT_CONFIGS + # Absolute paths: the launcher must not depend on the caller's cwd, and a + # relative path plus a `cd` to its own directory double-counts the prefix. + env_file = os.path.abspath(args.env_file) + serve_script = os.path.abspath(args.serve_script) base, logfile = args.base_url, args.log results = {} log("spec A/B start: " + ", ".join(n for n, _ in configs) + " (unit " + UNIT + " stopped for the duration)", logfile) stop_unit() for name, over in configs: - env_path = write_env(args.env_file, name, over) + env_path = write_env(env_file, name, over) logf = "/tmp/spec-ab-" + name.replace("/", "_") + ".log" - sh("cd " + sh("dirname " + args.serve_script) + " && FRANK_MEDIUM_ENV_FILE=" + env_path + - " setsid bash " + args.serve_script + " > " + logf + " 2>&1 < /dev/null &") + sh("FRANK_MEDIUM_ENV_FILE=" + env_path + " setsid bash " + serve_script + + " > " + logf + " 2>&1 < /dev/null &") if not wait_health(base): log(name + ": FAILED to become healthy -- " + sh("tail -3 " + logf), logfile) results[name] = {"error": "not healthy", "tail": sh("tail -6 " + logf)}