Skip to content

Commit 8e7f5f7

Browse files
dothebartKVS85goedderz
authored
Fix coverage runs (#479)
* only run coverage if tests are successfull * we should allways have the reports * Update helper.fish * silence * multi threadded unlimited core tar * configure individual temp-subdirectories per run * configure individual temp-subdirectories per run * revert * don't delete files that are still needed * debug * try to clean temp * reduce sysetm capabilities in coverage tests * no extensions... * lint * lint * use proper environment variable already here * lint * lint * blank * launch cluster and single from one python run. * lint * suffix the runs * fix prefix handling for both case * remove debug * strive to include missing directories * attempt to set exit code * improve message composition * improve messaging for coredump zipping * lint * fix oskar python report switching integration * re-enable code * fix oskar python report switching integration * fix generation * work on exit code handling * work on exit code handling * Update jenkins/helper/test_launch_controller.py Co-authored-by: Tobias Gödderz <[email protected]> * Update jenkins/runCoverageRocksDB.fish Co-authored-by: Tobias Gödderz <[email protected]> * disable running for now * fix path * reenable * preserve inbetween file * link last missing files * individualise slots, give gcov a little more * switch wording * switch wording * set the suite to run early on. * fix filtering, add missing enterprise filter * cluster args is used 2-fold: to indicate cluster only tests, and later on to control that we are in the custer case * fix syntax * add negative way so its better switcheable * ps * quotes maybe? * add negative way so its better switcheable * add echo * fix cluster parameter adding to the testcasse --------- Co-authored-by: Vadim <[email protected]> Co-authored-by: Tobias Gödderz <[email protected]>
1 parent 0103756 commit 8e7f5f7

11 files changed

+216
-107
lines changed

Diff for: helper.fish

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ end
9494
9595
function single ; set -gx TESTSUITE single ; end
9696
function cluster ; set -gx TESTSUITE cluster ; end
97+
function single_cluster ; set -gx TESTSUITE single_cluster ; end
9798
function resilience ; set -gx TESTSUITE resilience ; end
9899
function catchtest ; set -gx TESTSUITE gtest ; end
99100
function gtest ; set -gx TESTSUITE gtest ; end
@@ -1519,7 +1520,7 @@ function showConfig
15191520
printf $fmt3 'SkipGrey' $SKIPGREY '(skipGrey/includeGrey)'
15201521
printf $fmt3 'OnlyGrey' $ONLYGREY '(onlyGreyOn/onlyGreyOff)'
15211522
printf $fmt3 'Storage engine' $STORAGEENGINE '(mmfiles/rocksdb)'
1522-
printf $fmt3 'Test suite' $TESTSUITE '(single/cluster/resilience/gtest)'
1523+
printf $fmt3 'Test suite' $TESTSUITE '(single/cluster/single_cluster/resilience/gtest)'
15231524
printf $fmt2 'Log Levels' (echo $LOG_LEVELS)
15241525
echo
15251526
echo 'Package Configuration'

Diff for: jenkins/helper/asciiprint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def ascii_convert(the_bytes: bytes):
5858

5959
def ascii_convert_str(the_str: str):
6060
"""convert string to only be ascii without control sequences"""
61-
return ANSI_ESCAPE.sub(rb"", the_str)
61+
return ANSI_ESCAPE.sub("", the_str)
6262

6363

6464
def ascii_print(string):

Diff for: jenkins/helper/launch_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def launch(args, tests):
2525
dmesg_thread.start()
2626
time.sleep(3)
2727
for test in tests:
28-
runner.register_test_func(args.cluster, test)
28+
runner.register_test_func(test)
2929
runner.sort_by_priority()
3030
print(runner.scenarios)
3131
create_report = True

Diff for: jenkins/helper/site_config.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
from pathlib import Path
66
import platform
7+
import re
78
import shutil
89
import signal
910
import sys
@@ -55,8 +56,9 @@ def get_workspace():
5556
# return workdir
5657
return Path.cwd() / 'work'
5758

59+
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
5860
for env in os.environ:
59-
print(f'{env}={os.environ[env]}')
61+
print(f"{env}={ansi_escape.sub('', os.environ[env])}")
6062
TEMP = Path("/tmp/")
6163
if 'TMP' in os.environ:
6264
TEMP = Path(os.environ['TMP'])
@@ -135,15 +137,23 @@ def __init__(self, definition_file):
135137
self.slots_to_parallelity_factor = self.max_load / self.available_slots
136138
self.rapid_fire = round(self.available_slots / 10)
137139
self.is_asan = 'SAN' in os.environ and os.environ['SAN'] == 'On'
138-
if self.is_asan:
139-
print('SAN enabled, reducing possible system capacity')
140+
self.is_aulsan = self.is_asan and os.environ['SAN_MODE'] == 'AULSan'
141+
self.is_gcov = 'COVERAGE' in os.environ and os.environ['COVERAGE'] == 'On'
142+
san_gcov_msg = ""
143+
if self.is_asan or self.is_gcov:
144+
san_gcov_msg = ' - SAN '
145+
slot_divisor = 4
146+
if self.is_aulsan:
147+
san_gcov_msg = ' - AUL-SAN '
148+
elif self.is_gcov:
149+
san_gcov_msg = ' - GCOV'
150+
slot_divisor = 3
151+
san_gcov_msg += ' enabled, reducing possible system capacity\n'
140152
self.rapid_fire = 1
141-
self.available_slots /= 4
153+
self.available_slots /= slot_divisor
142154
#self.timeout *= 1.5
143155
self.loop_sleep *= 2
144156
self.max_load /= 2
145-
if os.environ['SAN_MODE'] == 'AULSan':
146-
print('Aulsan must reduce even more!')
147157
self.deadline = datetime.now() + timedelta(seconds=self.timeout)
148158
self.hard_deadline = datetime.now() + timedelta(seconds=self.timeout + 660)
149159
if definition_file.is_file():
@@ -175,7 +185,7 @@ def __init__(self, definition_file):
175185
- Starting {str(datetime.now())} soft deadline will be: {str(self.deadline)} hard deadline will be: {str(self.hard_deadline)}
176186
- {self.core_dozend} / {self.loop_sleep} machine size / loop frequency
177187
- {socket_count} number of currently active tcp sockets
178-
""")
188+
{san_gcov_msg}""")
179189
self.cfgdir = base_source_dir / 'etc' / 'relative'
180190
self.bin_dir = bin_dir
181191
self.base_path = base_source_dir

Diff for: jenkins/helper/test_launch_controller.py

+59-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/env python3
22
""" read test definition, and generate the output for the specified target """
33
import argparse
4+
import copy
45
import sys
56
from traceback import print_exc
67

@@ -18,39 +19,64 @@
1819

1920
def filter_tests(args, tests):
2021
""" filter testcase by operations target Single/Cluster/full """
22+
for one in tests:
23+
one['prefix'] = ""
2124
if args.all:
2225
return tests
2326

24-
filters = []
25-
if args.cluster:
26-
filters.append(lambda test: "single" not in test["flags"])
27-
else:
28-
filters.append(lambda test: "cluster" not in test["flags"])
29-
30-
if args.full:
31-
filters.append(lambda test: "!full" not in test["flags"])
32-
else:
33-
filters.append(lambda test: "full" not in test["flags"])
34-
35-
if args.gtest:
36-
filters.append(lambda test: "gtest" == test["name"])
37-
38-
if IS_WINDOWS:
39-
filters.append(lambda test: "!windows" not in test["flags"])
40-
41-
if IS_MAC:
42-
filters.append(lambda test: "!mac" not in test["flags"])
43-
44-
if IS_ARM:
45-
filters.append(lambda test: "!arm" not in test["flags"])
46-
47-
if args.no_report:
48-
print("Disabling report generation")
49-
args.create_report = False
27+
def list_generator(cluster):
28+
# pylint: disable=too-many-branches
29+
filters = []
30+
if cluster:
31+
filters.append(lambda test: "single" not in test["flags"])
32+
else:
33+
filters.append(lambda test: "cluster" not in test["flags"])
5034

51-
for one_filter in filters:
52-
tests = filter(one_filter, tests)
53-
return list(tests)
35+
if args.full:
36+
filters.append(lambda test: "!full" not in test["flags"])
37+
else:
38+
filters.append(lambda test: "full" not in test["flags"])
39+
40+
if args.gtest:
41+
filters.append(lambda test: "gtest" == test["name"])
42+
43+
if not args.enterprise:
44+
filters.append(lambda test: "enterprise" not in test["flags"])
45+
46+
if IS_WINDOWS:
47+
filters.append(lambda test: "!windows" not in test["flags"])
48+
49+
if IS_MAC:
50+
filters.append(lambda test: "!mac" not in test["flags"])
51+
52+
if IS_ARM:
53+
filters.append(lambda test: "!arm" not in test["flags"])
54+
55+
if args.no_report:
56+
print("Disabling report generation")
57+
args.create_report = False
58+
59+
filtered = copy.deepcopy(tests)
60+
for one_filter in filters:
61+
filtered = filter(one_filter, filtered)
62+
remaining_tests = list(filtered)
63+
if cluster:
64+
# after we filtered for cluster only tests, we now need to make sure
65+
# that tests are actually launched as cluster tests:
66+
for one in remaining_tests:
67+
if not 'cluster' in one['flags']:
68+
one['flags'].append('cluster')
69+
return remaining_tests
70+
71+
if args.single_cluster:
72+
res_sg = list_generator(False)
73+
for one in res_sg:
74+
one['prefix'] = "sg_"
75+
res_cl = list_generator(True)
76+
for one in res_cl:
77+
one['prefix'] = "cl_"
78+
return res_sg + res_cl
79+
return list_generator(args.cluster)
5480

5581
formats = {
5682
"dump": generate_dump_output,
@@ -73,6 +99,7 @@ def filter_tests(args, tests):
7399
}
74100

75101
known_parameter = {
102+
"prefix": 'internal',
76103
"buckets": "number of buckets to use for this test",
77104
"suffix": "suffix that is appended to the tests folder name",
78105
"priority": "priority that controls execution order. Testsuites with lower priority are executed later",
@@ -104,6 +131,9 @@ def parse_arguments():
104131
parser.add_argument("--validate-only", help="validates the test definition file", action="store_true")
105132
parser.add_argument("--help-flags", help="prints information about available flags and exits", action="store_true")
106133
parser.add_argument("--cluster", help="output only cluster tests instead of single server", action="store_true")
134+
parser.add_argument("--single_cluster", help="process cluster cluster and single tests", action="store_true")
135+
parser.add_argument("--enterprise", help="add enterprise tests", action="store_true")
136+
parser.add_argument("--no-enterprise", help="add enterprise tests", action="store_true")
107137
parser.add_argument("--full", help="output full test set", action="store_true")
108138
parser.add_argument("--gtest", help="only run gtest", action="store_true")
109139
parser.add_argument("--all", help="output all test, ignore other filters", action="store_true")

Diff for: jenkins/helper/testing_runner.py

+57-49
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import sys
1111
import time
1212
from threading import Thread, Lock
13+
from multiprocessing import Process
14+
import zipfile
1315

1416
import psutil
1517

@@ -41,6 +43,17 @@
4143
except ModuleNotFoundError:
4244
pass
4345

46+
def zipp_this(filenames, target_dir):
47+
""" worker function to zip one file a time in a subprocess """
48+
# pylint: disable=consider-using-with
49+
for corefile in filenames:
50+
try:
51+
print(f'zipping {corefile}')
52+
zipfile.ZipFile(str(target_dir / (corefile.name + '.xz')),
53+
mode='w', compression=zipfile.ZIP_LZMA).write(str(corefile))
54+
except Exception as exc:
55+
print(f'skipping {corefile} since {exc}')
56+
4457
def testing_runner(testing_instance, this, arangosh):
4558
""" operate one makedata instance """
4659
try:
@@ -343,16 +356,28 @@ def cleanup_unneeded_binary_files(self):
343356
""" delete all files not needed for the crashreport binaries """
344357
shutil.rmtree(str(self.cfg.bin_dir / 'tzdata'))
345358
needed = [
346-
'arangod',
359+
'tzdata',
360+
'icudtl',
361+
'fuertetest',
362+
'arangovpack',
363+
'arangobackup',
347364
'arangosh',
348-
'arangodump',
349-
'arangorestore',
365+
'arangoexport',
366+
'arangoinspect',
350367
'arangoimport',
351-
'arangobackup',
352-
'arangodbtests']
368+
'arangoimp',
369+
'arango-secure-installation',
370+
'foxx-manager',
371+
'arangorestore',
372+
'arangobench',
373+
'snowball',
374+
'arangodbtests',
375+
'arangod',
376+
'arango-init-database',
377+
'arangodump']
353378
for one_file in self.cfg.bin_dir.iterdir():
354379
if (one_file.suffix == '.lib' or
355-
(one_file.stem not in needed) ):
380+
(one_file.stem not in needed)):
356381
print(f'Deleting {str(one_file)}')
357382
one_file.unlink(missing_ok=True)
358383

@@ -389,56 +414,45 @@ def generate_crash_report(self):
389414
print(f'Coredumps are not collected: {str(len(core_files_list))} coredumps found; coredumps max limit to collect is {str(core_max_count)}!')
390415
return
391416

392-
for one_file in core_files_list:
393-
if one_file.is_file():
394-
size = (one_file.stat().st_size / (1024 * 1024))
395-
if 0 < MAX_COREFILE_SIZE_MB and MAX_COREFILE_SIZE_MB < size:
396-
print(f'deleting coredump {str(one_file)} its too big: {str(size)}')
397-
one_file.unlink(missing_ok=True)
398-
core_files_list.remove(one_file)
399-
else:
400-
print(f"removing file from list {str(one_file)}")
401-
core_files_list.remove(one_file)
402-
403-
if len(core_files_list) > core_max_count and core_max_count > 0:
404-
count = 0
405-
for one_crash_file in core_files_list:
406-
count += 1
407-
if count > core_max_count:
408-
print(f'{core_max_count} reached. will not archive {one_crash_file}')
409-
one_crash_file.unlink(missing_ok=True)
410-
core_files_list.remove(one_crash_file)
411-
412-
if len(core_files_list) == 0:
413-
return
414-
self.crashed = True
415-
416417
core_zip_dir = get_workspace() / 'coredumps'
417418
core_zip_dir.mkdir(parents=True, exist_ok=True)
419+
zip_slots = psutil.cpu_count(logical=False)
420+
count = 0
421+
zip_slot_array = []
422+
for _ in range(zip_slots):
423+
zip_slot_array.append([])
418424
for one_file in core_files_list:
419425
if one_file.exists():
420-
try:
421-
shutil.move(str(one_file.resolve()), str(core_zip_dir.resolve()))
422-
except shutil.Error as ex:
423-
msg = f"generate_crash_report: failed to move file while while gathering coredumps: {ex}"
424-
self.append_report_txt('\n' + msg + '\n')
425-
print(msg)
426-
except PermissionError as ex:
427-
print(f"won't move {str(one_file)} - not an owner! {str(ex)}")
428-
self.append_report_txt(f"won't move {str(one_file)} - not an owner! {str(ex)}")
426+
zip_slot_array[count % zip_slots].append(one_file)
427+
count += 1
428+
zippers = []
429+
print(f"coredump launching zipper sub processes {zip_slot_array}")
430+
for zip_slot in zip_slot_array:
431+
if len(zip_slot) > 0:
432+
proc = Process(target=zipp_this, args=(zip_slot, core_zip_dir))
433+
proc.start()
434+
zippers.append(proc)
435+
for zipper in zippers:
436+
zipper.join()
437+
print("compressing files done")
438+
439+
for one_file in core_files_list:
440+
if one_file.is_file():
441+
one_file.unlink(missing_ok=True)
429442

430443
crash_report_file = get_workspace() / datetime.now(tz=None).strftime(f"crashreport-{self.cfg.datetime_format}")
431444
print(f"creating crashreport: {str(crash_report_file)} with {str(core_files_list)}")
432445
sys.stdout.flush()
433446
try:
434447
shutil.make_archive(str(crash_report_file),
435-
ZIPFORMAT,
448+
'tar',
436449
(core_zip_dir / '..').resolve(),
437450
core_zip_dir.name,
438451
True)
439452
except Exception as ex:
440453
print("Failed to create binaries zip: " + str(ex))
441454
self.append_report_txt("Failed to create binaries zip: " + str(ex))
455+
442456
self.cleanup_unneeded_binary_files()
443457
binary_report_file = get_workspace() / datetime.now(tz=None).strftime(f"binaries-{self.cfg.datetime_format}")
444458
print("creating crashreport binary support zip: " + str(binary_report_file))
@@ -536,29 +550,23 @@ def create_testruns_file(self):
536550
</table>
537551
''')
538552

539-
def register_test_func(self, cluster, test):
553+
def register_test_func(self, test):
540554
""" print one test function """
541555
args = test["args"]
542556
params = test["params"]
543557
suffix = params.get("suffix", "")
544-
name = test["name"]
558+
name = test['prefix'] + test["name"]
545559
if suffix:
546560
name += f"_{suffix}"
547561

548562
if test["parallelity"] :
549563
parallelity = test["parallelity"]
550-
if 'single' in test['flags'] and cluster:
551-
return
552-
if 'cluster' in test['flags'] and not cluster:
553-
return
554-
if cluster:
564+
if 'cluster' in test['flags']:
555565
self.cluster = True
556566
if parallelity == 1:
557567
parallelity = 4
558568
args += ['--cluster', 'true',
559569
'--dumpAgencyOnError', 'true']
560-
if "enterprise" in test["flags"]:
561-
return
562570
if "ldap" in test["flags"] and not 'LDAPHOST' in os.environ:
563571
return
564572

0 commit comments

Comments
 (0)