github.com/rochacon/deis@v1.0.2-0.20150903015341-6839b592a1ff/tests/bin/accept/lib/functions.sh (about)

     1  # Shell functions for the tests module.
     2  #/ usage: source RERUN_MODULE_DIR/lib/functions.sh command
     3  #
     4  
     5  # Read rerun's public functions
     6  . $RERUN || {
     7      echo >&2 "ERROR: Failed sourcing rerun function library: \"$RERUN\""
     8      return 1
     9  }
    10  
    11  # Check usage. Argument should be command name.
    12  [[ $# = 1 ]] || rerun_option_usage
    13  
    14  # Source the option parser script.
    15  #
    16  if [[ -r $RERUN_MODULE_DIR/commands/$1/options.sh ]] 
    17  then
    18      . $RERUN_MODULE_DIR/commands/$1/options.sh || {
    19          rerun_die "Failed loading options parser."
    20      }
    21  fi
    22  
    23  # - - -
    24  # Your functions declared here.
    25  # - - -
    26  
    27  function not-implemented {
    28    rerun_log "No implementation of ${FUNCNAME[1]} in ${PROVIDER}"
    29  }
    30  
    31  function setup-provider {
    32  # This loads the provider's implementations of the provider interface
    33    local provider="${1}"
    34  
    35    source "${PROVIDER_DIR}/interface.sh"
    36    source "${PROVIDER_DIR}/${provider}.sh"
    37  }
    38  
    39  function setup-upgrader {
    40    local upgrader="${1}"
    41  
    42    source "${UPGRADER_DIR}/interface.sh"
    43    source "${UPGRADER_DIR}/${upgrader}.sh"
    44  }
    45  
    46  function source-shared {
    47    source "${RERUN_MODULE_DIR}/../test-setup.sh"
    48  
    49    # Needs DEIS_TEST_ID
    50    source "${RERUN_MODULE_DIR}/lib/config.sh"
    51    source "${RERUN_MODULE_DIR}/lib/clients.sh"
    52    source "${RERUN_MODULE_DIR}/lib/checks.sh"
    53    source "${RERUN_MODULE_DIR}/lib/platform.sh"
    54  }
    55  
    56  function setup-provider-dependencies {
    57    _setup-provider-dependencies
    58  }
    59  
    60  function destroy-cluster {
    61    dump-vars
    62  
    63    if [ "${SKIP_CLEANUP}" != true ]; then
    64      rerun_log "Cleaning up"
    65      _destroy || true
    66    fi
    67  }
    68  
    69  function create-cluster {
    70    _create
    71  }
    72  
    73  function dump-vars {
    74    echo
    75    rerun_log "Dumping useful variables (sourceable: ${TEST_ROOT}/vars)..."
    76  
    77    local output=$(cat <<EOF
    78  TEST_ROOT="${TEST_ROOT}"
    79  DEISCTL_TUNNEL="${DEISCTL_TUNNEL}"
    80  PATH="${PATH}"
    81  DEIS_TEST_SSH_KEY="${DEIS_TEST_SSH_KEY}"
    82  EOF
    83  )
    84  
    85    mkdir -p "${TEST_ROOT}"
    86    echo "${output}" > "${TEST_ROOT}/vars"
    87    echo "======= VARIABLES ======="
    88    echo "${output}"
    89    echo "========================="
    90  }
    91  
    92  source-shared