source: mod_gnutls/test/proxy_backend.bash @ 94430e6

debian/masterdebian/stretch-backportsupstream
Last change on this file since 94430e6 was 94430e6, checked in by Thomas Klute <thomas2.klute@…>, 2 years ago

Test suite: Run a separate Apache instance for the OCSP responder

This change will be needed to cache OCSP responses on start (and
schedule) instead of when needed. An OCSP responder in the same Apache
instance won't be ready while the mod_gnutls post_config hook is
executing.

The changes to lock file handling included in this patch mean that
most parts of the test framework won't need to check which locking
method (if any) is used, they can just pass a lock file which is then
used for flock or PID file checks depending on ./configure results.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#!/bin/bash
2
3set -e
4. ${srcdir}/common.bash
5
6if [ -z "${BACKEND_HOST}" ]; then
7    export BACKEND_HOST="localhost"
8fi
9if [ -z "${BACKEND_PORT}" ]; then
10    export BACKEND_PORT="9934"
11fi
12: ${srcdir:="."}
13: ${APACHE2:="apache2"}
14: ${TEST_LOCK_WAIT:="30"}
15
16function backend_apache
17{
18    # needed for start and stop
19    dir="${1}"
20    conf="${2}"
21    action="${3}"
22    # Needed only for start. The "lockfile" parameter is used as flock
23    # lock file or PID file to watch depending on whether FLOCK is
24    # set.
25    lockfile="${4}"
26
27    TEST_NAME="$(basename "${dir}")"
28    (
29        export TEST_NAME
30        export TEST_PORT="${BACKEND_PORT}"
31        export srcdir="$(realpath ${srcdir})"
32        local flock_cmd=""
33        case ${action} in
34            start)
35                if [ -n "${USE_TEST_NAMESPACE}" ]; then
36                    echo "Using namespaces to isolate tests, no need for" \
37                         "locking."
38                elif [ -n "${FLOCK}" ]; then
39                    flock_cmd="${FLOCK} -w ${TEST_LOCK_WAIT} ${lockfile}"
40                else
41                    echo "Locking disabled, using wait based on proxy PID file."
42                    wait_pid_gone "${lockfile}"
43                fi
44                ${flock_cmd} \
45                    ${APACHE2} -f "$(realpath ${testdir}/${conf})" -k start || return 1
46                ;;
47            stop)
48                ${APACHE2} -f "$(realpath ${testdir}/${conf})" -k stop || return 1
49                ;;
50            *)
51                echo "${FUNCNAME[0]}: Invalid action \"${action}\"." >&2
52                exit 1
53                ;;
54        esac
55    )
56}
Note: See TracBrowser for help on using the repository browser.