From 474b1e7e2f9618a74db3d1359bf2b8f8beffc221 Mon Sep 17 00:00:00 2001 From: Assaf Muller Date: Fri, 8 Apr 2016 15:16:54 -0400 Subject: [PATCH] Add logging for some functional tests Functional tests log to a file only if they inherit from the Sudo tests base class. This patch changes the base class for some test cases to make them log. Related-Bug: #1567668 Change-Id: I494ad5410e48489f1fb3689cec44c5a29bbc42f3 --- .../tests/functional/agent/linux/test_keepalived.py | 4 ++-- neutron/tests/functional/base.py | 12 ++++++++---- .../common/exclusive_resources/test_ip_address.py | 4 ++-- .../common/exclusive_resources/test_ip_network.py | 4 ++-- .../tests/common/exclusive_resources/test_port.py | 4 ++-- .../exclusive_resources/test_resource_allocator.py | 4 ++-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/neutron/tests/functional/agent/linux/test_keepalived.py b/neutron/tests/functional/agent/linux/test_keepalived.py index 8bc9c23afe3..a420f2794a5 100644 --- a/neutron/tests/functional/agent/linux/test_keepalived.py +++ b/neutron/tests/functional/agent/linux/test_keepalived.py @@ -19,12 +19,12 @@ from neutron._i18n import _ from neutron.agent.linux import external_process from neutron.agent.linux import keepalived from neutron.agent.linux import utils -from neutron.tests import base from neutron.tests.functional.agent.linux import helpers +from neutron.tests.functional import base from neutron.tests.unit.agent.linux import test_keepalived -class KeepalivedManagerTestCase(base.BaseTestCase, +class KeepalivedManagerTestCase(base.BaseLoggingTestCase, test_keepalived.KeepalivedConfBaseMixin): def setUp(self): diff --git a/neutron/tests/functional/base.py b/neutron/tests/functional/base.py index 59bf1ff7dc9..ddaa68104ba 100644 --- a/neutron/tests/functional/base.py +++ b/neutron/tests/functional/base.py @@ -28,7 +28,14 @@ SUDO_CMD = 'sudo -n' DEFAULT_LOG_DIR = '/tmp/dsvm-functional-logs/' -class BaseSudoTestCase(base.BaseTestCase): +class BaseLoggingTestCase(base.BaseTestCase): + def setUp(self): + super(BaseLoggingTestCase, self).setUp() + base.setup_test_logging( + cfg.CONF, DEFAULT_LOG_DIR, "%s.log" % self.id()) + + +class BaseSudoTestCase(BaseLoggingTestCase): """ Base class for tests requiring invocation of commands via a root helper. @@ -54,9 +61,6 @@ class BaseSudoTestCase(base.BaseTestCase): if not base.bool_from_env('OS_SUDO_TESTING'): self.skipTest('Testing with sudo is not enabled') - base.setup_test_logging( - cfg.CONF, DEFAULT_LOG_DIR, "%s.log" % self.id()) - config.register_root_helper(cfg.CONF) self.config(group='AGENT', root_helper=os.environ.get('OS_ROOTWRAP_CMD', SUDO_CMD)) diff --git a/neutron/tests/functional/tests/common/exclusive_resources/test_ip_address.py b/neutron/tests/functional/tests/common/exclusive_resources/test_ip_address.py index ab89610cfdc..0ce41ad3790 100644 --- a/neutron/tests/functional/tests/common/exclusive_resources/test_ip_address.py +++ b/neutron/tests/functional/tests/common/exclusive_resources/test_ip_address.py @@ -14,11 +14,11 @@ import netaddr -from neutron.tests import base from neutron.tests.common.exclusive_resources import ip_address +from neutron.tests.functional import base -class TestExclusiveIPAddress(base.DietTestCase): +class TestExclusiveIPAddress(base.BaseLoggingTestCase): def test_ip_address(self): address_1 = self.useFixture( ip_address.ExclusiveIPAddress('10.0.0.1', '10.0.0.2')).address diff --git a/neutron/tests/functional/tests/common/exclusive_resources/test_ip_network.py b/neutron/tests/functional/tests/common/exclusive_resources/test_ip_network.py index 5c40f48f8d3..a03e7db2e7e 100644 --- a/neutron/tests/functional/tests/common/exclusive_resources/test_ip_network.py +++ b/neutron/tests/functional/tests/common/exclusive_resources/test_ip_network.py @@ -14,11 +14,11 @@ import netaddr -from neutron.tests import base from neutron.tests.common.exclusive_resources import ip_network +from neutron.tests.functional import base -class TestExclusiveIPNetwork(base.DietTestCase): +class TestExclusiveIPNetwork(base.BaseLoggingTestCase): def test_ip_network(self): network_1 = self.useFixture( ip_network.ExclusiveIPNetwork( diff --git a/neutron/tests/functional/tests/common/exclusive_resources/test_port.py b/neutron/tests/functional/tests/common/exclusive_resources/test_port.py index 9d845b26b9f..190dcbf1b9d 100644 --- a/neutron/tests/functional/tests/common/exclusive_resources/test_port.py +++ b/neutron/tests/functional/tests/common/exclusive_resources/test_port.py @@ -14,11 +14,11 @@ from neutron_lib import constants -from neutron.tests import base from neutron.tests.common.exclusive_resources import port +from neutron.tests.functional import base -class TestExclusivePort(base.DietTestCase): +class TestExclusivePort(base.BaseLoggingTestCase): def test_port(self): port_1 = self.useFixture(port.ExclusivePort( constants.PROTO_NAME_TCP)).port diff --git a/neutron/tests/functional/tests/common/exclusive_resources/test_resource_allocator.py b/neutron/tests/functional/tests/common/exclusive_resources/test_resource_allocator.py index 715847f77b6..eea791b08a8 100644 --- a/neutron/tests/functional/tests/common/exclusive_resources/test_resource_allocator.py +++ b/neutron/tests/functional/tests/common/exclusive_resources/test_resource_allocator.py @@ -17,8 +17,8 @@ import os import testtools from neutron.common import utils -from neutron.tests import base from neutron.tests.common.exclusive_resources import resource_allocator +from neutron.tests.functional import base def safe_remove_file(file_path): @@ -28,7 +28,7 @@ def safe_remove_file(file_path): pass -class TestResourceAllocator(base.DietTestCase): +class TestResourceAllocator(base.BaseLoggingTestCase): def setUp(self): super(TestResourceAllocator, self).setUp() self.ra = resource_allocator.ResourceAllocator(