]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Default to not capturing log output in tests
authorMaru Newby <marun@redhat.com>
Tue, 3 Sep 2013 16:35:52 +0000 (16:35 +0000)
committerMaru Newby <marun@redhat.com>
Tue, 3 Sep 2013 17:32:32 +0000 (17:32 +0000)
Viewing log output while tests are still running can be useful for
debugging, but log output was previously always captured.  This
change ensures that log capture is off by default, but can still
be enabled by setting OS_LOG_CAPTURE=1 in the shell environment.

testr invocation is unchanged and will continue to capture logs by
default.

Change-Id: I9d0fb648541280cacfebb47f67f608378ae66ef3

.testr.conf
neutron/tests/base.py

index 719144046651e6178035c85bc74e34f851f6074f..01d160ec50c872aadb2ada6f0bfe34aa71bfd867 100644 (file)
@@ -1,4 +1,4 @@
 [DEFAULT]
-test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ neutron/tests/unit $LISTOPT $IDOPTION
+test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ neutron/tests/unit $LISTOPT $IDOPTION
 test_id_option=--load-list $IDFILE
 test_list_option=--list
index 3bb5a2e093bbebb76c6065dc6b05a84a27ff08b5..82fd051fa6a7baeb52609d4f3016c7db52e37546 100644 (file)
@@ -42,7 +42,15 @@ class BaseTestCase(testtools.TestCase):
             _level = logging.DEBUG
         else:
             _level = logging.INFO
-        self.useFixture(fixtures.FakeLogger(format=LOG_FORMAT, level=_level))
+        capture_logs = os.environ.get('OS_LOG_CAPTURE') in TRUE_STRING
+        if not capture_logs:
+            logging.basicConfig(format=LOG_FORMAT, level=_level)
+        self.log_fixture = self.useFixture(
+            fixtures.FakeLogger(
+                format=LOG_FORMAT,
+                level=_level,
+                nuke_handlers=capture_logs,
+            ))
 
         test_timeout = int(os.environ.get('OS_TEST_TIMEOUT', 0))
         if test_timeout == -1: