TT#72351 Add a new helper program to run the tests

This new program is a wrapper to make running the tests easier, and it
will abstrat all necessary knowledge about the test runner.

We also remove the results file generation support, and let our caller
handle it as it simplifies the code overall.

Change-Id: Iad884429b00a94d5f3c9c3b37db31a523ab3c701
changes/77/36377/18
Guillem Jover 5 years ago
parent 6ea0a4b891
commit 62a2332662

@ -1,2 +1,2 @@
templates/* /etc/ngcp-config/templates/etc/ngcp-system-tests/
testrunner /usr/share/ngcp-system-tests/
ngcp-system-tests /usr/bin/

@ -0,0 +1,94 @@
#!/bin/bash
set -e
declare -r ME="$(basename "$0")"
declare -r OPTS=("$@")
declare -a PROVE_OPTS=()
NGCP_TESTS_MODE=${NGCP_TESTS_MODE:=prove}
error() {
if [ "${NGCP_TESTS_MODE}" = 'tap' ]; then
echo "Bail out! $*" >&2
else
echo "$ME: error: $*" >&2
fi
exit 1
}
usage() {
cat <<HELP
Usage: ${ME} [<option>...]
Options:
--mode <name> Operation mode to use. Values: jenkins, tap, prove.
-h, --help Print this help message and exit.
HELP
}
get_options() {
local _cmdline_opts="mode:"
local _opt_temp
_opt_temp=$(getopt -n "${ME}" -o 'h' -l "${_cmdline_opts}" -- "${OPTS[@]}")
eval set -- "${_opt_temp}"
while :; do
case "$1" in
--help|-h)
usage
exit 0
;;
--mode)
shift
NGCP_TESTS_MODE="$1"
;;
--)
shift
break
;;
*)
error "Internal getopt error! $1"
;;
esac
shift
done
PROVE_OPTS=("$@")
}
if ! [ -d /etc/ngcp-system-tests/ ]; then
error "Missing system test suite files, please run 'ngcpcfg build'"
fi
get_options "$@"
case "${NGCP_TESTS_MODE}" in
jenkins)
export GOSS_NOCOLOR=true
$0 --mode=tap
;;
prove)
export NGCP_TESTS_MODE=tap
prove "${PROVE_OPTS[@]}" -f "$0"
;;
*)
DEBIAN_RELEASE=$(sed -e 's/\([0-9]*\)\..*/\1/' /etc/debian_version)
# Translate Debian codenames that don't have a version number (yet) into
# according numbers
case "${DEBIAN_RELEASE}" in
bullseye*)
DEBIAN_RELEASE=11
;;
esac
export DEBIAN_RELEASE
# We need to export these, so that goss sees existent variables.
export SKIP_DNS_CHECK_TEST=${SKIP_DNS_CHECK_TEST:-false}
export SKIP_STRICT_HOSTNAME_TEST=${SKIP_STRICT_HOSTNAME_TEST:-false}
PLAN='/etc/ngcp-system-tests/goss.yaml'
goss -g "${PLAN}" validate --format "${NGCP_TESTS_MODE}"
;;
esac

@ -1,36 +0,0 @@
#!/bin/bash
set -e
REPORT_DIRECTORY='reports/'
diag() {
echo "$@" 2>&1
}
if ! [ -d /etc/ngcp-system-tests/ ]; then
diag "Missing system test suite files, please run 'ngcpcfg build'"
exit 1
fi
rm -rf "${REPORT_DIRECTORY}"
mkdir -p "${REPORT_DIRECTORY}"
TAP_RESULTS="${REPORT_DIRECTORY}/goss_results.tap"
DEBIAN_RELEASE=$(sed -e 's/\([0-9]*\)\..*/\1/' /etc/debian_version)
# translate Debian codenames that don't have a version number (yet) into according numbers
case "${DEBIAN_RELEASE}" in
bullseye*)
DEBIAN_RELEASE=11
;;
esac
export DEBIAN_RELEASE
# We need to export these, so that goss sees existent variables.
export SKIP_DNS_CHECK_TEST=${SKIP_DNS_CHECK_TEST:-false}
export SKIP_STRICT_HOSTNAME_TEST=${SKIP_STRICT_HOSTNAME_TEST:-false}
goss -g "/etc/ngcp-system-tests/goss.yaml" validate --format tap \
| tee "${TAP_RESULTS}"
exit "${PIPESTATUS[0]}"
Loading…
Cancel
Save