Skip to content

Commit

Permalink
Merge pull request #128 from kubernetes-simulator/refactor-command-args
Browse files Browse the repository at this point in the history
Removed unused IS_TEST_ONLY variable and various test
  • Loading branch information
jondkent authored Dec 2, 2019
2 parents b48feba + 35b04ae commit feeb51c
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions simulation-scripts/perturb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ SCENARIO=''
MASTER_HOST=""
SLAVE_HOSTS=""
BASTION_HOST=""
IS_TEST_ONLY=0
IS_FORCE=0

main() {
Expand All @@ -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"
}
Expand Down Expand Up @@ -461,9 +453,6 @@ parse_arguments() {
IS_AUTOPOPULATE=1
AUTOPOPULATE_REGEX="${1}"
;;
--test)
IS_TEST_ONLY=1
;;
--force)
IS_FORCE=1
;;
Expand Down Expand Up @@ -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=$(
Expand Down

0 comments on commit feeb51c

Please sign in to comment.