Changeset c96a965 in mod_gnutls


Ignore:
Timestamp:
Dec 12, 2019, 6:48:09 AM (10 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
c7f83a3
Parents:
b57d2c2
Message:

Create function to run a test config YAML file

This is much more efficient when also managing the test environment
using Python.

Location:
test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/https-test-client.py

    rb57d2c2 rc96a965  
    1717
    1818import os
    19 import sys
    20 import yaml
    2119
    22 from mgstest.tests import TestConnection
     20from mgstest.tests import run_test_conf
    2321
    2422if __name__ == "__main__":
     
    5250        os.environ['TEST_PORT'] = args.port
    5351
    54     conns = None
    55 
    56     config = yaml.load(args.test_config, Loader=yaml.Loader)
    57     if type(config) is TestConnection:
    58         conns = [config]
    59     elif type(config) is list:
    60         # assume list elements are connections
    61         conns = config
    62     else:
    63         raise TypeError(f'Unsupported configuration: {config!r}')
    64     print(conns)
    65     sys.stdout.flush()
    66 
    67     for i, test_conn in enumerate(conns):
    68         if test_conn.description:
    69             print(f'Running test connection {i}: {test_conn.description}')
    70             sys.stdout.flush()
    71         test_conn.run(timeout=args.timeout)
     52    run_test_conf(args.test_config, args.timeout)
     53    args.test_config.close()
  • test/mgstest/tests.py

    rb57d2c2 rc96a965  
    367367    t = Template(text)
    368368    return t.substitute(os.environ)
     369
     370
     371
     372def run_test_conf(test_config, timeout=5.0):
     373    conns = None
     374
     375    config = yaml.load(test_config, Loader=yaml.Loader)
     376    if type(config) is TestConnection:
     377        conns = [config]
     378    elif type(config) is list:
     379        # assume list elements are connections
     380        conns = config
     381    else:
     382        raise TypeError(f'Unsupported configuration: {config!r}')
     383    print(conns)
     384    sys.stdout.flush()
     385
     386    for i, test_conn in enumerate(conns):
     387        if test_conn.description:
     388            print(f'Running test connection {i}: {test_conn.description}')
     389            sys.stdout.flush()
     390        test_conn.run(timeout=timeout)
Note: See TracChangeset for help on using the changeset viewer.