#!/usr/bin/env bash

#####
# This script does all the steps that are part of the integration tests.
# This script should simply be invoked whenever a complete integration test needs to be run.
#
# 1. Perform setup, if it fails do not run the tests.
# 2. Run all the tests.
# 3. Perform teardown.
#####

set -euo pipefail

# Get the correct directory where the script resides
intgtest="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd ${intgtest}

echo
echo "===================="
echo "===== SETTING UP THE LOCAL INTEGRATION TEST ENVIRONMENT"
echo
./local_setup.sh
if [ $? -eq 0 ]
then
    echo
    echo "===================="
    echo "===== STARTING EXECUTION OF ALL THE TESTS"
    echo
    ./local_run_tests.sh
    echo
fi

echo
echo "===================="
echo "===== TEARING DOWN THE INTEGRTION TEST ENVIRONMENT"
echo
./local_teardown.sh
echo
