Browse Source

Run tests in debug mode, use fork's repo for upgraded

The test harness will suppress output unless an error occurs.

Upgrade testing was failing in forked repos CI because the
source repo was hard-coded.  Use the CI environment to use
the fork's repo.
pull/691/head
Timothe Litt 4 years ago
parent
commit
4447f4ec47
Failed to extract signature
4 changed files with 35 additions and 14 deletions
  1. +25
    -10
      getssl
  2. +6
    -1
      test/32-test-upgrade.bats
  3. +1
    -0
      test/run-test.sh
  4. +3
    -3
      test/test_helper.bash

+ 25
- 10
getssl View File

@ -267,6 +267,7 @@
# 2021-07-25 Fix copy_file_to_location failures with ssh when suffix applied to file lacking an extension (tlhackque)(#686)
# 2021-07-27 Support ftps://, FTPS_OPTIONS, remove default --insecure parameter to ftpes. Report caller(s) of error_exit in debug and test modes (tlhackque)(#687)(2.39)
# 2021-07-30 Prefer API V2 when both offered (tlhackque) (#690) (2.40)
# 2021-07-30 Run tests with -d to catch intermittent failures, Use fork's repo for upgrade tests. (tlhackque) (#692) (2.41)
# ----------------------------------------------------------------------------------------
case :$SHELLOPTS: in
@ -275,7 +276,7 @@ esac
PROGNAME=${0##*/}
PROGDIR="$(cd "$(dirname "$0")" || exit; pwd -P;)"
VERSION="2.40"
VERSION="2.41"
# defaults
ACCOUNT_KEY_LENGTH=4096
@ -285,7 +286,11 @@ CA="https://acme-staging-v02.api.letsencrypt.org/directory"
CHALLENGE_CHECK_TYPE="http"
CHECK_REMOTE_WAIT=0
CHECK_REMOTE="true"
CODE_LOCATION="https://raw.githubusercontent.com/srvrco/getssl/master/getssl"
if [[ -n "${GITHUB_REPOSITORY}" ]] ; then
CODE_LOCATION="https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/master/getssl"
else
CODE_LOCATION="https://raw.githubusercontent.com/srvrco/getssl/master/getssl"
fi
CSR_SUBJECT="/"
CURL_USERAGENT="${PROGNAME}/${VERSION}"
DEACTIVATE_AUTH="false"
@ -1798,7 +1803,7 @@ get_signing_params() { # get signing parameters from key
}
graceful_exit() { # normal exit function.
exit_code=$1
exit_code="${1-0}"
clean_up
# shellcheck disable=SC2086
exit $exit_code
@ -2415,14 +2420,18 @@ signal_exit() { # Handle trapped signals
esac
}
test_setup() { # setup for running test
_USE_DEBUG=1
}
traceback() { # Print function traceback
local i d=1 lbl=" called"
echo "Traceback" >&2
for ((i=$((${#FUNCNAME[@]}-1)); i>0; i--)); do
if [[ ${i} -eq 1 ]] ; then lbl=" called traceback" ; fi
printf "%*s%s() line %d%s\n" "$d" '' "${FUNCNAME[$i]}" "${BASH_LINENO[$((i-1))]}" "$lbl" >&2
((d++))
done
local i d=1 lbl=" called"
debug "Traceback"
for ((i=$((${#FUNCNAME[@]}-1)); i>0; i--)); do
if [[ ${i} -eq 1 ]] ; then lbl=" called traceback" ; fi
debug "$(printf "%*s%s() line %d%s\n" "$d" '' "${FUNCNAME[$i]}" "${BASH_LINENO[$((i-1))]}" "$lbl")"
((d++))
done
}
urlbase64() { # urlbase64: base64 encoded string with '+' replaced with '-' and '/' replaced with '_'
@ -2627,6 +2636,12 @@ write_openssl_conf() { # write out a minimal openssl conf
trap "signal_exit TERM" TERM HUP
trap "signal_exit INT" INT
# When running tests, use debug mode to capture intermittent faults
# Test harness will Save output in a temporary file, which is displayed if an error occurs
if [[ ${_RUNNING_TEST} -eq 1 ]] ; then
test_setup
fi
# Parse command-line
while [[ -n ${1+defined} ]]; do
case $1 in


+ 6
- 1
test/32-test-upgrade.bats View File

@ -11,7 +11,12 @@ setup() {
# Turn off warning about detached head
git config --global advice.detachedHead false
run git clone https://github.com/srvrco/getssl.git "$INSTALL_DIR/upgrade-getssl"
if [[ -n "${GITHUB_REPOSITORY}" ]] ; then
_REPO="https://github.com/${GITHUB_REPOSITORY}.git"
else
_REPO="https://github.com/srvrco/getssl.git"
fi
run git clone "${_REPO}" "$INSTALL_DIR/upgrade-getssl"
# Don't do version arithmetics any longer, look what was the previous version by getting the last
# line (starting with v) and the one before that from the list of tags.


+ 1
- 0
test/run-test.sh View File

@ -37,6 +37,7 @@ docker run \
--env GETSSL_HOST=$ALIAS $STAGING \
--env GETSSL_IDN_HOST=$GETSSL_IDN_HOST \
--env GETSSL_OS=$GETSSL_OS \
--env GITHUB_REPOSITORY="${GITHUB_REPOSITORY}" \
-v "$(pwd)":/getssl \
--rm \
--network ${PWD##*/}_acmenet \


+ 3
- 3
test/test_helper.bash View File

@ -25,7 +25,7 @@ check_nginx() {
check_output_for_errors() {
refute_output --regexp '[Ff][Aa][Ii][Ll][Ee][Dd]'
# less strict tests if running with debug output
if [ -n "$1" ]; then
if [ -n "X$1" ]; then
# don't fail for :error:badNonce
refute_output --regexp '[^:][Ee][Rr][Rr][Oo][Rr][^:]'
# don't check for "Warnings:" as there might be a warning message if nslookup doesn't support -debug (alpine/ubuntu)
@ -47,12 +47,12 @@ create_certificate() {
# Create certificate
cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_CMD_HOST}/getssl.cfg"
# shellcheck disable=SC2086
run ${CODE_DIR}/getssl "$@" "$GETSSL_CMD_HOST"
run ${CODE_DIR}/getssl -d "$@" "$GETSSL_CMD_HOST"
}
init_getssl() {
# Run initialisation (create account key, etc)
run ${CODE_DIR}/getssl -c "$GETSSL_CMD_HOST"
run ${CODE_DIR}/getssl -d -c "$GETSSL_CMD_HOST"
assert_success
[ -d "$INSTALL_DIR/.getssl" ]
}


Loading…
Cancel
Save