#!/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="help,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