-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.py
59 lines (49 loc) · 1.91 KB
/
driver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
import the `main` function below to then kick off the various
tests that you've made
"""
import os
from typing import List
import logging
import os, sys
sys.path.append("tests")
from tests.testing_utils.testing_config_loader import load_configs
from tests.testing_utils.testing_classes import TestConfig, TestOutput
from tests.testing_utils.testing_runners import run_scripts, run_test_for_result, summarize_results
def setup_logging(level=logging.DEBUG, filename=None, filemode=None, format=None, datefmt=None):
if filename is None:
filename = "tests/test_results.log"
if filemode is None:
filemode = "w"
if format is None:
format = "[%(filename)s:%(lineno)d] - %(asctime)s - %(levelname)s - %(message)s"
if datefmt is None:
datefmt = '%m/%d/%Y %I:%M:%S %p'
logging.basicConfig(
handlers=[
logging.FileHandler(filename, mode=filemode),
logging.StreamHandler()
],
format=format,
level=level,
datefmt=datefmt
)
if __name__ == '__main__':
level = logging.INFO
setup_logging(level=level)
logging.info("Loading in tests")
base_dir = os.getcwd() + "/tests"
test_folders = os.listdir(base_dir)
p2p_tests = [f for f in test_folders if "party" in f][::-1]
# crypto = [f for f in test_folders if "crypto" in f]
logging.info(f"Configs found {p2p_tests}")
test_results = []
for node in p2p_tests:
# Get the configs for the runs
run_configs: List[TestConfig] = [load_configs(node, base_dir)][0]
run_results: List[TestOutput] = [run_scripts(conf) for conf in run_configs]
# Pass the results to the test runner
node_test_results = [run_test_for_result(run_config, run_result) for (run_config, run_result) in
zip(run_configs, run_results)]
test_results.extend(node_test_results)
summarize_results(test_results)