Changeset cf4e708 in mod_gnutls for test


Ignore:
Timestamp:
Jan 23, 2016, 5:11:43 PM (4 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
debian/master, debian/stretch-backports, jessie-backports, master, upstream
Children:
ddf6027
Parents:
bca7629
Message:

Run tests in separate network namespaces

Creating a network namespace for each test avoids port conflicts so
Apache instances can run in parallel, and also isolates the tests from
the host system.

Test namespaces are automatically used if the "unshare" command is
available, and can be disabled by passing "--disable-test-namespaces"
to ./configure.

Location:
test
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • test/Makefile.am

    rbca7629 rcf4e708  
    156156        export BACKEND_HOST="$(TEST_HOST)";
    157157
     158if ENABLE_NETNS
     159AM_TESTS_ENVIRONMENT += export UNSHARE="$(UNSHARE)"; \
     160        export USE_TEST_NAMESPACE=1;
     161endif
    158162# Without flock tests must not run in parallel. Otherwise set lock files.
    159163if DISABLE_FLOCK
  • test/base_apache.conf

    rbca7629 rcf4e708  
    55ErrorLog logs/${TEST_NAME}.error.log
    66HostnameLookups Off
    7 PidFile apache2.pid
    87KeepAlive Off
    98LogLevel debug
     
    1514
    1615Include         listen.conf
     16Include         apache-conf/*.conf
    1717
    1818DocumentRoot ${srcdir}/data
  • test/common.bash

    rbca7629 rcf4e708  
    1616    done
    1717}
     18
     19
     20
     21# Usage: netns_reexec ${@}
     22#
     23# If USE_TEST_NAMESPACE is set and MGS_NETNS_ACTIVE is not, exec the
     24# running command inside a new namespace with active loopback
     25# interface and MGS_NETNS_ACTIVE defined. This function can be used to
     26# isolate each testcase inside its own network namespace. Since
     27# MGS_NETNS_ACTIVE is used to track status, there's no harm in calling
     28# it multiple times (e.g. in the test-* script and runtests).
     29function netns_reexec
     30{
     31    if [ -n "${USE_TEST_NAMESPACE}" ] && [ -z "${MGS_NETNS_ACTIVE}" ]; then
     32        exec "${UNSHARE}" --net -r /bin/bash -c \
     33             "export MGS_NETNS_ACTIVE=1; ip link set up lo; exec ${0} ${@}"
     34    fi
     35    return 0
     36}
  • test/runtests

    rbca7629 rcf4e708  
    77set -e
    88. ${srcdir}/common.bash
     9netns_reexec ${@}
    910
    1011testid="${1##t-}"
     
    153154TEST_PID="apache2.pid"
    154155# configure locking for the Apache process
    155 if [ -n "${TEST_LOCK}" ]; then
     156if [ -n "${USE_TEST_NAMESPACE}" ]; then
     157    echo "Using namespaces to isolate tests, no need for locking."
     158    flock_cmd=""
     159elif [ -n "${TEST_LOCK}" ]; then
    156160    flock_cmd="${FLOCK} -w ${TEST_LOCK_WAIT} $(realpath ${TEST_LOCK})"
    157161else
  • test/test-19_TLS_reverse_proxy.bash

    rbca7629 rcf4e708  
    33set -e
    44: ${srcdir:="."}
     5. ${srcdir}/common.bash
     6netns_reexec ${@}
    57
    68testdir="${srcdir}/tests/19_TLS_reverse_proxy"
  • test/test-20_TLS_reverse_proxy_client_auth.bash

    rbca7629 rcf4e708  
    33set -e
    44: ${srcdir:="."}
     5. ${srcdir}/common.bash
     6netns_reexec ${@}
    57
    68testdir="${srcdir}/tests/20_TLS_reverse_proxy_client_auth"
  • test/test-21_TLS_reverse_proxy_wrong_cert.bash

    rbca7629 rcf4e708  
    33set -e
    44: ${srcdir:="."}
     5. ${srcdir}/common.bash
     6netns_reexec ${@}
    57
    68testdir="${srcdir}/tests/21_TLS_reverse_proxy_wrong_cert"
  • test/test-22_TLS_reverse_proxy_crl_revoke.bash

    rbca7629 rcf4e708  
    33set -e
    44: ${srcdir:="."}
     5. ${srcdir}/common.bash
     6netns_reexec ${@}
    57
    68testdir="${srcdir}/tests/22_TLS_reverse_proxy_crl_revoke"
  • test/test-23_TLS_reverse_proxy_mismatched_priorities.bash

    rbca7629 rcf4e708  
    33set -e
    44: ${srcdir:="."}
     5. ${srcdir}/common.bash
     6netns_reexec ${@}
    57
    68testdir="${srcdir}/tests/23_TLS_reverse_proxy_mismatched_priorities"
Note: See TracChangeset for help on using the changeset viewer.