Skip to content

Commit 19d794b

Browse files
authored
split the huge file into its natural modules (#460)
* split the huge file into its natural modules * remove unused imports
1 parent a5fcdcb commit 19d794b

11 files changed

+1154
-1088
lines changed

Diff for: jenkins/helper/arangosh.py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/env python3
2+
""" launch a testing.js instance with given testsuite and arguments """
3+
4+
from async_client import (
5+
ArangoCLIprogressiveTimeoutExecutor,
6+
7+
make_logfile_params,
8+
logfile_line_result,
9+
delete_logfile_params,
10+
)
11+
12+
class ArangoshExecutor(ArangoCLIprogressiveTimeoutExecutor):
13+
"""configuration"""
14+
15+
def __init__(self, site_config, slot_lock):
16+
self.slot_lock = slot_lock
17+
self.read_only = False
18+
super().__init__(site_config, None)
19+
20+
def run_testing(self,
21+
testcase,
22+
testing_args,
23+
timeout,
24+
directory,
25+
logfile,
26+
identifier,
27+
verbose
28+
):
29+
# pylint: disable=R0913 disable=R0902
30+
""" testing.js wrapper """
31+
print('------')
32+
print(testing_args)
33+
args = [
34+
'-c', str(self.cfg.cfgdir / 'arangosh.conf'),
35+
"--log.foreground-tty", "true",
36+
"--log.force-direct", "true",
37+
'--log.level', 'warning',
38+
"--log.level", "v8=debug",
39+
'--server.endpoint', 'none',
40+
'--javascript.allow-external-process-control', 'true',
41+
'--javascript.execute', self.cfg.base_path / 'UnitTests' / 'unittest.js',
42+
]
43+
run_cmd = args +[
44+
'--',
45+
testcase,
46+
'--testOutput', directory ] + testing_args
47+
params = make_logfile_params(verbose, logfile, self.cfg.trace)
48+
ret = self.run_monitored(
49+
self.cfg.bin_dir / "arangosh",
50+
run_cmd,
51+
params=params,
52+
progressive_timeout=timeout,
53+
deadline=self.cfg.deadline,
54+
result_line_handler=logfile_line_result,
55+
identifier=identifier
56+
)
57+
delete_logfile_params(params)
58+
ret['error'] = params['error']
59+
return ret

Diff for: jenkins/helper/dmesg.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/env python3
2+
"""
3+
on supported systems launch a thread that will follow system messages
4+
to detect serious incidents like oom
5+
"""
6+
7+
import psutil
8+
9+
from async_client import (
10+
ArangoCLIprogressiveTimeoutExecutor,
11+
12+
make_tail_params,
13+
tail_line_result,
14+
delete_tail_params
15+
)
16+
17+
def dmesg_runner(dmesg):
18+
""" thread to run dmesg in """
19+
dmesg.launch()
20+
21+
class DmesgWatcher(ArangoCLIprogressiveTimeoutExecutor):
22+
"""configuration"""
23+
24+
def __init__(self, site_config):
25+
self.params = None
26+
super().__init__(site_config, None)
27+
28+
def launch(self):
29+
# pylint: disable=R0913 disable=R0902
30+
""" dmesg wrapper """
31+
print('------')
32+
args = ['-wT']
33+
verbose = False
34+
self.params = make_tail_params(verbose,
35+
'dmesg ',
36+
self.cfg.test_report_dir / 'dmesg_log.txt')
37+
ret = self.run_monitored(
38+
"dmesg",
39+
args,
40+
params=self.params,
41+
progressive_timeout=9999999,
42+
deadline=self.cfg.deadline,
43+
result_line_handler=tail_line_result,
44+
identifier='0_dmesg'
45+
)
46+
#delete_logfile_params(params)
47+
ret = {}
48+
ret['error'] = self.params['error']
49+
delete_tail_params(self.params)
50+
return ret
51+
52+
def end_run(self):
53+
""" terminate dmesg again """
54+
print(f'killing dmesg {self.pid}')
55+
try:
56+
psutil.Process(self.pid).kill()
57+
except psutil.NoSuchProcess:
58+
print('dmesg already gone?')

Diff for: jenkins/helper/dump_handler.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/env python3
2+
""" test the syntax of the test-definition.txt and output the results """
3+
def generate_dump_output(_, tests):
4+
""" interactive version output to inspect comprehension """
5+
def output(line):
6+
""" output one line """
7+
print(line)
8+
9+
for test in tests:
10+
params = " ".join(f"{key}={value}" for key, value in test['params'].items())
11+
output(f"{test['name']}")
12+
output(f"\tpriority: {test['priority']}")
13+
output(f"\tparallelity: {test['parallelity']}")
14+
output(f"\tflags: {' '.join(test['flags'])}")
15+
output(f"\tparams: {params}")
16+
output(f"\targs: {' '.join(test['args'])}")

Diff for: jenkins/helper/launch_handler.py

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/env python3
2+
""" launch tests from the config, write reports, etc. Control logic """
3+
from pathlib import Path
4+
import sys
5+
import time
6+
from threading import Thread
7+
from traceback import print_exc
8+
9+
from dmesg import DmesgWatcher, dmesg_runner
10+
from site_config import SiteConfig, IS_LINUX
11+
from testing_runner import TestingRunner
12+
13+
# pylint: disable=broad-except
14+
def launch(args, tests):
15+
""" Manage test execution on our own """
16+
runner = None
17+
try:
18+
runner = TestingRunner(SiteConfig(Path(args.definitions).resolve()))
19+
except Exception as exc:
20+
print(exc)
21+
raise exc
22+
dmesg = DmesgWatcher(runner.cfg)
23+
if IS_LINUX:
24+
dmesg_thread = Thread(target=dmesg_runner, args=[dmesg])
25+
dmesg_thread.start()
26+
time.sleep(3)
27+
for test in tests:
28+
runner.register_test_func(args.cluster, test)
29+
runner.sort_by_priority()
30+
print(runner.scenarios)
31+
create_report = True
32+
if args.no_report:
33+
print("won't generate report as you demanded!")
34+
create_report = False
35+
try:
36+
runner.testing_runner()
37+
runner.overload_report_fh.close()
38+
runner.generate_report_txt()
39+
if create_report:
40+
runner.generate_test_report()
41+
if not runner.cfg.is_asan:
42+
runner.generate_crash_report()
43+
except Exception as exc:
44+
runner.success = False
45+
sys.stderr.flush()
46+
sys.stdout.flush()
47+
print(exc, file=sys.stderr)
48+
print_exc()
49+
finally:
50+
sys.stderr.flush()
51+
sys.stdout.flush()
52+
runner.create_log_file()
53+
runner.create_testruns_file()
54+
if IS_LINUX:
55+
dmesg.end_run()
56+
print('joining dmesg threads')
57+
dmesg_thread.join()
58+
runner.print_and_exit_closing_stance()

Diff for: jenkins/helper/monkeypatch_psutil.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import signal
88
import subprocess
99
import time
10-
import sys
10+
# import sys
1111

1212
winver = platform.win32_ver()
1313
if winver[0]:
@@ -89,7 +89,7 @@ def terminate(self):
8989
# sys.exit(1)
9090
# # pylint: disable=unnecessary-pass
9191
# pass
92-
#
92+
#
9393
# original_sigint_handler = signal.getsignal(signal.SIGINT)
9494
# signal.signal(signal.SIGINT, sigint_boomerang_handler)
9595
# # only here on the wintendo:

0 commit comments

Comments
 (0)