Skip to content

Commit 6ba0502

Browse files
authored
Feature/align tmp folder to testname (#462)
* split the huge file into its natural modules * remove unused imports * calculate nicer temp dir * try to flatten directories * remove debug
1 parent 19d794b commit 6ba0502

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

Diff for: jenkins/helper/arangosh.py

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/env python3
22
""" launch a testing.js instance with given testsuite and arguments """
3+
import os
34

45
from async_client import (
56
ArangoCLIprogressiveTimeoutExecutor,
@@ -15,21 +16,32 @@ class ArangoshExecutor(ArangoCLIprogressiveTimeoutExecutor):
1516
def __init__(self, site_config, slot_lock):
1617
self.slot_lock = slot_lock
1718
self.read_only = False
19+
self.temp_dir = ""
1820
super().__init__(site_config, None)
1921

22+
def get_environment(self):
23+
""" hook to implemnet custom environment variable setters """
24+
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)
28+
return my_env
29+
2030
def run_testing(self,
2131
testcase,
2232
testing_args,
2333
timeout,
2434
directory,
2535
logfile,
2636
identifier,
37+
tempdir,
2738
verbose
2839
):
2940
# pylint: disable=R0913 disable=R0902
3041
""" testing.js wrapper """
3142
print('------')
3243
print(testing_args)
44+
self.temp_dir = tempdir
3345
args = [
3446
'-c', str(self.cfg.cfgdir / 'arangosh.conf'),
3547
"--log.foreground-tty", "true",

Diff for: jenkins/helper/async_client.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ def __init__(self, config, connect_instance, deadline_signal=-1):
260260
else:
261261
self.deadline_signal = signal.SIGINT
262262

263-
263+
def get_environment(self):
264+
""" hook to implemnet custom environment variable setters """
265+
return os.environ.copy()
266+
264267
def run_arango_tool_monitored(
265268
self,
266269
executeable,
@@ -352,6 +355,7 @@ def run_monitored(self,
352355
stderr=PIPE,
353356
close_fds=ON_POSIX,
354357
cwd=self.cfg.test_data_dir.resolve(),
358+
env=self.get_environment()
355359
) as process:
356360
# pylint: disable=consider-using-f-string
357361
self.pid = process.pid

Diff for: jenkins/helper/test_config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import copy
44
import os
55

6-
from site_config import IS_WINDOWS, IS_MAC
6+
from site_config import IS_WINDOWS, IS_MAC, TEMP
77
TEST_LOG_FILES = []
88

99
class TestConfig():
@@ -40,6 +40,8 @@ def __init__(self,
4040
if not self.base_logdir.exists():
4141
self.base_logdir.mkdir()
4242
self.log_file = cfg.run_root / f'{self.name}.log'
43+
44+
self.temp_dir = TEMP / self.name
4345
# pylint: disable=global-variable-not-assigned
4446
global TEST_LOG_FILES
4547
try:

Diff for: jenkins/helper/testing_runner.py

+12
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def testing_runner(testing_instance, this, arangosh):
4949
this.base_logdir,
5050
this.log_file,
5151
this.name_enum,
52+
this.temp_dir,
5253
True) #verbose?
5354
this.success = (
5455
not ret["progressive_timeout"] or
@@ -86,6 +87,9 @@ def testing_runner(testing_instance, this, arangosh):
8687
if this.crashed:
8788
testing_instance.crashed = True
8889
testing_instance.success = False
90+
temp_dir = TEMP / ("FAIL_" + this.name)
91+
this.temp_dir.rename(temp_dir)
92+
this.temp_dir = temp_dir
8993
testing_instance.done_job(this.parallelity)
9094

9195
class TestingRunner():
@@ -435,6 +439,14 @@ def generate_crash_report(self):
435439
def generate_test_report(self):
436440
""" regular testresults zip """
437441
tarfile = get_workspace() / datetime.now(tz=None).strftime(f"testreport-{self.cfg.datetime_format}")
442+
print('flattening inner dir structure')
443+
for subdir in TEMP.iterdir():
444+
for subsubdir in subdir.iterdir():
445+
path_segment = subsubdir.parts[len(subsubdir.parts) - 1]
446+
if path_segment.startswith('arangosh_'):
447+
for subsubsubdir in subsubdir.iterdir():
448+
shutil.move(str(subsubsubdir), str(subdir))
449+
subsubdir.rmdir()
438450
print("Creating " + str(tarfile))
439451
sys.stdout.flush()
440452
try:

0 commit comments

Comments
 (0)