From 35b04ae1ce559bc41126ce1610ba6543c3dc5652 Mon Sep 17 00:00:00 2001 From: jondkent Date: Mon, 2 Dec 2019 15:34:58 +0000 Subject: [PATCH] refactor(perturb): removed unused IS_TEST_ONLY variable and various tests --- simulation-scripts/perturb.sh | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/simulation-scripts/perturb.sh b/simulation-scripts/perturb.sh index a534ee03..0d54c011 100755 --- a/simulation-scripts/perturb.sh +++ b/simulation-scripts/perturb.sh @@ -57,7 +57,6 @@ SCENARIO='' MASTER_HOST="" SLAVE_HOSTS="" BASTION_HOST="" -IS_TEST_ONLY=0 IS_FORCE=0 main() { @@ -69,36 +68,29 @@ main() { local SCENARIO_DIR="scenario/${SCENARIO}/" - if [[ "${IS_TEST_ONLY:-}" == 1 ]]; then - success "In test mode, skipping deployment of ${SCENARIO}" - else - - source test-func.sh + source test-func.sh - local FOUND_SCENARIO - if FOUND_SCENARIO=$(find_scenario); then - if [[ "${IS_FORCE}" != 1 && "${FOUND_SCENARIO}" == "${SCENARIO}" ]]; then - if ! is_special_scenario; then - error "Scenario ${SCENARIO} already deployed, reset deployment with 'cleanup' first" - fi + local FOUND_SCENARIO + if FOUND_SCENARIO=$(find_scenario); then + if [[ "${IS_FORCE}" != 1 && "${FOUND_SCENARIO}" == "${SCENARIO}" ]]; then + if ! is_special_scenario; then + error "Scenario ${SCENARIO} already deployed, reset deployment with 'cleanup' first" fi - info "Found scenario ${FOUND_SCENARIO}" fi - - info "Running ${SCENARIO_DIR} against ${MASTER_HOST}" + info "Found scenario ${FOUND_SCENARIO}" fi + info "Running ${SCENARIO_DIR} against ${MASTER_HOST}" + if ! is_master_accessible; then error "Cannot connect to ${MASTER_HOST}" elif [[ ! -d "${SCENARIO_DIR}" ]]; then error "Scenario directory not found at ${SCENARIO_DIR}" fi - if [[ "${IS_TEST_ONLY:-}" != 1 ]]; then - run_scenario "${SCENARIO_DIR}" + run_scenario "${SCENARIO_DIR}" - success "${SCENARIO_DIR} applied to ${MASTER_HOST} (master) and ${SLAVE_HOSTS} (slaves)" - fi + success "${SCENARIO_DIR} applied to ${MASTER_HOST} (master) and ${SLAVE_HOSTS} (slaves)" success "End of perturb" } @@ -461,9 +453,6 @@ parse_arguments() { IS_AUTOPOPULATE=1 AUTOPOPULATE_REGEX="${1}" ;; - --test) - IS_TEST_ONLY=1 - ;; --force) IS_FORCE=1 ;; @@ -520,7 +509,7 @@ get_cluster_slaves() { validate_arguments() { [[ "${#ARGUMENTS[@]}" -gt 1 ]] && error "Only one scenario accepted" - [[ "${#ARGUMENTS[@]}" -lt 1 && "${IS_TEST_ONLY}" != 1 ]] && error "Scenario required" + [[ "${#ARGUMENTS[@]}" -lt 1 ]] && error "Scenario required" if [[ "${IS_AUTOPOPULATE:-}" == 1 ]]; then MASTER_HOST=$(