github.com/rvaralda/deis@v1.4.1/tests/bin/test-acceptance.sh (about)

     1  #!/bin/bash
     2  #
     3  # Preps a test environment and runs `make test-integration`
     4  # against artifacts produced from the current source tree
     5  #
     6  
     7  # fail on any command exiting non-zero
     8  set -eo pipefail
     9  
    10  # absolute path to current directory
    11  export THIS_DIR=$(cd $(dirname $0); pwd)
    12  
    13  # setup the test environment
    14  source $THIS_DIR/test-setup.sh
    15  
    16  # setup callbacks on process exit and error
    17  trap cleanup EXIT
    18  trap dump_logs ERR
    19  
    20  log_phase "Running documentation tests"
    21  
    22  # test building documentation
    23  make -C docs/ test
    24  
    25  log_phase "Running unit tests"
    26  
    27  make test-unit
    28  
    29  log_phase "Building from current source tree"
    30  
    31  # build all docker images and client binaries
    32  make build
    33  
    34  # use the built client binaries
    35  export PATH=$DEIS_ROOT/deisctl:$DEIS_ROOT/client/dist:$PATH
    36  
    37  log_phase "Running functional tests"
    38  
    39  make test-functional
    40  
    41  log_phase "Provisioning 3-node CoreOS"
    42  
    43  export DEIS_NUM_INSTANCES=3
    44  make discovery-url
    45  vagrant up --provider virtualbox
    46  
    47  log_phase "Waiting for etcd/fleet"
    48  
    49  until deisctl list >/dev/null 2>&1; do
    50      sleep 1
    51  done
    52  
    53  log_phase "Provisioning Deis on old release"
    54  
    55  function set_release {
    56    deisctl config $1 set image=deis/$1:$2
    57  }
    58  set_release logger ${OLD_TAG}
    59  set_release cache ${OLD_TAG}
    60  set_release router ${OLD_TAG}
    61  set_release database ${OLD_TAG}
    62  set_release controller ${OLD_TAG}
    63  set_release registry ${OLD_TAG}
    64  
    65  deisctl install platform
    66  time deisctl start platform
    67  
    68  log_phase "Running smoke tests"
    69  
    70  time make test-smoke
    71  
    72  log_phase "Publishing new release"
    73  
    74  time make release
    75  
    76  log_phase "Updating channel with new release"
    77  
    78  updateservicectl channel update --app-id=${APP_ID} --channel=${CHANNEL} --version=${BUILD_TAG} --publish=true
    79  
    80  log_phase "Waiting for upgrade to complete"
    81  
    82  # configure platform settings
    83  deisctl config platform set domain=$DEIS_TEST_DOMAIN
    84  deisctl config platform set sshPrivateKey=$DEIS_TEST_SSH_KEY
    85  deisctl config platform channel=${CHANNEL} autoupdate=true
    86  
    87  function wait_for_update {
    88    set -x
    89    vagrant ssh $1 -c "journalctl -n 500 -u deis-updater.service -f" &
    90    pid_$1=$!
    91    vagrant ssh $1 -c "/bin/sh -c \"while [[ \"\$(cat /etc/deis-version)\" != \"${BUILD_TAG}\" ]]; do echo waiting for update to complete...; sleep 5; done\""
    92    kill $pid_$1
    93    set +x
    94  }
    95  
    96  wait_for_update deis-1 &
    97  update1=$!
    98  wait_for_update deis-2 &
    99  update2=$!
   100  wait_for_update deis-3 &
   101  update3=$!
   102  wait update1 update2 update3
   103  
   104  log_phase "Running end-to-end integration test"
   105  
   106  time make test-integration