summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjuraj.linkes <juraj.linkes@pantheon.tech>2018-11-09 11:58:54 +0100
committerFlorin Coras <florin.coras@gmail.com>2018-11-09 23:33:59 +0000
commitdfb5f2aff3675b3d70ba024dfd367c688ea1def6 (patch)
tree814924c0a84981ed1ea8bc4605659aeb5ca5de1f
parentd5969e4a7b5aa4a51ee65a86e80e8ca3ae01c2a5 (diff)
Fix logging into multiple files
When running tests in one process, only one logger was used and each testcase added its own file handler, which resulted in logs appearing in multiple files. Fix this by restoring the creation of new loggers for each testcase and only reuse the stream handler from parent process. Change-Id: I5b8471e041dc769128fddb433d33812bfcb5ecf6 Signed-off-by: juraj.linkes <juraj.linkes@pantheon.tech>
-rw-r--r--test/framework.py9
-rw-r--r--test/log.py2
-rw-r--r--test/run_tests.py2
3 files changed, 6 insertions, 7 deletions
diff --git a/test/framework.py b/test/framework.py
index 27fcdb5a7f6..3201e632348 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -25,7 +25,7 @@ from vpp_lo_interface import VppLoInterface
from vpp_papi_provider import VppPapiProvider
from vpp_papi.vpp_stats import VPPStats
from log import RED, GREEN, YELLOW, double_line_delim, single_line_delim, \
- getLogger, colorize
+ get_logger, colorize
from vpp_object import VppObjectRegistry
from util import ppp, is_core_present
from scapy.layers.inet import IPerror, TCPerror, UDPerror, ICMPerror
@@ -369,10 +369,9 @@ class VppTestCase(unittest.TestCase):
gc.collect() # run garbage collection first
random.seed()
cls.print_header(cls)
- if not hasattr(cls, 'logger'):
- cls.logger = getLogger(cls.__name__)
- else:
- cls.logger.name = cls.__name__
+ cls.logger = get_logger(cls.__name__)
+ if hasattr(cls, 'parallel_handler'):
+ cls.logger.addHandler(cls.parallel_handler)
cls.tempdir = tempfile.mkdtemp(
prefix='vpp-unittest-%s-' % cls.__name__)
cls.stats_sock = "%s/stats.sock" % cls.tempdir
diff --git a/test/log.py b/test/log.py
index 9720cbcc41d..de127fefb27 100644
--- a/test/log.py
+++ b/test/log.py
@@ -50,7 +50,7 @@ scapy_logger = logging.getLogger("scapy.runtime")
scapy_logger.setLevel(logging.ERROR)
-def getLogger(name):
+def get_logger(name):
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
return logger
diff --git a/test/run_tests.py b/test/run_tests.py
index c42c6a820dc..b2de2e702fb 100644
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -120,7 +120,7 @@ def test_runner_wrapper(suite, keep_alive_pipe, stdouterr_queue,
finished_pipe, result_pipe, logger):
sys.stdout = stdouterr_queue
sys.stderr = stdouterr_queue
- VppTestCase.logger = logger
+ VppTestCase.parallel_handler = logger.handlers[0]
result = VppTestRunner(keep_alive_pipe=keep_alive_pipe,
descriptions=descriptions,
verbosity=verbose,