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):
level = logging_std.DEBUG
else:
level = logging_std.INFO
logging = logging_std.getLogger(name.upper())
logging = logging_std.getLogger(name)
for handler in logging.handlers[:]:
logging.removeHandler(handler)
if filename is None:
......
......@@ -58,7 +58,7 @@ def main(args=None):
)
# 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
from neo.admin.app import Application
......
......@@ -62,7 +62,7 @@ def main(args=None):
)
# 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
from neo.master.app import Application
......
......@@ -47,7 +47,7 @@ def main(args=None):
raise RuntimeError('The NEO cluster name must be supplied')
# set up logging
setupLog('neomigrate', None, options.verbose or False)
setupLog('NEOMIGRATE', None, options.verbose or False)
# open storages
from ZODB.FileStorage import FileStorage
......
......@@ -68,7 +68,7 @@ def main(args=None):
)
# 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
from neo.storage.app import Application
......
......@@ -94,13 +94,6 @@ ZODB_TEST_MODULES = [
('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):
""" Custom result class to build report with statistics per module """
......
......@@ -26,7 +26,7 @@ import MySQLdb
import neo
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.util import getAddressType
from time import time, gmtime
......@@ -92,8 +92,14 @@ class NeoTestBase(unittest.TestCase):
logger.PACKET_LOGGER.enable(True)
sys.stdout.write(' * %s ' % (self.id(), ))
sys.stdout.flush()
self.setupLog()
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):
unittest.TestCase.tearDown(self)
sys.stdout.write('\n')
......
......@@ -33,6 +33,7 @@ import psutil
import neo.scripts
from neo.neoctl.neoctl import NeoCTL, NotReadyException
from neo.lib import setupLog
from neo.lib.protocol import ClusterStates, NodeTypes, CellStates, NodeStates
from neo.lib.util import dump, SOCKET_CONNECTORS_DICT
from neo.tests import DB_ADMIN, DB_PASSWD, NeoTestBase, buildUrlFromString, \
......@@ -635,6 +636,10 @@ class NEOCluster(object):
class NEOFunctionalTest(NeoTestBase):
def setupLog(self):
log_file = os.path.join(self.getTempDirectory(), 'test.log')
setupLog('TEST', log_file, True)
def getTempDirectory(self):
# build the full path based on test case and current test method
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