Skip to content

Commit 0f71b23

Browse files
authored
QA-333: the clear name seems to sum up to too long filenames for several testes (#466)
* the clear name seems to sum up to too long filenames for several testcases * build the ID earlier * lint * fix tempdir handling * streamline parameter handling * dmesg needs to be adjusted to PID via params as wel.
1 parent 7a2bc7b commit 0f71b23

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

Diff for: jenkins/helper/arangosh.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/env python3
22
""" launch a testing.js instance with given testsuite and arguments """
33
import os
4-
54
from async_client import (
65
ArangoCLIprogressiveTimeoutExecutor,
76

@@ -16,15 +15,14 @@ class ArangoshExecutor(ArangoCLIprogressiveTimeoutExecutor):
1615
def __init__(self, site_config, slot_lock):
1716
self.slot_lock = slot_lock
1817
self.read_only = False
19-
self.temp_dir = ""
2018
super().__init__(site_config, None)
2119

22-
def get_environment(self):
20+
def get_environment(self, params):
2321
""" hook to implemnet custom environment variable setters """
2422
my_env = os.environ.copy()
25-
my_env['TMPDIR'] = str(self.temp_dir)
26-
my_env['TEMP'] = str(self.temp_dir)
27-
my_env['TMP'] = str(self.temp_dir)
23+
my_env['TMPDIR'] = str(params['temp_dir'])
24+
my_env['TEMP'] = str(params['temp_dir'])
25+
my_env['TMP'] = str(params['temp_dir'])
2826
return my_env
2927

3028
def run_testing(self,
@@ -34,14 +32,13 @@ def run_testing(self,
3432
directory,
3533
logfile,
3634
identifier,
37-
tempdir,
35+
temp_dir,
3836
verbose
3937
):
4038
# pylint: disable=R0913 disable=R0902
4139
""" testing.js wrapper """
4240
print('------')
4341
print(testing_args)
44-
self.temp_dir = tempdir
4542
args = [
4643
'-c', str(self.cfg.cfgdir / 'arangosh.conf'),
4744
"--log.foreground-tty", "true",
@@ -56,7 +53,7 @@ def run_testing(self,
5653
'--',
5754
testcase,
5855
'--testOutput', directory ] + testing_args
59-
params = make_logfile_params(verbose, logfile, self.cfg.trace)
56+
params = make_logfile_params(verbose, logfile, self.cfg.trace, temp_dir)
6057
ret = self.run_monitored(
6158
self.cfg.bin_dir / "arangosh",
6259
run_cmd,

Diff for: jenkins/helper/async_client.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def delete_tail_params(params):
8888
params['output'].close()
8989
print(f"{params['identifier']} {params['lfn']} closed")
9090

91-
def make_logfile_params(verbose, logfile, trace):
91+
def make_logfile_params(verbose, logfile, trace, temp_dir):
9292
""" create the structure to work with logfiles """
9393
return {
9494
"trace_io": True,
@@ -97,8 +97,10 @@ def make_logfile_params(verbose, logfile, trace):
9797
"verbose": verbose,
9898
"output": logfile.open('wb'),
9999
"identifier": "",
100-
"lfn": str(logfile)
100+
"lfn": str(logfile),
101+
"temp_dir": temp_dir
101102
}
103+
102104
def logfile_line_result(wait, line, params):
103105
""" Write the line to a logfile, print progress. """
104106
# pylint: disable=pointless-statement
@@ -269,19 +271,19 @@ def __init__(self, config, connect_instance, deadline_signal=-1):
269271
else:
270272
self.deadline_signal = signal.SIGINT
271273

272-
def dig_for_children(self):
274+
def dig_for_children(self, params):
273275
""" manual search for children that may be there without the self.pid still being there """
274276
children = []
275277
for process in psutil.process_iter(["pid", "ppid", "name"]):
276-
if process.ppid() == self.pid:
278+
if process.ppid() == params['pid']:
277279
children.append(process)
278280
elif (process.ppid() == 1 and
279281
(process.name().lower().find('arango') >= 0 or
280282
process.name().lower().find('tshark') >= 0)):
281283
children.append(process)
282284
return children
283285

284-
def get_environment(self):
286+
def get_environment(self, params):
285287
""" hook to implemnet custom environment variable setters """
286288
return os.environ.copy()
287289

@@ -357,10 +359,7 @@ def run_monitored(self,
357359
children = []
358360
if identifier == "":
359361
# pylint: disable=global-statement
360-
global ID_COUNTER
361-
my_no = ID_COUNTER
362-
ID_COUNTER += 1
363-
identifier = f"IO_{str(my_no)}"
362+
identifier = f"IO_{str(params.my_id)}"
364363
print(params)
365364
params['identifier'] = identifier
366365
if not isinstance(deadline,datetime):
@@ -376,10 +375,10 @@ def run_monitored(self,
376375
stderr=PIPE,
377376
close_fds=ON_POSIX,
378377
cwd=self.cfg.test_data_dir.resolve(),
379-
env=self.get_environment()
378+
env=self.get_environment(params)
380379
) as process:
381380
# pylint: disable=consider-using-f-string
382-
self.pid = process.pid
381+
params['pid'] = process.pid
383382
queue = Queue()
384383
thread1 = Thread(
385384
name=f"readIO {identifier}",
@@ -452,15 +451,15 @@ def run_monitored(self,
452451
try:
453452
children = children + process.children(recursive=True)
454453
rc_exit = process.wait(timeout=1)
455-
children = children + self.dig_for_children()
454+
children = children + self.dig_for_children(params)
456455
add_message_to_report(
457456
params,
458457
f"{identifier} exited unexpectedly: {str(rc_exit)}",
459458
True, True)
460459
kill_children(identifier, params, children)
461460
break
462461
except psutil.NoSuchProcess:
463-
children = children + self.dig_for_children()
462+
children = children + self.dig_for_children(params)
464463
add_message_to_report(
465464
params,
466465
f"{identifier} exited unexpectedly: {str(rc_exit)}",
@@ -502,7 +501,7 @@ def run_monitored(self,
502501
try:
503502
process.send_signal(self.deadline_signal)
504503
except psutil.NoSuchProcess:
505-
children = children + self.dig_for_children()
504+
children = children + self.dig_for_children(params)
506505
print_log(f"{identifier} process already dead!", params)
507506
elif have_deadline > 1 and datetime.now() > final_deadline:
508507
try:

Diff for: jenkins/helper/dmesg.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def launch(self):
5151

5252
def end_run(self):
5353
""" terminate dmesg again """
54-
print(f'killing dmesg {self.pid}')
54+
print(f"killing dmesg {self.params['pid']}")
5555
try:
56-
psutil.Process(self.pid).kill()
56+
psutil.Process(self.params['pid']).kill()
5757
except psutil.NoSuchProcess:
5858
print('dmesg already gone?')

Diff for: jenkins/helper/testing_runner.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def testing_runner(testing_instance, this, arangosh):
7171
this.summary += this.summary_file.read_text()
7272
else:
7373
print(f'{this.name_enum} no testreport!')
74+
final_name = TEMP / this.name
7475
if this.crashed or not this.success:
7576
print(str(this.log_file.name))
7677
print(this.log_file.parent / ("FAIL_" + str(this.log_file.name))
@@ -85,9 +86,11 @@ def testing_runner(testing_instance, this, arangosh):
8586
if this.crashed:
8687
testing_instance.crashed = True
8788
testing_instance.success = False
88-
temp_dir = TEMP / ("FAIL_" + this.name)
89-
this.temp_dir.rename(temp_dir)
90-
this.temp_dir = temp_dir
89+
final_name = TEMP / ("FAIL_" + this.name)
90+
try:
91+
this.temp_dir.rename(final_name)
92+
except FileExistsError as ex:
93+
print(f"can't expand the temp directory {ex} to {final_name}")
9194
finally:
9295
with arangosh.slot_lock:
9396
testing_instance.running_suites.remove(this.name_enum)
@@ -162,6 +165,8 @@ def launch_next(self, offset, counter, do_loadcheck):
162165
parallelity = self.scenarios[offset].parallelity
163166
self.used_slots += parallelity
164167
this = self.scenarios[offset]
168+
this.counter = counter
169+
this.temp_dir = TEMP / str(counter)
165170
this.name_enum = f"{this.name} {str(counter)}"
166171
print(f"launching {this.name_enum}")
167172
pp.pprint(this)

0 commit comments

Comments
 (0)