From 57a92b14c0e2280964cb4806fac7f1b92a0d7dbe Mon Sep 17 00:00:00 2001 From: Michael Eischer <eischer@cs.fau.de> Date: Thu, 2 Jul 2020 13:59:47 +0200 Subject: [PATCH] Add config check option to experiments When passing '--check' as first argument, then an experiment will run a basic configuration check. --- Makefile | 4 ++++ experiments/helper.sh | 7 ++++++- scripts/exp/exp-experiment | 10 +++++++++- scripts/test/benchmark.py | 9 +++++++++ scripts/test/helper/config-variants-generator.py | 12 +++--------- src/refit/config/REFITConfigTest.java | 14 ++++++++++++++ 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 src/refit/config/REFITConfigTest.java diff --git a/Makefile b/Makefile index 4f1689e..4e60f0f 100644 --- a/Makefile +++ b/Makefile @@ -30,5 +30,9 @@ tests: $(TEST_FILES) | $(BUILD_MARKER) mkdir -p bin/tests javac -d bin/tests -cp $(BUILD_DEST):$(LIBS):lib/junit-4.13.jar $^ +# basic config sanity check +check-config: refit + java -cp $(BUILD_DEST):$(LIBS) refit.config.REFITConfigTest + clean: -rm -rf bin || true diff --git a/experiments/helper.sh b/experiments/helper.sh index 16cb7b0..b70f050 100644 --- a/experiments/helper.sh +++ b/experiments/helper.sh @@ -6,9 +6,14 @@ HOME="$(cd `dirname $0` && pwd)" EXPERIMENT_NAME="$(basename "$HOME")" MAIN_DIR="$(cd ~/../.. && pwd)" err_code=1 +check="" config_files=( "scripts/config/java" "scripts/config/refit-overrides" ) +if [[ "$1" == "--check" ]]; then + check="--check" +fi + function cleanup() { # only try to restore a bckp file if it actually exists for i in "${config_files[@]}"; do @@ -40,7 +45,7 @@ done # queue experiment cd "$MAIN_DIR/scripts" -exp/exp remote -m "$SCRIPT" "$EXPERIMENT_NAME" "$EXPERIMENT_DURATION" +exp/exp remote $check -m "$SCRIPT" "$EXPERIMENT_NAME" "$EXPERIMENT_DURATION" # cleanup err_code=0 diff --git a/scripts/exp/exp-experiment b/scripts/exp/exp-experiment index 97392ac..cb35c09 100755 --- a/scripts/exp/exp-experiment +++ b/scripts/exp/exp-experiment @@ -5,6 +5,13 @@ SCRIPT_DIR="${BASE_DIR}/experiments" ERRORS=0 +check="" +if [[ "$1" == "--check" ]]; then + echo "Checking experiment configurations" + check="--check" + shift +fi + for cmd in "$@"; do if [[ "$cmd" == "" || ! -x "${SCRIPT_DIR}/$cmd/run.sh" ]]; then echo "Invalid experiment name $cmd" @@ -20,7 +27,7 @@ if [[ "$ERRORS" == 0 ]]; then for cmd in "$@"; do if [[ "$cmd" != "" || -x "${SCRIPT_DIR}/$cmd/run.sh" ]]; then pushd "${SCRIPT_DIR}/$cmd" > /dev/null - if ! ./run.sh ; then + if ! ./run.sh $check ; then echo "!!! Execution failed !!!" exit 1 fi @@ -28,6 +35,7 @@ if [[ "$ERRORS" == 0 ]]; then fi done else + echo "Usage: exp experiment [--check] experiment_name [experiment_name...]" echo "Available experiments:" cd "$SCRIPT_DIR" for i in *; do diff --git a/scripts/test/benchmark.py b/scripts/test/benchmark.py index bcbf5ba..fb24e2b 100755 --- a/scripts/test/benchmark.py +++ b/scripts/test/benchmark.py @@ -489,6 +489,8 @@ def execute(cls, cmd_args): queue_parser.add_argument("-p", "--prio", help="Use priority queue", action="store_true") queue_parser.add_argument("-m", "--multi", help="Generate variants", action="store_true") queue_parser.add_argument("-n", "--dry-run", help="Prepare only benchmark execution", action="store_true") + queue_parser.add_argument("-c", "--check", help="Run configuration check for every experiment variant. " + "Implies dry-run", action="store_true") queue_parser.add_argument("--parent-folder", help="Enqueue the whole repository parent folder", action="store_true") queue_parser.add_argument("testfile", help="test script which controls the benchmark execution") @@ -568,6 +570,8 @@ def execute(cls, cmd_args): return 1 elif args.cmd == "queue": experiment_name = gen_experiment_name(args) + if args.check: + args.dry_run = True success = prepare(args, experiment_name) and ( args.dry_run or queue(args.prio, experiment_name, args.parent_folder)) if success: @@ -612,7 +616,12 @@ def prepare(args, experiment_name): print("Generating configuration variants") config_helper(["./test/helper/config-variants-generator.py", "-n", args.scenario, "echo", '{}'], variant_file, scripts_dir) + + if args.check: + subprocess.run(["./test/helper/config-variants-generator.py", args.scenario, "-d", MAIN_DIR, + "make", "check-config"], cwd=scripts_dir, check=True) else: + subprocess.run(["make", "check-config"], cwd=MAIN_DIR, check=True) with open(variant_file, "w") as f: f.write(args.scenario) diff --git a/scripts/test/helper/config-variants-generator.py b/scripts/test/helper/config-variants-generator.py index 5bd2cfb..da88536 100755 --- a/scripts/test/helper/config-variants-generator.py +++ b/scripts/test/helper/config-variants-generator.py @@ -124,14 +124,10 @@ def execute(scenario): return cmd = [] - has_placeholder = False for part in SCRIPT: if part == "{}": part = scn - has_placeholder = True cmd.append(part) - if not has_placeholder: - cmd.append(scn) ret = subprocess.call(cmd, cwd=CWD) max_ret_code = max(max_ret_code, ret) @@ -175,17 +171,15 @@ def run(): 'just print the scenarios.') parser.add_argument('-v', '--verbose', action='store_true', help='Verbose printing of config modification') - parser.add_argument('-s', '--scenario', help='Only run the specified scenario. If multiple' + parser.add_argument('-s', '--scenario', help='Only run the specified scenario. If multiple ' 'configurations have the same name, all of them will be executed.') parser.add_argument('-c', '--config-file', help='Use the specified config file as source') parser.add_argument('-d', '--directory', help='Execute script in the given directory. Defaults ' 'to the current directory.') parser.add_argument('scenario_prefix', help='Prefix for the assembled scenario name, can be ' 'empty (pass an empty string: "").') - parser.add_argument('script', nargs='+', help='Command to run for every scenario. ' - 'The placeholder {} will be replaced with the scenario name. If no ' - 'placeholder exists the scenario name will be passed as the last ' - 'parameter.') + parser.add_argument('script', nargs='+', help='Command to run for every scenario. If a placeholder {} exists,' + ' then it will be replaced with the scenario name.') args = parser.parse_args() scenario_prefix = [args.scenario_prefix.strip("-")] diff --git a/src/refit/config/REFITConfigTest.java b/src/refit/config/REFITConfigTest.java new file mode 100644 index 0000000..5f1e00d --- /dev/null +++ b/src/refit/config/REFITConfigTest.java @@ -0,0 +1,14 @@ +package refit.config; + +public class REFITConfigTest { + public static void main(String[] args) { + // It doesn't matter much which config parameter is accessed + // It is only important to load and thereby initialize the REFITConfig class + if (REFITConfig.ADDRESSES.length > 0) { + System.exit(0); + } else { + System.err.println("Configuration without replicas/clients???"); + System.exit(1); + } + } +} -- GitLab