Commit 5e9af25c authored by Julien Muchembled's avatar Julien Muchembled

tests: output logs of parent process in temporary directory of current run

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2738 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 8a49145c
...@@ -38,7 +38,7 @@ def setupLog(name='NEO', filename=None, verbose=False): ...@@ -38,7 +38,7 @@ def setupLog(name='NEO', filename=None, verbose=False):
level = logging_std.DEBUG level = logging_std.DEBUG
else: else:
level = logging_std.INFO level = logging_std.INFO
logging = logging_std.getLogger(name.upper()) logging = logging_std.getLogger(name)
for handler in logging.handlers[:]: for handler in logging.handlers[:]:
logging.removeHandler(handler) logging.removeHandler(handler)
if filename is None: if filename is None:
......
...@@ -58,7 +58,7 @@ def main(args=None): ...@@ -58,7 +58,7 @@ def main(args=None):
) )
# setup custom logging # setup custom logging
setupLog(config.getName(), options.logfile or None, options.verbose) setupLog(config.getName().upper(), options.logfile or None, options.verbose)
# and then, load and run the application # and then, load and run the application
from neo.admin.app import Application from neo.admin.app import Application
......
...@@ -62,7 +62,7 @@ def main(args=None): ...@@ -62,7 +62,7 @@ def main(args=None):
) )
# setup custom logging # setup custom logging
setupLog(config.getName(), options.logfile or None, options.verbose) setupLog(config.getName().upper(), options.logfile or None, options.verbose)
# and then, load and run the application # and then, load and run the application
from neo.master.app import Application from neo.master.app import Application
......
...@@ -47,7 +47,7 @@ def main(args=None): ...@@ -47,7 +47,7 @@ def main(args=None):
raise RuntimeError('The NEO cluster name must be supplied') raise RuntimeError('The NEO cluster name must be supplied')
# set up logging # set up logging
setupLog('neomigrate', None, options.verbose or False) setupLog('NEOMIGRATE', None, options.verbose or False)
# open storages # open storages
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
......
...@@ -68,7 +68,7 @@ def main(args=None): ...@@ -68,7 +68,7 @@ def main(args=None):
) )
# setup custom logging # setup custom logging
setupLog(config.getName(), options.logfile or None, options.verbose) setupLog(config.getName().upper(), options.logfile or None, options.verbose)
# and then, load and run the application # and then, load and run the application
from neo.storage.app import Application from neo.storage.app import Application
......
...@@ -94,13 +94,6 @@ ZODB_TEST_MODULES = [ ...@@ -94,13 +94,6 @@ ZODB_TEST_MODULES = [
('neo.tests.zodb.testZODB', 'check'), ('neo.tests.zodb.testZODB', 'check'),
] ]
# configuration
ATTACH_LOG = False # for ZODB test, only the client side is logged
LOG_FILE = 'neo.log'
# override logging configuration to send all messages to a file
for logger_name in ('NEO', 'CLIENT'):
neo.lib.setupLog(logger_name, filename=LOG_FILE)
class NeoTestRunner(unittest.TestResult): class NeoTestRunner(unittest.TestResult):
""" Custom result class to build report with statistics per module """ """ Custom result class to build report with statistics per module """
......
...@@ -26,7 +26,7 @@ import MySQLdb ...@@ -26,7 +26,7 @@ import MySQLdb
import neo import neo
from mock import Mock from mock import Mock
from neo.lib import debug, logger, protocol from neo.lib import debug, logger, protocol, setupLog
from neo.lib.protocol import Packets from neo.lib.protocol import Packets
from neo.lib.util import getAddressType from neo.lib.util import getAddressType
from time import time, gmtime from time import time, gmtime
...@@ -92,8 +92,14 @@ class NeoTestBase(unittest.TestCase): ...@@ -92,8 +92,14 @@ class NeoTestBase(unittest.TestCase):
logger.PACKET_LOGGER.enable(True) logger.PACKET_LOGGER.enable(True)
sys.stdout.write(' * %s ' % (self.id(), )) sys.stdout.write(' * %s ' % (self.id(), ))
sys.stdout.flush() sys.stdout.flush()
self.setupLog()
unittest.TestCase.setUp(self) unittest.TestCase.setUp(self)
def setupLog(self):
test_case, test_method = self.id().rsplit('.', 1)
log_file = os.path.join(getTempDirectory(), test_case + '.log')
setupLog(test_method, log_file, True)
def tearDown(self): def tearDown(self):
unittest.TestCase.tearDown(self) unittest.TestCase.tearDown(self)
sys.stdout.write('\n') sys.stdout.write('\n')
......
...@@ -33,6 +33,7 @@ import psutil ...@@ -33,6 +33,7 @@ import psutil
import neo.scripts import neo.scripts
from neo.neoctl.neoctl import NeoCTL, NotReadyException from neo.neoctl.neoctl import NeoCTL, NotReadyException
from neo.lib import setupLog
from neo.lib.protocol import ClusterStates, NodeTypes, CellStates, NodeStates from neo.lib.protocol import ClusterStates, NodeTypes, CellStates, NodeStates
from neo.lib.util import dump, SOCKET_CONNECTORS_DICT from neo.lib.util import dump, SOCKET_CONNECTORS_DICT
from neo.tests import DB_ADMIN, DB_PASSWD, NeoTestBase, buildUrlFromString, \ from neo.tests import DB_ADMIN, DB_PASSWD, NeoTestBase, buildUrlFromString, \
...@@ -635,6 +636,10 @@ class NEOCluster(object): ...@@ -635,6 +636,10 @@ class NEOCluster(object):
class NEOFunctionalTest(NeoTestBase): class NEOFunctionalTest(NeoTestBase):
def setupLog(self):
log_file = os.path.join(self.getTempDirectory(), 'test.log')
setupLog('TEST', log_file, True)
def getTempDirectory(self): def getTempDirectory(self):
# build the full path based on test case and current test method # build the full path based on test case and current test method
temp_dir = os.path.join(getTempDirectory(), self.id()) temp_dir = os.path.join(getTempDirectory(), self.id())
......
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