source: mod_gnutls/test/tests/37_TLS_reverse_proxy_resume_session/hooks.py @ 21cd807

asyncio
Last change on this file since 21cd807 was 43a601f, checked in by Fiona Klute <fiona.klute@…>, 13 months ago

Proxy resume test: Allow initial close/resume open to interleave

Almost always closing the initial connection is logged before
resumption, but "almost" is not enough for a reliable test. Either way
the messages are just a few milliseconds apart on my system.

Instead the test now matches the resume and open messages for the
resume session by handler thread ID to increase reliability.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1import re
2from mgstest import require_match, TestExpectationFailed
3from pathlib import Path
4
5
6LOGFILE = Path('logs/37_TLS_reverse_proxy_resume_session.backend.error.log')
7LOGFILE_POSITION = 0
8
9
10def prepare_env():
11    # Seek to the end of server log, if it exists from previous tests
12    if LOGFILE.exists():
13        global LOGFILE_POSITION
14        LOGFILE_POSITION = LOGFILE.stat().st_size
15
16
17def post_check(conn_log, response_log):
18    conn_opened = re.compile(r'tid (\d+)\].* TLS connection opened.')
19    session_resumed = re.compile(r'tid (\d+)\].* TLS session resumed.')
20
21    print('Checking if the backend server log contains session resumption')
22    with LOGFILE.open() as log:
23        print(f'Seeking to position {LOGFILE_POSITION}')
24        log.seek(LOGFILE_POSITION)
25
26        require_match(conn_opened, log)
27        print('Initial session found.')
28
29        id1 = require_match(session_resumed, log).group(1)
30        id2 = require_match(conn_opened, log).group(1)
31        if id1 != id2:
32            raise TestExpectationFailed(
33                'thread ID mismatch between resume and open message: '
34                f'{id1} != {id2}')
35        print('Resumed session found.')
Note: See TracBrowser for help on using the repository browser.