diff --git a/debian/ngcp-system-tests.install b/debian/ngcp-system-tests.install index 3dd59ff..4e03fd1 100644 --- a/debian/ngcp-system-tests.install +++ b/debian/ngcp-system-tests.install @@ -1,2 +1,2 @@ templates/* /etc/ngcp-config/templates/etc/ngcp-system-tests/ -testrunner /usr/share/ngcp-system-tests/ +ngcp-system-tests /usr/bin/ diff --git a/ngcp-system-tests b/ngcp-system-tests new file mode 100755 index 0000000..dc3b83b --- /dev/null +++ b/ngcp-system-tests @@ -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 <...] + +Options: + --mode 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 diff --git a/testrunner b/testrunner deleted file mode 100755 index 101fcb8..0000000 --- a/testrunner +++ /dev/null @@ -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]}"