#!/usr/bin/env bash
#
# You can use this script to run the tests on the remote qa box
# Requires ssh config with name delphi-api-cache (or set below)
# Optionally takes one argument: the test suite name
#

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"

SSH_CONFIG_HOST="delphi-api-cache"
REMOTE_DIR="~/delphi-api-cache"
DEFAULT_TEST_SUITE_NAME="delphi-api-testsuite-v3.jmx"
TEST_SUITE_NAME="${1:-$DEFAULT_TEST_SUITE_NAME}"
RUN_SCRIPT_NAME="run-tests.sh"

./upload-files.sh || exit 1

ssh ${SSH_CONFIG_HOST} << EOF
 cd ${REMOTE_DIR} && ./${RUN_SCRIPT_NAME} ${TEST_SUITE_NAME}
EOF

echo -e "\nFinished running test suite"

./download-reports.sh
