-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest_config.py
153 lines (137 loc) · 5.77 KB
/
test_config.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/env python3
""" keep the config for one testsuite to execute """
import copy
import os
from site_config import IS_WINDOWS, IS_MAC, TEMP
TEST_LOG_FILES = []
class TestConfig():
""" setup of one test """
# pylint: disable=too-many-instance-attributes disable=too-many-arguments
# pylint: disable=too-many-branches disable=too-many-statements
# pylint: disable=too-few-public-methods disable=line-too-long
def __init__(self,
cfg,
name,
suite,
args,
arangosh_args,
priority,
parallelity,
flags):
""" defaults for test config """
self.parallelity = parallelity
if self.parallelity > cfg.available_slots:
self.parallelity = cfg.available_slots
self.launch_delay = 1.3
self.progressive_timeout = 100
self.priority = priority
self.suite = suite
self.name = name
self.name_enum = name
self.crashed = False
self.success = True
self.structured_results = ""
self.summary = ""
self.start = None
self.finish = None
self.delta_seconds = 0
self.delta = None
self.base_logdir = cfg.test_report_dir / self.name
if not self.base_logdir.exists():
self.base_logdir.mkdir()
self.log_file = cfg.run_root / f'{self.name}.log'
self.xml_report_dir = cfg.xml_report_dir / self.name
if not self.xml_report_dir.exists():
self.xml_report_dir.mkdir(parents=True)
self.temp_dir = TEMP / self.name
# pylint: disable=global-variable-not-assigned
global TEST_LOG_FILES
try:
print(TEST_LOG_FILES.index(str(self.log_file)))
raise Exception(f'duplicate testfile {str(self.log_file)}')
except ValueError:
TEST_LOG_FILES.append(str(self.log_file))
self.summary_file = self.base_logdir / 'testfailures.txt'
self.crashed_file = self.base_logdir / 'UNITTEST_RESULT_CRASHED.json'
self.success_file = self.base_logdir / 'UNITTEST_RESULT_EXECUTIVE_SUMMARY.json'
self.report_file = self.base_logdir / 'UNITTEST_RESULT.json'
self.base_testdir = cfg.test_data_dir_x / self.name
self.arangosh_args = arangosh_args
self.args = copy.deepcopy(cfg.extra_args)
for param in args:
if param.startswith('$'):
paramname = param[1:]
if paramname in os.environ:
self.args += os.environ[paramname].split(' ')
else:
print("Error: failed to expand environment variable: '" + param + "' for '" + self.name + "'")
else:
self.args.append(param)
self.args += ['--coreCheck', 'true',
'--disableMonitor', 'true',
'--writeXmlReport', 'true',
'--testXmlOutputDirectory', str(self.xml_report_dir),
'--memory', str(self.parallelity * cfg.slot_memory) ]
if 'filter' in os.environ:
self.args += ['--test', os.environ['filter']]
if 'sniff' in flags:
if IS_WINDOWS and 'TSHARK' in os.environ:
self.args += ['--sniff', 'true',
'--sniffProgram', os.environ['TSHARK'],
'--sniffDevice', os.environ['DUMPDEVICE']]
elif IS_MAC:
self.args += ['--sniff', 'sudo']
else:
self.args += ['--sniff', 'true']
if 'SKIPNONDETERMINISTIC' in os.environ:
self.args += ['--skipNondeterministic', os.environ['SKIPNONDETERMINISTIC']]
if 'SKIPTIMECRITICAL' in os.environ:
self.args += ['--skipTimeCritical', os.environ['SKIPTIMECRITICAL']]
if 'BUILDMODE' in os.environ:
self.args += [ '--buildType', os.environ['BUILDMODE'] ]
if 'DUMPAGENCYONERROR' in os.environ:
self.args += [ '--dumpAgencyOnError', os.environ['DUMPAGENCYONERROR']]
myport = cfg.portbase
cfg.portbase += cfg.port_offset
self.args += [ '--minPort', str(myport), '--maxPort', str(myport + cfg.port_offset - 1)]
if 'SKIPGREY' in os.environ:
self.args += [ '--skipGrey', os.environ['SKIPGREY']]
if 'ONLYGREY' in os.environ:
self.args += [ '--onlyGrey', os.environ['ONLYGREY']]
if 'vst' in flags:
self.args += [ '--vst', 'true']
if 'ssl' in flags:
self.args += [ '--protocol', 'ssl']
if 'http2' in flags:
self.args += [ '--http2', 'true']
def __repr__(self):
return f"""
{self.name} => {self.parallelity}, {self.priority}, {self.success} -- {' '.join(self.args)}"""
def print_test_log_line(self):
""" get visible representation """
# pylint: disable=consider-using-f-string
resultstr = "Good result in"
if not self.success:
resultstr = "Bad result in"
if self.crashed:
resultstr = "Crash occured in"
return """
{1} {0.name} => {0.delta_seconds}, {0.parallelity}, {0.priority}, {0.success} -- {2}""".format(
self,
resultstr,
' '.join(self.args))
def print_testruns_line(self):
""" get visible representation """
# pylint: disable=consider-using-f-string
resultstr = "GOOD"
if not self.success:
resultstr = "BAD"
if self.crashed:
resultstr = "CRASH"
return """
<tr><td>{0.name}</td><td align="right">{0.delta}</td><td align="right">{1}</td></tr>""".format(
self,
resultstr)
def get_priority(test_config):
""" sorter function to return the priority """
return test_config.priority