Commit 624b3d1d authored by Jérome Perrin's avatar Jérome Perrin

make testnode test less verbose

Don't log and fix a few resource warnings

See merge request nexedi/erp5!1307
parents 6c272cab 9c60d750
Pipeline #12490 failed with stage
in 0 seconds
...@@ -38,9 +38,6 @@ def dummySuiteLog(_): ...@@ -38,9 +38,6 @@ def dummySuiteLog(_):
class ERP5TestNode(TestCase): class ERP5TestNode(TestCase):
_handler = logging.StreamHandler(sys.stdout)
_handler.setFormatter(logging.Formatter('TESTNODE LOG: %(message)s'))
def setUp(self): def setUp(self):
self._temp_dir = tempfile.mkdtemp() self._temp_dir = tempfile.mkdtemp()
self.working_directory = os.path.join(self._temp_dir, 'testnode') self.working_directory = os.path.join(self._temp_dir, 'testnode')
...@@ -66,11 +63,9 @@ class ERP5TestNode(TestCase): ...@@ -66,11 +63,9 @@ class ERP5TestNode(TestCase):
os.mkdir(self.remote_repository0) os.mkdir(self.remote_repository0)
os.mkdir(self.remote_repository1) os.mkdir(self.remote_repository1)
os.mkdir(self.remote_repository2) os.mkdir(self.remote_repository2)
logging.getLogger().addHandler(self._handler)
def tearDown(self): def tearDown(self):
shutil.rmtree(self._temp_dir, True) shutil.rmtree(self._temp_dir, True)
logging.getLogger().removeHandler(self._handler)
def getTestNode(self): def getTestNode(self):
config = {} config = {}
......
...@@ -136,8 +136,6 @@ def killCommand(pid): ...@@ -136,8 +136,6 @@ def killCommand(pid):
class ProcessManager(object): class ProcessManager(object):
stdin = open(os.devnull)
def __init__(self, max_timeout=MAX_TIMEOUT): def __init__(self, max_timeout=MAX_TIMEOUT):
self.process_pid_set = set() self.process_pid_set = set()
signal.signal(signal.SIGTERM, self.sigterm_handler) signal.signal(signal.SIGTERM, self.sigterm_handler)
...@@ -176,23 +174,28 @@ class ProcessManager(object): ...@@ -176,23 +174,28 @@ class ProcessManager(object):
logger.info('subprocess_kw : %r', subprocess_kw) logger.info('subprocess_kw : %r', subprocess_kw)
logger.info('$ %s', command) logger.info('$ %s', command)
sys.stdout.flush() sys.stdout.flush()
p = subprocess.Popen(args, stdin=self.stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env, close_fds=True, with open(os.devnull) as stdin:
**subprocess_kw) p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE,
self.process_pid_set.add(p.pid) stderr=subprocess.PIPE, env=env, close_fds=True,
timer = threading.Timer(self.max_timeout, timeoutExpired, args=(p,)) **subprocess_kw)
self.timer_set.add(timer) self.process_pid_set.add(p.pid)
timer.start() timer = threading.Timer(self.max_timeout, timeoutExpired, args=(p,))
stdout, stderr = subprocess_capture(p, log_prefix, get_output=get_output, output_replacers=output_replacers) self.timer_set.add(timer)
timer.cancel() timer.start()
self.timer_set.discard(timer) stdout, stderr = subprocess_capture(p, log_prefix, get_output=get_output, output_replacers=output_replacers)
result = dict(status_code=p.returncode, command=command, timer.cancel()
stdout=stdout, stderr=stderr) self.timer_set.discard(timer)
self.process_pid_set.discard(p.pid) result = dict(status_code=p.returncode, command=command,
if self.under_cancellation: stdout=stdout, stderr=stderr)
raise CancellationError("Test Result was cancelled") self.process_pid_set.discard(p.pid)
if raise_error_if_fail and p.returncode: p.stdout.close()
raise SubprocessError(result) p.stderr.close()
if self.under_cancellation:
raise CancellationError("Test Result was cancelled")
if raise_error_if_fail and p.returncode:
raise SubprocessError(result)
return result return result
def getSupportedParameterList(self, program_path): def getSupportedParameterList(self, program_path):
......
...@@ -190,6 +190,7 @@ shared = true ...@@ -190,6 +190,7 @@ shared = true
finally: finally:
logger.propagate = True logger.propagate = True
logger.removeHandler(handler) logger.removeHandler(handler)
handler.close()
def checkRevision(self, test_result, node_test_suite): def checkRevision(self, test_result, node_test_suite):
if node_test_suite.revision == test_result.revision: if node_test_suite.revision == test_result.revision:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment