Changeset 0909c92 in mod_gnutls


Ignore:
Timestamp:
Dec 27, 2019, 12:40:51 PM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, main, master, proxy-ticket
Children:
3039495
Parents:
05984a0
Message:

Add hooks system to the test runner

With this all tests can use runtest.py to set up their
environment. Note that at the moment only the run_connection hook is
implemented.

Location:
test
Files:
2 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • test/Makefile.am

    r05984a0 r0909c92  
    5858# Python tools for tests
    5959noinst_PYTHON = https-test-client.py mgstest/http.py mgstest/__init__.py \
    60         mgstest/services.py mgstest/tests.py runtest.py
     60        mgstest/hooks.py mgstest/services.py mgstest/tests.py runtest.py
    6161
    6262# Identities in the miniature CA, server, and client environment for
     
    254254
    255255EXTRA_DIST = $(apache_data) $(cert_templates) $(shared_identities:=/uid.in) \
    256         apache_service.bash common.bash authority/server/crl.template \
    257         softhsm.bash
     256        common.bash authority/server/crl.template softhsm.bash
    258257
    259258# Lockfile for the main Apache process
  • test/runtest.py

    r05984a0 r0909c92  
    2222import sys
    2323
     24import mgstest.hooks
    2425from mgstest import lockfile, TestExpectationFailed
    2526from mgstest.services import ApacheService, TestService
     
    110111    os.environ['TEST_NAME'] = testname
    111112
     113    # Load test case hooks (if any)
     114    plugin_path = os.path.join(testdir, 'hooks.py')
     115    plugin = mgstest.hooks.load_hooks_plugin(plugin_path)
     116
    112117    # PID file name varies depending on whether we're using
    113118    # namespaces.
     
    187192        # Run the test connections
    188193        with contextlib.ExitStack() as stack:
    189             test_conf = stack.enter_context(
    190                 open(os.path.join(testdir, 'test.yml'), 'r'))
    191194            log_file = None
    192195            output_file = None
     
    196199                output_file = stack.enter_context(open(args.log_responses, 'w'))
    197200
    198             run_test_conf(test_conf,
    199                           float(os.environ.get('TEST_QUERY_TIMEOUT', 5.0)),
    200                           conn_log=log_file, response_log=output_file)
     201            if plugin.run_connection:
     202                plugin.run_connection(testname,
     203                                      conn_log=log_file,
     204                                      response_log=output_file)
     205            else:
     206                test_conf = stack.enter_context(
     207                    open(os.path.join(testdir, 'test.yml'), 'r'))
     208                run_test_conf(test_conf,
     209                              float(os.environ.get('TEST_QUERY_TIMEOUT', 5.0)),
     210                              conn_log=log_file, response_log=output_file)
    201211
    202212        # TODO: add hook to replace the test request, e.g. for curl
  • test/test-28_HTTP2_support.bash

    r05984a0 r0909c92  
    44
    55set -e
    6 : ${srcdir:="."}
    7 . ${srcdir}/common.bash
    8 netns_reexec ${@}
    9 
    10 testdir="${srcdir}/tests/28_HTTP2_support"
    11 TEST_NAME="$(basename ${testdir})"
    12 . $(dirname ${0})/apache_service.bash
    136
    147if [ ! -r ${AP_LIBEXECDIR}/mod_http2.so ]; then
     
    2114fi
    2215
    23 function stop_server
    24 {
    25     apache_service "${testdir}" "apache.conf" stop
    26 }
    27 apache_service "${testdir}" "apache.conf" start "${TEST_LOCK}"
    28 trap stop_server EXIT
     16# expected output files
     17log="outputs/28_HTTP2_support.log"
     18output="outputs/28_HTTP2_support.output"
    2919
    30 output="outputs/${TEST_NAME}.output"
    31 header="outputs/${TEST_NAME}.header"
    32 rm -f "${output}" "${header}"
    33 
    34 URL="https://${TEST_HOST}:${TEST_PORT}/status?auto"
    35 ${HTTP_CLI} --http2 --location --verbose --cacert authority/x509.pem \
    36             --dump-header "${header}" --output "${output}" "${URL}"
     20${srcdir}/netns_py.bash ${srcdir}/runtest.py --test-number 28 \
     21         --log-connection "${log}" --log-responses "${output}"
    3722
    3823echo "Checking for HTTP/2 in logged header:"
    39 grep "HTTP/2 200" "${header}"
     24grep "HTTP/2 200" "${log}"
    4025echo "Checking for TLS session status:"
    4126grep "Current TLS session: (TLS" "${output}"
    42 
    43 apache_service "${testdir}" "apache.conf" stop
    44 trap - EXIT
  • test/tests/Makefile.am

    r05984a0 r0909c92  
    2828        26_redirect_HTTP_to_HTTPS/apache.conf 26_redirect_HTTP_to_HTTPS/test.yml \
    2929        27_OCSP_server/apache.conf 27_OCSP_server/ocsp.conf 27_OCSP_server/test.yml \
    30         28_HTTP2_support/apache.conf \
     30        28_HTTP2_support/apache.conf 28_HTTP2_support/hooks.py \
    3131        29_force_handshake_vhost/apache.conf 29_force_handshake_vhost/test.yml \
    3232        30_ip_based_vhosts/apache.conf 30_ip_based_vhosts/test.yml \
Note: See TracChangeset for help on using the changeset viewer.