Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(ASC-1552) Add health check tests before running system tests #3479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions gating/check/run
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ fi
if [[ ${RE_JOB_ACTION} == "elk" ]]; then
bash -c "$(readlink -f $(dirname ${0})/run_elk_tests.sh)"
fi

if [[ ${RE_JOB_ACTION} == "health_check" ]]; then
bash -c "$(readlink -f $(dirname ${0})/run_health_check_tests.sh)"
fi
60 changes: 60 additions & 0 deletions gating/check/run_health_check_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

## Deploy virtualenv for testing environment molecule/ansible-playbook/infratest

## Shell Opts ----------------------------------------------------------------

set -ex
set -o pipefail

## Variables -----------------------------------------------------------------

# The RPC_PRODUCT_RELEASE and RPC_RELEASE need to be brought into scope
# before running health check tests.
if [[ ${RE_JOB_IMAGE} =~ .*mnaio.* ]]; then
source /opt/rpc-openstack/scripts/functions.sh
fi

RE_HOOK_ARTIFACT_DIR="${RE_HOOK_ARTIFACT_DIR:-/tmp/artifacts}"
export RE_HOOK_RESULT_DIR="${RE_HOOK_RESULT_DIR:-/tmp/results}"
HC_WORKING_DIR=$(mktemp -d -t healthcheck_test_workingdir.XXXXXXXX)
export HC_VENV_NAME="${HC_VENV_NAME:-healthcheck-molecule}"
HC_TEST_SOURCE_BASE="${HC_TEST_SOURCE_BASE:-https://github.com/rcbops}"
HC_TEST_SOURCE="${HC_TEST_SOURCE:-rpc-openstack-healthcheck}"
HC_TEST_SOURCE_REPO="${HC_TEST_SOURCE_BASE}/${HC_TEST_SOURCE}"
HC_TEST_BRANCH="${RE_JOB_BRANCH:-master}"

## Main ----------------------------------------------------------------------

# 1. Clone test repository into working directory.
pushd "${HC_WORKING_DIR}"
git clone "${HC_TEST_SOURCE_REPO}"
cd "${HC_TEST_SOURCE}"

# Checkout defined branch
git checkout "${HC_TEST_BRANCH}"
echo "${HC_TEST_SOURCE} at SHA $(git rev-parse HEAD)"

# fail softly if the tests or artifact gathering fails
set +e

# 2. Execute script from repository
chmod 755 execute_tests.sh
./execute_tests.sh
[[ $? -ne 0 ]] && RC=$? # record non-zero exit code

# 3. Collect results from script, if they exist
mkdir -p "${RE_HOOK_RESULT_DIR}" || true # ensure that result directory exists
if [[ -e test_results.tar ]]; then
tar -xf test_results.tar -C "${RE_HOOK_RESULT_DIR}"
fi

# 4. Collect logs from script, if they exist
mkdir -p "${RE_HOOK_ARTIFACT_DIR}" || true # ensure that artifact directory exists
if [[ -e test_results.tar ]]; then
cp test_results.tar "${RE_HOOK_ARTIFACT_DIR}/molecule_test_results.tar"
fi
popd

# if exit code is recorded, use it, otherwise let it exit naturally
[[ -z ${RC+x} ]] && exit ${RC}