From: Sean McGinnis Date: Wed, 1 Jul 2015 20:14:57 +0000 (-0500) Subject: Remove useless logging from unit tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=46e1f1741d85c946f012d1c1da0189dec85d1f08;p=openstack-build%2Fcinder-build.git Remove useless logging from unit tests It has been discussed that there really isn't much point in having unit tests making any kind of logger calls. Some usage has already been cleaned up. This patch removes the remaining instances of log calls under the cinder/tests directory. Also cleaned up a lot of cases where the source files would import oslo_logging and declare a LOG variable which was never actually used. Leaving logging in the cinder/tests/unit/integrated tree for now until a plan is decided as to what to do with all of these type of tests. Added hacking check to prevent new instances from slipping by code reviews. Change-Id: If177394486d5c92fa5466cd3825b15d30cf5fb18 --- diff --git a/HACKING.rst b/HACKING.rst index b0e412311..198ca3299 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -25,6 +25,7 @@ Cinder Specific Commandments - [C306] timeutils.strtime() must not be used (deprecated). - [C307] LOG.warn is deprecated. Enforce use of LOG.warning. - [C308] timeutils.isotime() must not be used (deprecated). +- [C309] Unit tests should not perform logging. General ------- diff --git a/cinder/hacking/checks.py b/cinder/hacking/checks.py index e130b077c..00ec758d4 100644 --- a/cinder/hacking/checks.py +++ b/cinder/hacking/checks.py @@ -57,6 +57,8 @@ log_translation_LE = re.compile( r"(.)*LOG\.(exception|error)\(\s*(_\(|'|\")") log_translation_LW = re.compile( r"(.)*LOG\.(warning|warn)\(\s*(_\(|'|\")") +logging_instance = re.compile( + r"(.)*LOG\.(warning|info|debug|error|exception)\(") class BaseASTChecker(ast.NodeVisitor): @@ -307,6 +309,17 @@ def check_timeutils_isotime(logical_line): yield(0, msg) +def no_test_log(logical_line, filename, noqa): + if "cinder/tests" not in filename or noqa: + return + # Skip the "integrated" tests for now + if "cinder/tests/unit/integrated" in filename: + return + msg = "C309: Unit tests should not perform logging." + if logging_instance.match(logical_line): + yield (0, msg) + + def factory(register): register(no_vi_headers) register(no_translate_debug_logs) @@ -324,3 +337,4 @@ def factory(register): register(check_no_contextlib_nested) register(no_log_warn) register(dict_constructor_with_list_copy) + register(no_test_log) diff --git a/cinder/tests/unit/api/contrib/test_cgsnapshots.py b/cinder/tests/unit/api/contrib/test_cgsnapshots.py index 9b2458846..21124732a 100644 --- a/cinder/tests/unit/api/contrib/test_cgsnapshots.py +++ b/cinder/tests/unit/api/contrib/test_cgsnapshots.py @@ -21,7 +21,6 @@ import json from xml.dom import minidom import mock -from oslo_log import log as logging import webob from cinder.consistencygroup import api as consistencygroupAPI @@ -34,9 +33,6 @@ from cinder.tests.unit import utils import cinder.volume -LOG = logging.getLogger(__name__) - - class CgsnapshotsAPITestCase(test.TestCase): """Test Case for cgsnapshots API.""" @@ -76,7 +72,6 @@ class CgsnapshotsAPITestCase(test.TestCase): consistencygroup_id)['id'] cgsnapshot_id = self._create_cgsnapshot( consistencygroup_id=consistencygroup_id) - LOG.debug('Created cgsnapshot with id %s' % cgsnapshot_id) req = webob.Request.blank('/v2/fake/cgsnapshots/%s' % cgsnapshot_id) req.method = 'GET' @@ -364,7 +359,6 @@ class CgsnapshotsAPITestCase(test.TestCase): res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) - LOG.info(res_dict) self.assertEqual(res.status_int, 202) self.assertIn('id', res_dict['cgsnapshot']) diff --git a/cinder/tests/unit/api/contrib/test_hosts.py b/cinder/tests/unit/api/contrib/test_hosts.py index 139842663..33a727163 100644 --- a/cinder/tests/unit/api/contrib/test_hosts.py +++ b/cinder/tests/unit/api/contrib/test_hosts.py @@ -16,7 +16,6 @@ import datetime from lxml import etree -from oslo_log import log as logging from oslo_utils import timeutils import webob.exc @@ -26,7 +25,6 @@ from cinder import db from cinder import test -LOG = logging.getLogger(__name__) created_time = datetime.datetime(2012, 11, 14, 1, 20, 41, 95099) curr_time = datetime.datetime(2013, 7, 3, 0, 0, 1) diff --git a/cinder/tests/unit/api/contrib/test_volume_transfer.py b/cinder/tests/unit/api/contrib/test_volume_transfer.py index 665b2e19d..3397c2de3 100644 --- a/cinder/tests/unit/api/contrib/test_volume_transfer.py +++ b/cinder/tests/unit/api/contrib/test_volume_transfer.py @@ -20,7 +20,6 @@ Tests for volume transfer code. import json from xml.dom import minidom -from oslo_log import log as logging import webob from cinder.api.contrib import volume_transfer @@ -32,9 +31,6 @@ from cinder.tests.unit.api import fakes import cinder.transfer -LOG = logging.getLogger(__name__) - - class VolumeTransferAPITestCase(test.TestCase): """Test Case for transfers API.""" @@ -71,7 +67,6 @@ class VolumeTransferAPITestCase(test.TestCase): def test_show_transfer(self): volume_id = self._create_volume(size=5) transfer = self._create_transfer(volume_id) - LOG.debug('Created transfer with id %s' % transfer) req = webob.Request.blank('/v2/fake/os-volume-transfer/%s' % transfer['id']) req.method = 'GET' @@ -269,7 +264,6 @@ class VolumeTransferAPITestCase(test.TestCase): res = req.get_response(fakes.wsgi_app()) res_dict = json.loads(res.body) - LOG.info(res_dict) self.assertEqual(res.status_int, 202) self.assertIn('id', res_dict['transfer']) diff --git a/cinder/tests/unit/api/test_router.py b/cinder/tests/unit/api/test_router.py index c3f4e68e8..ca35aeba2 100644 --- a/cinder/tests/unit/api/test_router.py +++ b/cinder/tests/unit/api/test_router.py @@ -13,8 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging - from cinder.api.openstack import wsgi from cinder.api.v1 import router from cinder.api.v1 import snapshots @@ -24,9 +22,6 @@ from cinder import test from cinder.tests.unit.api import fakes -LOG = logging.getLogger(__name__) - - class FakeController(object): def __init__(self, ext_mgr=None): self.ext_mgr = ext_mgr diff --git a/cinder/tests/unit/api/v1/test_snapshots.py b/cinder/tests/unit/api/v1/test_snapshots.py index fd4b7cc71..f2cbb4058 100644 --- a/cinder/tests/unit/api/v1/test_snapshots.py +++ b/cinder/tests/unit/api/v1/test_snapshots.py @@ -15,7 +15,6 @@ from lxml import etree import mock -from oslo_log import log as logging from oslo_utils import timeutils import webob @@ -32,8 +31,6 @@ from cinder.tests.unit import fake_volume from cinder import volume -LOG = logging.getLogger(__name__) - UUID = '00000000-0000-0000-0000-000000000001' INVALID_UUID = '00000000-0000-0000-0000-000000000002' diff --git a/cinder/tests/unit/api/v2/test_snapshots.py b/cinder/tests/unit/api/v2/test_snapshots.py index 26df1078a..9c362c3be 100644 --- a/cinder/tests/unit/api/v2/test_snapshots.py +++ b/cinder/tests/unit/api/v2/test_snapshots.py @@ -15,7 +15,6 @@ from lxml import etree import mock -from oslo_log import log as logging from oslo_utils import timeutils import webob @@ -32,8 +31,6 @@ from cinder.tests.unit import fake_volume from cinder import volume -LOG = logging.getLogger(__name__) - UUID = '00000000-0000-0000-0000-000000000001' INVALID_UUID = '00000000-0000-0000-0000-000000000002' diff --git a/cinder/tests/unit/brick/fake_lvm.py b/cinder/tests/unit/brick/fake_lvm.py index 2bfb79807..61f28ec01 100644 --- a/cinder/tests/unit/brick/fake_lvm.py +++ b/cinder/tests/unit/brick/fake_lvm.py @@ -10,11 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging - - -LOG = logging.getLogger(__name__) - class FakeBrickLVM(object): """Logs and records calls, for unit tests.""" diff --git a/cinder/tests/unit/brick/test_brick_lvm.py b/cinder/tests/unit/brick/test_brick_lvm.py index a032edfb1..77744c688 100644 --- a/cinder/tests/unit/brick/test_brick_lvm.py +++ b/cinder/tests/unit/brick/test_brick_lvm.py @@ -14,15 +14,12 @@ # under the License. from mox3 import mox from oslo_concurrency import processutils -from oslo_log import log as logging from cinder.brick.local_dev import lvm as brick from cinder import exception from cinder import test from cinder.volume import configuration as conf -LOG = logging.getLogger(__name__) - def create_configuration(): configuration = mox.MockObject(conf.Configuration) diff --git a/cinder/tests/unit/db/test_purge.py b/cinder/tests/unit/db/test_purge.py index 94f4adebb..e2a07e2fd 100644 --- a/cinder/tests/unit/db/test_purge.py +++ b/cinder/tests/unit/db/test_purge.py @@ -18,7 +18,6 @@ import datetime import uuid -from oslo_log import log as logging from oslo_utils import timeutils from cinder import context @@ -30,9 +29,6 @@ from cinder import test from oslo_db.sqlalchemy import utils as sqlalchemyutils -LOG = logging.getLogger(__name__) - - class PurgeDeletedTest(test.TestCase): def setUp(self): diff --git a/cinder/tests/unit/db/test_qos_specs.py b/cinder/tests/unit/db/test_qos_specs.py index 0fb6c59ae..4bdcb7944 100644 --- a/cinder/tests/unit/db/test_qos_specs.py +++ b/cinder/tests/unit/db/test_qos_specs.py @@ -19,8 +19,6 @@ import time -from oslo_log import log as logging - from cinder import context from cinder import db from cinder import exception @@ -28,9 +26,6 @@ from cinder import test from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - - def fake_qos_specs_get_by_name(context, name, session=None, inactive=False): pass diff --git a/cinder/tests/unit/db/test_transfers.py b/cinder/tests/unit/db/test_transfers.py index 5e54998ee..557096995 100644 --- a/cinder/tests/unit/db/test_transfers.py +++ b/cinder/tests/unit/db/test_transfers.py @@ -15,8 +15,6 @@ """Tests for transfers table.""" -from oslo_log import log as logging - from cinder import context from cinder import db from cinder import exception @@ -24,9 +22,6 @@ from cinder import test from cinder.tests.unit import utils -LOG = logging.getLogger(__name__) - - class TransfersTableTestCase(test.TestCase): """Test case for transfers model.""" diff --git a/cinder/tests/unit/fake_driver.py b/cinder/tests/unit/fake_driver.py index dcc6eeca5..d68bbb088 100644 --- a/cinder/tests/unit/fake_driver.py +++ b/cinder/tests/unit/fake_driver.py @@ -12,18 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging - -from cinder.i18n import _LE from cinder.tests.unit.brick import fake_lvm from cinder.volume import driver from cinder.volume.drivers import lvm from cinder.zonemanager import utils as fczm_utils -LOG = logging.getLogger(__name__) - - class FakeISCSIDriver(lvm.LVMISCSIDriver): """Logs calls instead of executing.""" def __init__(self, *args, **kwargs): @@ -58,7 +52,6 @@ class FakeISCSIDriver(lvm.LVMISCSIDriver): @staticmethod def fake_execute(cmd, *_args, **_kwargs): """Execute that simply logs the command.""" - LOG.debug("FAKE ISCSI: %s", cmd) return (None, None) @@ -77,7 +70,6 @@ class FakeISERDriver(FakeISCSIDriver): @staticmethod def fake_execute(cmd, *_args, **_kwargs): """Execute that simply logs the command.""" - LOG.debug("FAKE ISER: %s", cmd) return (None, None) @@ -134,7 +126,6 @@ class LoggingVolumeDriver(driver.VolumeDriver): self.log_action('clear_volume', volume) def local_path(self, volume): - LOG.error(_LE("local_path not implemented")) raise NotImplementedError() def ensure_export(self, context, volume): @@ -161,12 +152,10 @@ class LoggingVolumeDriver(driver.VolumeDriver): @staticmethod def log_action(action, parameters): """Logs the command.""" - LOG.debug("LoggingVolumeDriver: %s" % (action)) log_dictionary = {} if parameters: log_dictionary = dict(parameters) log_dictionary['action'] = action - LOG.debug("LoggingVolumeDriver: %s" % (log_dictionary)) LoggingVolumeDriver._LOGS.append(log_dictionary) @staticmethod diff --git a/cinder/tests/unit/fake_utils.py b/cinder/tests/unit/fake_utils.py index 885f473e4..3f430acd2 100644 --- a/cinder/tests/unit/fake_utils.py +++ b/cinder/tests/unit/fake_utils.py @@ -17,14 +17,10 @@ import re from eventlet import greenthread -from oslo_concurrency import processutils -from oslo_log import log as logging import six from cinder import utils -LOG = logging.getLogger(__name__) - _fake_execute_repliers = [] _fake_execute_log = [] @@ -68,7 +64,6 @@ def fake_execute(*cmd_parts, **kwargs): run_as_root = kwargs.get('run_as_root', False) cmd_str = ' '.join(str(part) for part in cmd_parts) - LOG.debug("Faking execution of cmd (subprocess): %s", cmd_str) _fake_execute_log.append(cmd_str) reply_handler = fake_execute_default_reply_handler @@ -76,28 +71,19 @@ def fake_execute(*cmd_parts, **kwargs): for fake_replier in _fake_execute_repliers: if re.match(fake_replier[0], cmd_str): reply_handler = fake_replier[1] - LOG.debug('Faked command matched %s' % fake_replier[0]) break if isinstance(reply_handler, six.string_types): # If the reply handler is a string, return it as stdout reply = reply_handler, '' else: - try: - # Alternative is a function, so call it - reply = reply_handler(cmd_parts, - process_input=process_input, - delay_on_retry=delay_on_retry, - attempts=attempts, - run_as_root=run_as_root, - check_exit_code=check_exit_code) - except processutils.ProcessExecutionError as e: - LOG.debug('Faked command raised an exception %s', e) - raise - - LOG.debug("Reply to faked command is stdout='%(stdout)s' " - "stderr='%(stderr)s'" % {'stdout': reply[0], - 'stderr': reply[1]}) + # Alternative is a function, so call it + reply = reply_handler(cmd_parts, + process_input=process_input, + delay_on_retry=delay_on_retry, + attempts=attempts, + run_as_root=run_as_root, + check_exit_code=check_exit_code) # Replicate the sleep call in the real function greenthread.sleep(0) diff --git a/cinder/tests/unit/image/fake.py b/cinder/tests/unit/image/fake.py index b178326e2..5214e09e8 100644 --- a/cinder/tests/unit/image/fake.py +++ b/cinder/tests/unit/image/fake.py @@ -20,15 +20,10 @@ import copy import datetime import uuid -from oslo_log import log as logging - from cinder import exception import cinder.image.glance -LOG = logging.getLogger(__name__) - - class _FakeImageService(object): """Mock (fake) image service for unit testing.""" @@ -163,8 +158,6 @@ class _FakeImageService(object): image = self.images.get(str(image_id)) if image: return copy.deepcopy(image) - LOG.warning('Unable to find image id %s. Have images: %s', - image_id, self.images) raise exception.ImageNotFound(image_id=image_id) def create(self, context, metadata, data=None): diff --git a/cinder/tests/unit/scheduler/test_scheduler.py b/cinder/tests/unit/scheduler/test_scheduler.py index 288f4ccc7..78ed770f2 100644 --- a/cinder/tests/unit/scheduler/test_scheduler.py +++ b/cinder/tests/unit/scheduler/test_scheduler.py @@ -1,4 +1,3 @@ - # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. @@ -20,7 +19,6 @@ Tests For Scheduler import mock from oslo_config import cfg -from oslo_log import log as logging from cinder import context from cinder import db @@ -266,9 +264,7 @@ class SchedulerManagerTestCase(test.TestCase): 'schedule_create_consistencygroup') as mock_cg: original_driver = self.manager.driver self.manager.driver = filter_scheduler.FilterScheduler - LOG = logging.getLogger('cinder.scheduler.manager') - self.stubs.Set(LOG, 'error', mock.Mock()) - self.stubs.Set(LOG, 'exception', mock.Mock()) + LOG = self.mock_object(manager, 'LOG') self.stubs.Set(db, 'consistencygroup_update', mock.Mock()) ex = exception.CinderException('test') diff --git a/cinder/tests/unit/test_blockbridge.py b/cinder/tests/unit/test_blockbridge.py index 333a4267c..6b0c9b878 100644 --- a/cinder/tests/unit/test_blockbridge.py +++ b/cinder/tests/unit/test_blockbridge.py @@ -21,7 +21,6 @@ try: from unittest import mock except ImportError: import mock -from oslo_log import log as logging from oslo_serialization import jsonutils from oslo_utils import units import six @@ -34,8 +33,6 @@ from cinder import test from cinder.volume import configuration as conf import cinder.volume.drivers.blockbridge as bb -LOG = logging.getLogger(__name__) - DEFAULT_POOL_NAME = "OpenStack" DEFAULT_POOL_QUERY = "+openstack" diff --git a/cinder/tests/unit/test_dellfc.py b/cinder/tests/unit/test_dellfc.py index 99aedc92a..53ebf4b19 100644 --- a/cinder/tests/unit/test_dellfc.py +++ b/cinder/tests/unit/test_dellfc.py @@ -13,7 +13,6 @@ # under the License. import mock -from oslo_log import log as logging from cinder import context from cinder import exception @@ -22,12 +21,8 @@ from cinder.volume.drivers.dell import dell_storagecenter_api from cinder.volume.drivers.dell import dell_storagecenter_fc -LOG = logging.getLogger(__name__) - # We patch these here as they are used by every test to keep # from trying to contact a Dell Storage Center. - - @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '__init__', return_value=None) diff --git a/cinder/tests/unit/test_dellsc.py b/cinder/tests/unit/test_dellsc.py index a99fdd60b..e6809962c 100644 --- a/cinder/tests/unit/test_dellsc.py +++ b/cinder/tests/unit/test_dellsc.py @@ -12,7 +12,9 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_log import log as logging +import uuid + +import mock from cinder import context from cinder import exception @@ -21,17 +23,9 @@ from cinder.volume.drivers.dell import dell_storagecenter_api from cinder.volume.drivers.dell import dell_storagecenter_iscsi from cinder.volume import volume_types -import mock - -import uuid - - -LOG = logging.getLogger(__name__) # We patch these here as they are used by every test to keep # from trying to contact a Dell Storage Center. - - @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '__init__', return_value=None) diff --git a/cinder/tests/unit/test_dellscapi.py b/cinder/tests/unit/test_dellscapi.py index 6fc071a45..a1a88c5f8 100644 --- a/cinder/tests/unit/test_dellscapi.py +++ b/cinder/tests/unit/test_dellscapi.py @@ -13,24 +13,18 @@ # under the License. import ddt -from oslo_log import log as logging +import mock +from requests import models +import uuid from cinder import context from cinder import exception from cinder import test from cinder.volume.drivers.dell import dell_storagecenter_api -import mock -from requests import models - -import uuid - -LOG = logging.getLogger(__name__) # We patch these here as they are used by every test to keep # from trying to contact a Dell Storage Center. - - @ddt.ddt @mock.patch.object(dell_storagecenter_api.StorageCenterApi, '__init__', diff --git a/cinder/tests/unit/test_drbdmanagedrv.py b/cinder/tests/unit/test_drbdmanagedrv.py index 14cc24552..c5e82b219 100644 --- a/cinder/tests/unit/test_drbdmanagedrv.py +++ b/cinder/tests/unit/test_drbdmanagedrv.py @@ -16,7 +16,6 @@ import collections import mock -from oslo_log import log as logging from oslo_utils import importutils from oslo_utils import timeutils @@ -71,9 +70,6 @@ sys.modules['drbdmanage.exceptions'] = collections.namedtuple( from cinder.volume.drivers import drbdmanagedrv -LOG = logging.getLogger(__name__) - - def create_configuration(object): configuration = mock.MockObject(conf.Configuration) configuration.san_is_local = False diff --git a/cinder/tests/unit/test_emc_vmax.py b/cinder/tests/unit/test_emc_vmax.py index b996ad413..55094e3cb 100644 --- a/cinder/tests/unit/test_emc_vmax.py +++ b/cinder/tests/unit/test_emc_vmax.py @@ -20,7 +20,6 @@ import time from xml.dom import minidom import mock -from oslo_log import log as logging from oslo_service import loopingcall from oslo_utils import units import six @@ -39,7 +38,6 @@ from cinder.volume.drivers.emc import emc_vmax_utils from cinder.volume import volume_types -LOG = logging.getLogger(__name__) CINDER_EMC_CONFIG_DIR = '/etc/cinder/' diff --git a/cinder/tests/unit/test_emc_xtremio.py b/cinder/tests/unit/test_emc_xtremio.py index 97a2a787c..9c6a00c70 100644 --- a/cinder/tests/unit/test_emc_xtremio.py +++ b/cinder/tests/unit/test_emc_xtremio.py @@ -15,16 +15,12 @@ import mock -from oslo_log import log as logging -import six from cinder import exception from cinder import test from cinder.volume.drivers.emc import xtremio -LOG = logging.getLogger(__name__) - typ2id = {'volumes': 'vol-id', 'snapshots': 'vol-id', 'initiators': 'initiator-id', @@ -149,8 +145,6 @@ def xms_request(object_type='volumes', request_typ='GET', data=None, del xms_data[object_type][data['index']] del xms_data[object_type][data[typ2id[object_type]][1]] else: - LOG.error('Trying to delete a missing object %s', - six.text_type(obj_key)) raise exception.NotFound() elif request_typ == 'PUT': if obj_key in xms_data[object_type]: @@ -160,8 +154,6 @@ def xms_request(object_type='volumes', request_typ='GET', data=None, if key: xms_data[object_type][data[key]] = obj else: - LOG.error('Trying to update a missing object %s', - six.text_type(obj_key)) raise exception.NotFound() diff --git a/cinder/tests/unit/test_eqlx.py b/cinder/tests/unit/test_eqlx.py index ce1e064dd..5704df690 100644 --- a/cinder/tests/unit/test_eqlx.py +++ b/cinder/tests/unit/test_eqlx.py @@ -18,7 +18,6 @@ import time from eventlet import greenthread import mock from oslo_concurrency import processutils -from oslo_log import log as logging import paramiko import six @@ -30,8 +29,6 @@ from cinder import utils from cinder.volume import configuration as conf from cinder.volume.drivers import eqlx -LOG = logging.getLogger(__name__) - class DellEQLSanISCSIDriverTestCase(test.TestCase): diff --git a/cinder/tests/unit/test_gpfs.py b/cinder/tests/unit/test_gpfs.py index bb13ec0e0..2dda0bade 100644 --- a/cinder/tests/unit/test_gpfs.py +++ b/cinder/tests/unit/test_gpfs.py @@ -19,7 +19,6 @@ import tempfile import mock from oslo_concurrency import processutils from oslo_config import cfg -from oslo_log import log as logging from oslo_utils import units from cinder import context @@ -31,8 +30,6 @@ from cinder.volume.drivers.ibm import gpfs from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - CONF = cfg.CONF diff --git a/cinder/tests/unit/test_hacking.py b/cinder/tests/unit/test_hacking.py index 62214480b..b8ba8013b 100644 --- a/cinder/tests/unit/test_hacking.py +++ b/cinder/tests/unit/test_hacking.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import ddt import textwrap import mock @@ -21,6 +22,7 @@ from cinder.hacking import checks from cinder import test +@ddt.ddt class HackingTestCase(test.TestCase): """This class tests the hacking checks in cinder.hacking.checks @@ -346,3 +348,18 @@ class HackingTestCase(test.TestCase): self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy( " self._render_dict(xml, data_el, data.__dict__)")))) + + @ddt.unpack + @ddt.data( + (1, 'LOG.info', "cinder/tests/unit/fake.py", False), + (1, 'LOG.warning', "cinder/tests/fake.py", False), + (1, 'LOG.error', "cinder/tests/fake.py", False), + (1, 'LOG.exception', "cinder/tests/fake.py", False), + (1, 'LOG.debug', "cinder/tests/fake.py", False), + (0, 'LOG.info.assert_called_once_with', "cinder/tests/fake.py", False), + (0, 'some.LOG.error.call', "cinder/tests/fake.py", False), + (0, 'LOG.warning', "cinder/tests/unit/fake.py", True), + (0, 'LOG.warning', "cinder/tests/unit/integrated/fake.py", False)) + def test_no_test_log(self, first, second, third, fourth): + self.assertEqual(first, len(list(checks.no_test_log( + "%s('arg')" % second, third, fourth)))) diff --git a/cinder/tests/unit/test_hitachi_hnas_backend.py b/cinder/tests/unit/test_hitachi_hnas_backend.py index e0a1fe365..26e9b9735 100644 --- a/cinder/tests/unit/test_hitachi_hnas_backend.py +++ b/cinder/tests/unit/test_hitachi_hnas_backend.py @@ -17,7 +17,6 @@ import mock from oslo_concurrency import processutils from oslo_config import cfg -from oslo_log import log as logging from cinder import test from cinder import utils @@ -26,8 +25,6 @@ from cinder.volume.drivers.hitachi import hnas_nfs as nfs CONF = cfg.CONF -LOG = logging.getLogger(__name__) - HNAS_RESULT1 = "\n\ FS ID FS Label FS Permanent ID EVS ID EVS Label\n\ ----- ----------- ------------------ ------ ---------\n\ @@ -271,8 +268,6 @@ UTILS_EXEC_OUT = ["output: test_cmd", ""] def m_run_cmd(*args, **kargs): - LOG.debug(args) - LOG.debug(HNAS_CMDS.get(args)) return HNAS_CMDS.get(args) diff --git a/cinder/tests/unit/test_hitachi_hnas_iscsi.py b/cinder/tests/unit/test_hitachi_hnas_iscsi.py index 8f5e8c795..59dbed844 100644 --- a/cinder/tests/unit/test_hitachi_hnas_iscsi.py +++ b/cinder/tests/unit/test_hitachi_hnas_iscsi.py @@ -22,7 +22,6 @@ import os import tempfile import mock -from oslo_log import log as logging import six from cinder import exception @@ -31,8 +30,6 @@ from cinder.volume import configuration as conf from cinder.volume.drivers.hitachi import hnas_iscsi as iscsi from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - HNASCONF = """ ssc @@ -104,24 +101,16 @@ class SimulatedHnasBackend(object): self.connections = [] def deleteVolume(self, name): - LOG.info("delVolume: name %s", name) - volume = self.getVolume(name) if volume: - LOG.info("deleteVolume: deleted name %s provider %s", - volume['name'], volume['provider_location']) self.volumes.remove(volume) return True else: return False def deleteVolumebyProvider(self, provider): - LOG.info("delVolumeP: provider %s", provider) - volume = self.getVolumebyProvider(provider) if volume: - LOG.info("deleteVolumeP: deleted name %s provider %s", - volume['name'], volume['provider_location']) self.volumes.remove(volume) return True else: @@ -131,39 +120,20 @@ class SimulatedHnasBackend(object): return self.volumes def getVolume(self, name): - LOG.info("getVolume: find by name %s", name) - if self.volumes: for volume in self.volumes: if str(volume['name']) == name: - LOG.info("getVolume: found name %s provider %s", - volume['name'], volume['provider_location']) return volume - else: - LOG.info("getVolume: no volumes") - - LOG.info("getVolume: not found") return None def getVolumebyProvider(self, provider): - LOG.info("getVolumeP: find by provider %s", provider) - if self.volumes: for volume in self.volumes: if str(volume['provider_location']) == provider: - LOG.info("getVolumeP: found name %s provider %s", - volume['name'], volume['provider_location']) return volume - else: - LOG.info("getVolumeP: no volumes") - - LOG.info("getVolumeP: not found") return None def createVolume(self, name, provider, sizeMiB, comment): - LOG.info("createVolume: name %s provider %s comment %s", - name, provider, comment) - new_vol = {'additionalStates': [], 'adminSpace': {'freeMiB': 0, 'rawReservedMiB': 384, @@ -203,10 +173,8 @@ class SimulatedHnasBackend(object): def delete_lu(self, cmd, ip0, user, pw, hdp, lun): _out = "" id = "myID" - LOG.info("Delete_Lu: check lun %s id %s", lun, id) - if self.deleteVolumebyProvider(id + '.' + str(lun)): - LOG.warning("Delete_Lu: failed to delete lun %s id %s", lun, id) + self.deleteVolumebyProvider(id + '.' + str(lun)) return _out def create_dup(self, cmd, ip0, user, pw, src_lun, hdp, size, name): @@ -214,7 +182,6 @@ class SimulatedHnasBackend(object): (self.start_lun, size)) id = name - LOG.info("HNAS Create_Dup: %d", self.start_lun) self.createVolume(name, id + '.' + str(self.start_lun), size, "create-dup") self.start_lun += 1 @@ -231,7 +198,6 @@ class SimulatedHnasBackend(object): self.init_index += 1 self.target_index += 1 self.hlun += 1 - LOG.debug("Created connection %d", self.init_index) self.connections.append(conn) return _out @@ -246,11 +212,9 @@ class SimulatedHnasBackend(object): _out = ("LUN: %s successfully extended to %s MB" % (lu, size)) id = name self.out = _out - LOG.info("extend_vol: lu: %s %d -> %s", lu, int(size), self.out) v = self.getVolumebyProvider(id + '.' + str(lu)) if v: v['sizeMiB'] = size - LOG.info("extend_vol: out %s %s", self.out, self) return _out def get_luns(self): diff --git a/cinder/tests/unit/test_hitachi_hnas_nfs.py b/cinder/tests/unit/test_hitachi_hnas_nfs.py index 194fe2d9c..e17bc0e3d 100644 --- a/cinder/tests/unit/test_hitachi_hnas_nfs.py +++ b/cinder/tests/unit/test_hitachi_hnas_nfs.py @@ -18,7 +18,6 @@ import os import tempfile import mock -from oslo_log import log as logging import six from cinder import exception @@ -27,7 +26,6 @@ from cinder.volume import configuration as conf from cinder.volume.drivers.hitachi import hnas_nfs as nfs from cinder.volume import volume_types -LOG = logging.getLogger(__name__) SHARESCONF = """172.17.39.132:/cinder 172.17.39.133:/cinder""" @@ -124,9 +122,7 @@ class SimulatedHnasBackend(object): def file_clone(self, cmd, ip0, user, pw, fslabel, source_path, target_path): - _out = "" - LOG.info("Clone: %s -> %s" % (source_path, target_path)) - return _out + return "" def get_version(self, ver, cmd, ip0, user, pw): self.out = "Array_ID: 18-48-A5-A1-80-13 (3080-G2) " \ diff --git a/cinder/tests/unit/test_hp3par.py b/cinder/tests/unit/test_hp3par.py index 6eb61195e..4280442fe 100644 --- a/cinder/tests/unit/test_hp3par.py +++ b/cinder/tests/unit/test_hp3par.py @@ -20,7 +20,6 @@ import mock import ast from oslo_config import cfg -from oslo_log import log as logging from oslo_utils import units from cinder import context @@ -36,8 +35,6 @@ from cinder.volume import volume_types hpexceptions = hp3parclient.hpexceptions -LOG = logging.getLogger(__name__) - CONF = cfg.CONF HP3PAR_CPG = 'OpenStackCPG' diff --git a/cinder/tests/unit/test_hplefthand.py b/cinder/tests/unit/test_hplefthand.py index f5ca8ca10..66492019c 100644 --- a/cinder/tests/unit/test_hplefthand.py +++ b/cinder/tests/unit/test_hplefthand.py @@ -16,7 +16,6 @@ """Unit tests for OpenStack Cinder volume drivers.""" import mock -from oslo_log import log as logging from oslo_utils import units import six @@ -30,8 +29,6 @@ from cinder.volume import volume_types hpexceptions = hplefthandclient.hpexceptions -LOG = logging.getLogger(__name__) - GOODNESS_FUNCTION = \ "capabilities.capacity_utilization < 0.6? 100 : 25" FILTER_FUNCTION = \ diff --git a/cinder/tests/unit/test_huawei_18000.py b/cinder/tests/unit/test_huawei_18000.py index d5826db7c..02b7a82fb 100644 --- a/cinder/tests/unit/test_huawei_18000.py +++ b/cinder/tests/unit/test_huawei_18000.py @@ -21,7 +21,6 @@ import time from xml.dom import minidom import mock -from oslo_log import log as logging from cinder import exception from cinder import test @@ -29,7 +28,6 @@ from cinder.volume import configuration as conf from cinder.volume.drivers.huawei import huawei_18000 from cinder.volume.drivers.huawei import rest_common -LOG = logging.getLogger(__name__) test_volume = {'name': 'volume-21ec7341-9256-497b-97d9-ef48edcf0635', 'size': 2, diff --git a/cinder/tests/unit/test_ibm_flashsystem.py b/cinder/tests/unit/test_ibm_flashsystem.py index cdd9cec4c..48b79b60f 100644 --- a/cinder/tests/unit/test_ibm_flashsystem.py +++ b/cinder/tests/unit/test_ibm_flashsystem.py @@ -21,8 +21,6 @@ Tests for the IBM FlashSystem volume driver. import mock from oslo_concurrency import processutils -from oslo_log import log as logging -from oslo_utils import excutils from oslo_utils import units import six @@ -38,8 +36,6 @@ from cinder.volume.drivers.ibm import flashsystem_fc from cinder.volume import utils as volume_utils from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - class FlashSystemManagementSimulator(object): def __init__(self): @@ -664,19 +660,8 @@ class FlashSystemFakeDriver(flashsystem_fc.FlashSystemFCDriver): self.fake_storage = fake def _ssh(self, cmd, check_exit_code=True): - try: - LOG.debug('Run CLI command: %s' % cmd) - utils.check_ssh_injection(cmd) - ret = self.fake_storage.execute_command(cmd, check_exit_code) - (stdout, stderr) = ret - LOG.debug('CLI output:\n stdout: %(stdout)s\n stderr: ' - '%(stderr)s' % {'stdout': stdout, 'stderr': stderr}) - - except processutils.ProcessExecutionError as e: - with excutils.save_and_reraise_exception(): - LOG.debug('CLI Exception output:\n stdout: %(out)s\n ' - 'stderr: %(err)s' % {'out': e.stdout, - 'err': e.stderr}) + utils.check_ssh_injection(cmd) + ret = self.fake_storage.execute_command(cmd, check_exit_code) return ret diff --git a/cinder/tests/unit/test_ibm_flashsystem_iscsi.py b/cinder/tests/unit/test_ibm_flashsystem_iscsi.py index 8da1ede7b..1d82edd9c 100644 --- a/cinder/tests/unit/test_ibm_flashsystem_iscsi.py +++ b/cinder/tests/unit/test_ibm_flashsystem_iscsi.py @@ -19,9 +19,6 @@ Tests for the IBM FlashSystem iSCSI volume driver. """ import mock -from oslo_concurrency import processutils -from oslo_log import log as logging -from oslo_utils import excutils import six import random @@ -35,8 +32,6 @@ from cinder.volume import configuration as conf from cinder.volume.drivers.ibm import flashsystem_iscsi from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - class FlashSystemManagementSimulator(fscommon.FlashSystemManagementSimulator): def __init__(self): @@ -66,20 +61,8 @@ class FlashSystemFakeISCSIDriver(flashsystem_iscsi.FlashSystemISCSIDriver): self.fake_storage = fake def _ssh(self, cmd, check_exit_code=True): - ret = None - try: - LOG.debug('Run CLI command: %s', cmd) - utils.check_ssh_injection(cmd) - ret = self.fake_storage.execute_command(cmd, check_exit_code) - (stdout, stderr) = ret - LOG.debug('CLI output:\n stdout: %(stdout)s\n stderr: ' - '%(stderr)s', {'stdout': stdout, 'stderr': stderr}) - - except processutils.ProcessExecutionError as e: - with excutils.save_and_reraise_exception(): - LOG.debug('CLI Exception output:\n stdout: %(out)s\n ' - 'stderr: %(err)s', {'out': e.stdout, - 'err': e.stderr}) + utils.check_ssh_injection(cmd) + ret = self.fake_storage.execute_command(cmd, check_exit_code) return ret diff --git a/cinder/tests/unit/test_ibmnas.py b/cinder/tests/unit/test_ibmnas.py index a7536030d..de7699aa4 100644 --- a/cinder/tests/unit/test_ibmnas.py +++ b/cinder/tests/unit/test_ibmnas.py @@ -23,7 +23,6 @@ NAS based IBM GPFS Storage Systems). import mock from oslo_config import cfg -from oslo_log import log as logging from oslo_utils import units from cinder import context @@ -32,8 +31,6 @@ from cinder import test from cinder.volume import configuration as conf from cinder.volume.drivers.ibm import ibmnas -LOG = logging.getLogger(__name__) - CONF = cfg.CONF diff --git a/cinder/tests/unit/test_netapp.py b/cinder/tests/unit/test_netapp.py index 89c952626..0f3ad1f16 100644 --- a/cinder/tests/unit/test_netapp.py +++ b/cinder/tests/unit/test_netapp.py @@ -19,7 +19,6 @@ Tests for NetApp volume driver from lxml import etree import mock -from oslo_log import log as logging import six from six.moves import BaseHTTPServer from six.moves import http_client @@ -35,9 +34,6 @@ from cinder.volume.drivers.netapp import options from cinder.volume.drivers.netapp import utils -LOG = logging.getLogger("cinder.volume.driver") - - def create_configuration(): configuration = conf.Configuration(None) configuration.append_config_values(options.netapp_connection_opts) diff --git a/cinder/tests/unit/test_netapp_eseries_iscsi.py b/cinder/tests/unit/test_netapp_eseries_iscsi.py index 52477f18a..e25828d93 100644 --- a/cinder/tests/unit/test_netapp_eseries_iscsi.py +++ b/cinder/tests/unit/test_netapp_eseries_iscsi.py @@ -23,7 +23,6 @@ import json import re import mock -from oslo_log import log as logging import requests from six.moves import urllib @@ -38,9 +37,6 @@ from cinder.volume.drivers.netapp import options import cinder.volume.drivers.netapp.utils as na_utils -LOG = logging.getLogger(__name__) - - def create_configuration(): configuration = conf.Configuration(None) configuration.append_config_values(options.netapp_basicauth_opts) diff --git a/cinder/tests/unit/test_netapp_nfs.py b/cinder/tests/unit/test_netapp_nfs.py index f49966135..148aee5af 100644 --- a/cinder/tests/unit/test_netapp_nfs.py +++ b/cinder/tests/unit/test_netapp_nfs.py @@ -22,11 +22,9 @@ import unittest from lxml import etree import mock from mox3 import mox as mox_lib -from oslo_log import log as logging import six from cinder import exception -from cinder.i18n import _LW from cinder.image import image_utils from cinder import test from cinder import utils as cinder_utils @@ -48,8 +46,6 @@ from cinder.volume.drivers.netapp import utils from oslo_config import cfg CONF = cfg.CONF -LOG = logging.getLogger(__name__) - CONNECTION_INFO = {'hostname': 'fake_host', 'transport_type': 'https', @@ -375,8 +371,6 @@ class NetAppCmodeNfsDriverTestCase(test.TestCase): if (share == 'testshare' and file_name == 'img-cache-id'): pass else: - LOG.warning(_LW("Share %(share)s and file name %(file_name)s") - % {'share': share, 'file_name': file_name}) self.fail('Return result is unexpected') def test_find_old_cache_files_notexists(self): diff --git a/cinder/tests/unit/test_nimble.py b/cinder/tests/unit/test_nimble.py index e229a6e20..4e3d02419 100644 --- a/cinder/tests/unit/test_nimble.py +++ b/cinder/tests/unit/test_nimble.py @@ -15,7 +15,6 @@ import mock from oslo_config import cfg -from oslo_log import log as logging from cinder import exception from cinder import test @@ -26,7 +25,6 @@ CONF = cfg.CONF NIMBLE_CLIENT = 'cinder.volume.drivers.nimble.client' NIMBLE_URLLIB2 = 'six.moves.urllib.request' NIMBLE_RANDOM = 'cinder.volume.drivers.nimble.random' -LOG = logging.getLogger(__name__) FAKE_ENUM_STRING = """ diff --git a/cinder/tests/unit/test_qos_specs.py b/cinder/tests/unit/test_qos_specs.py index 425cb3272..fb9f542f7 100644 --- a/cinder/tests/unit/test_qos_specs.py +++ b/cinder/tests/unit/test_qos_specs.py @@ -20,7 +20,6 @@ Unit Tests for qos specs internal API import time from oslo_db import exception as db_exc -from oslo_log import log as logging from cinder import context from cinder import db @@ -30,9 +29,6 @@ from cinder.volume import qos_specs from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - - def fake_db_qos_specs_create(context, values): if values['name'] == 'DupQoSName': raise exception.QoSSpecsExists(specs_id=values['name']) diff --git a/cinder/tests/unit/test_rbd.py b/cinder/tests/unit/test_rbd.py index f146ae393..a3205ed4a 100644 --- a/cinder/tests/unit/test_rbd.py +++ b/cinder/tests/unit/test_rbd.py @@ -21,7 +21,6 @@ import os import tempfile import mock -from oslo_log import log as logging from oslo_utils import timeutils from oslo_utils import units @@ -37,9 +36,6 @@ import cinder.volume.drivers.rbd as driver from cinder.volume.flows.manager import create_volume -LOG = logging.getLogger(__name__) - - # This is used to collect raised exceptions so that tests may check what was # raised. # NOTE: this must be initialised in test setUp(). diff --git a/cinder/tests/unit/test_srb.py b/cinder/tests/unit/test_srb.py index c8e16cdc2..329b8a65a 100644 --- a/cinder/tests/unit/test_srb.py +++ b/cinder/tests/unit/test_srb.py @@ -18,7 +18,6 @@ Unit tests for the Scality Rest Block Volume Driver. import mock from oslo_concurrency import processutils -from oslo_log import log as logging from oslo_utils import units from cinder import context @@ -28,8 +27,6 @@ from cinder.tests.unit.brick import test_brick_lvm from cinder.volume import configuration as conf from cinder.volume.drivers import srb -LOG = logging.getLogger(__name__) - class SRBLvmTestCase(test_brick_lvm.BrickLvmTestCase): def setUp(self): diff --git a/cinder/tests/unit/test_storwize_svc.py b/cinder/tests/unit/test_storwize_svc.py index 3ee36ca1b..e063c9f45 100644 --- a/cinder/tests/unit/test_storwize_svc.py +++ b/cinder/tests/unit/test_storwize_svc.py @@ -24,8 +24,6 @@ import time import mock from oslo_concurrency import processutils -from oslo_log import log as logging -from oslo_utils import excutils from oslo_utils import importutils from oslo_utils import units @@ -42,8 +40,6 @@ from cinder.volume.drivers.ibm.storwize_svc import ssh from cinder.volume import qos_specs from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - class StorwizeSVCManagementSimulator(object): def __init__(self, pool_name): @@ -1681,19 +1677,8 @@ class StorwizeSVCFakeDriver(storwize_svc.StorwizeSVCDriver): self.fake_storage = fake def _run_ssh(self, cmd, check_exit_code=True, attempts=1): - try: - LOG.debug('Run CLI command: %s' % cmd) - utils.check_ssh_injection(cmd) - ret = self.fake_storage.execute_command(cmd, check_exit_code) - (stdout, stderr) = ret - LOG.debug('CLI output:\n stdout: %(stdout)s\n stderr: ' - '%(stderr)s' % {'stdout': stdout, 'stderr': stderr}) - - except processutils.ProcessExecutionError as e: - with excutils.save_and_reraise_exception(): - LOG.debug('CLI Exception output:\n stdout: %(out)s\n ' - 'stderr: %(err)s' % {'out': e.stdout, - 'err': e.stderr}) + utils.check_ssh_injection(cmd) + ret = self.fake_storage.execute_command(cmd, check_exit_code) return ret diff --git a/cinder/tests/unit/test_tintri.py b/cinder/tests/unit/test_tintri.py index 12bfd5863..2921d3bef 100644 --- a/cinder/tests/unit/test_tintri.py +++ b/cinder/tests/unit/test_tintri.py @@ -17,7 +17,6 @@ Volume driver test for Tintri storage. import mock -from oslo_log import log as logging from oslo_utils import units from cinder import context @@ -28,8 +27,6 @@ from cinder.tests.unit import fake_volume from cinder.volume.drivers.tintri import TClient from cinder.volume.drivers.tintri import TintriDriver -LOG = logging.getLogger(__name__) - class FakeImage(object): def __init__(self): diff --git a/cinder/tests/unit/test_volume_configuration.py b/cinder/tests/unit/test_volume_configuration.py index 377707077..733706e68 100644 --- a/cinder/tests/unit/test_volume_configuration.py +++ b/cinder/tests/unit/test_volume_configuration.py @@ -17,15 +17,11 @@ from oslo_config import cfg -from oslo_log import log as logging from cinder import test from cinder.volume import configuration -LOG = logging.getLogger(__name__) - - volume_opts = [ cfg.StrOpt('str_opt', default='STR_OPT'), cfg.BoolOpt('bool_opt', default=False) diff --git a/cinder/tests/unit/test_volume_transfer.py b/cinder/tests/unit/test_volume_transfer.py index cf45cb9ce..c31ce569f 100644 --- a/cinder/tests/unit/test_volume_transfer.py +++ b/cinder/tests/unit/test_volume_transfer.py @@ -14,9 +14,7 @@ import datetime - import mock -from oslo_log import log as logging from cinder import context from cinder import db @@ -26,9 +24,6 @@ from cinder.tests.unit import utils from cinder.transfer import api as transfer_api -LOG = logging.getLogger(__name__) - - class VolumeTransferTestCase(test.TestCase): """Test cases for volume transfer code.""" def setUp(self): diff --git a/cinder/tests/unit/test_volume_types.py b/cinder/tests/unit/test_volume_types.py index f6f5b6276..8ac815395 100644 --- a/cinder/tests/unit/test_volume_types.py +++ b/cinder/tests/unit/test_volume_types.py @@ -20,23 +20,18 @@ import datetime import time from oslo_config import cfg -from oslo_log import log as logging from cinder import context from cinder import db from cinder.db.sqlalchemy import api as db_api from cinder.db.sqlalchemy import models from cinder import exception -from cinder.i18n import _ from cinder import test from cinder.tests.unit import conf_fixture from cinder.volume import qos_specs from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - - class VolumeTypeTestCase(test.TestCase): """Test cases for volume type code.""" def setUp(self): @@ -63,9 +58,6 @@ class VolumeTypeTestCase(test.TestCase): new = volume_types.get_volume_type_by_name(self.ctxt, self.vol_type1_name) - LOG.info(_("Given data: %s"), self.vol_type1_specs) - LOG.info(_("Result data: %s"), new) - self.assertEqual(self.vol_type1_description, new['description']) for k, v in self.vol_type1_specs.items(): @@ -187,7 +179,6 @@ class VolumeTypeTestCase(test.TestCase): vol_types = volume_types.get_all_types( self.ctxt, search_opts={'extra_specs': {"key1": "val1"}}) - LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 1) self.assertIn("type1", vol_types.keys()) self.assertEqual(vol_types['type1']['extra_specs'], @@ -196,7 +187,6 @@ class VolumeTypeTestCase(test.TestCase): vol_types = volume_types.get_all_types( self.ctxt, search_opts={'extra_specs': {"key2": "val2"}}) - LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 2) self.assertIn("type1", vol_types.keys()) self.assertIn("type2", vol_types.keys()) @@ -204,7 +194,6 @@ class VolumeTypeTestCase(test.TestCase): vol_types = volume_types.get_all_types( self.ctxt, search_opts={'extra_specs': {"key3": "val3"}}) - LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 1) self.assertIn("type2", vol_types.keys()) @@ -223,7 +212,6 @@ class VolumeTypeTestCase(test.TestCase): self.ctxt, search_opts={'extra_specs': {"key1": "val1", "key3": "val3"}}) - LOG.info("vol_types: %s" % vol_types) self.assertEqual(len(vol_types), 2) self.assertIn("type1", vol_types.keys()) self.assertIn("type3", vol_types.keys()) diff --git a/cinder/tests/unit/test_volume_utils.py b/cinder/tests/unit/test_volume_utils.py index 604b5387b..1c66a51b1 100644 --- a/cinder/tests/unit/test_volume_utils.py +++ b/cinder/tests/unit/test_volume_utils.py @@ -21,7 +21,6 @@ import mock from oslo_concurrency import processutils from oslo_config import cfg -from oslo_log import log as logging from cinder import exception from cinder import test @@ -30,8 +29,6 @@ from cinder.volume import throttling from cinder.volume import utils as volume_utils -LOG = logging.getLogger(__name__) - CONF = cfg.CONF diff --git a/cinder/tests/unit/test_zfssa.py b/cinder/tests/unit/test_zfssa.py index a25f91a5e..9fcaf653f 100644 --- a/cinder/tests/unit/test_zfssa.py +++ b/cinder/tests/unit/test_zfssa.py @@ -18,7 +18,6 @@ Unit tests for Oracle's ZFSSA Cinder volume driver import json import mock -from oslo_log import log as logging from oslo_utils import units from cinder import test @@ -30,8 +29,6 @@ from cinder.volume.drivers.zfssa import zfssanfs from cinder.volume.drivers.zfssa import zfssarest as rest -LOG = logging.getLogger(__name__) - nfs_logbias = 'latency' nfs_compression = 'off' diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py index a8729be97..0c60fa12f 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/test_nfs_cmode.py @@ -18,7 +18,6 @@ Mock unit tests for the NetApp cmode nfs storage driver import mock from os_brick.remotefs import remotefs as remotefs_brick -from oslo_log import log as logging from oslo_service import loopingcall from oslo_utils import units @@ -37,9 +36,6 @@ from cinder.volume.drivers import nfs from cinder.volume import utils as volume_utils -LOG = logging.getLogger(__name__) - - class NetAppCmodeNfsDriverTestCase(test.TestCase): def setUp(self): super(NetAppCmodeNfsDriverTestCase, self).setUp() diff --git a/cinder/tests/unit/volume/drivers/test_datera.py b/cinder/tests/unit/volume/drivers/test_datera.py index 4f7901163..42cf9b3b6 100644 --- a/cinder/tests/unit/volume/drivers/test_datera.py +++ b/cinder/tests/unit/volume/drivers/test_datera.py @@ -14,7 +14,6 @@ # under the License. import mock -from oslo_log import log as logging from cinder import context from cinder import exception @@ -23,9 +22,6 @@ from cinder.volume import configuration as conf from cinder.volume.drivers import datera -LOG = logging.getLogger(__name__) - - class DateraVolumeTestCase(test.TestCase): def setUp(self): super(DateraVolumeTestCase, self).setUp() diff --git a/cinder/tests/unit/volume/drivers/test_hgst.py b/cinder/tests/unit/volume/drivers/test_hgst.py index 51a8345c2..d968ef4bb 100644 --- a/cinder/tests/unit/volume/drivers/test_hgst.py +++ b/cinder/tests/unit/volume/drivers/test_hgst.py @@ -17,7 +17,6 @@ import mock from oslo_concurrency import processutils -from oslo_log import log as logging from cinder import context from cinder import exception @@ -27,9 +26,6 @@ from cinder.volume.drivers.hgst import HGSTDriver from cinder.volume import volume_types -LOG = logging.getLogger(__name__) - - class HGSTTestCase(test.TestCase): # Need to mock these since we use them on driver creation diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py index 3b20bd11a..4372c358e 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_san_lookup_service.py @@ -21,7 +21,6 @@ import mock from oslo_config import cfg -from oslo_log import log as logging import paramiko from cinder import exception @@ -31,7 +30,6 @@ import cinder.zonemanager.drivers.brocade.brcd_fc_san_lookup_service \ as brcd_lookup from cinder.zonemanager.drivers.brocade import fc_zone_constants -LOG = logging.getLogger(__name__) nsshow = '20:1a:00:05:1e:e8:e3:29' switch_data = [' N 011a00;2,3;20:1a:00:05:1e:e8:e3:29;\ diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py index 46e67eb0e..e1f9462c7 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_client_cli.py @@ -21,7 +21,6 @@ import mock from oslo_concurrency import processutils -from oslo_log import log as logging from cinder import exception from cinder import test @@ -29,7 +28,6 @@ from cinder.zonemanager.drivers.brocade \ import brcd_fc_zone_client_cli as client_cli import cinder.zonemanager.drivers.brocade.fc_zone_constants as ZoneConstant -LOG = logging.getLogger(__name__) nsshow = '20:1a:00:05:1e:e8:e3:29' switch_data = [' N 011a00;2,3;20:1a:00:05:1e:e8:e3:29;\ diff --git a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py index fa6c8da38..460b4b595 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py +++ b/cinder/tests/unit/zonemanager/test_brcd_fc_zone_driver.py @@ -21,18 +21,14 @@ import mock from oslo_config import cfg -from oslo_log import log as logging from oslo_utils import importutils import paramiko from cinder import exception -from cinder.i18n import _LI from cinder import test from cinder.volume import configuration as conf from cinder.zonemanager.drivers.brocade import brcd_fc_zone_driver as driver -LOG = logging.getLogger(__name__) - _active_cfg_before_add = {} _active_cfg_before_delete = { 'zones': { @@ -123,10 +119,6 @@ class TestBrcdFcZoneDriver(BrcdFcZoneDriverBaseTest, test.TestCase): """Normal flow for i-t mode.""" GlobalVars._is_normal_test = True GlobalVars._zone_state = [] - LOG.info(_LI("In Add GlobalVars._is_normal_test: " - "%s"), GlobalVars._is_normal_test) - LOG.info(_LI("In Add GlobalVars._zone_state:" - " %s"), GlobalVars._zone_state) get_active_zs_mock.return_value = _active_cfg_before_add self.driver.add_connection('BRCD_FAB_1', _initiator_target_map) self.assertTrue(_zone_name in GlobalVars._zone_state) @@ -180,14 +172,11 @@ class TestBrcdFcZoneDriver(BrcdFcZoneDriverBaseTest, test.TestCase): class FakeBrcdFCZoneClientCLI(object): def __init__(self, ipaddress, username, password, port): - LOG.info(_LI("User: %s"), username) - LOG.info(_LI("_zone_state: %s"), GlobalVars._zone_state) self.firmware_supported = True if not GlobalVars._is_normal_test: raise paramiko.SSHException("Unable to connect to fabric") def get_active_zone_set(self): - LOG.debug("Inside get_active_zone_set %s", GlobalVars._active_cfg) return GlobalVars._active_cfg def add_zones(self, zones, isActivate, active_zone_set): diff --git a/cinder/tests/unit/zonemanager/test_brcd_lookup_service.py b/cinder/tests/unit/zonemanager/test_brcd_lookup_service.py index 34d080c01..17f860ebe 100644 --- a/cinder/tests/unit/zonemanager/test_brcd_lookup_service.py +++ b/cinder/tests/unit/zonemanager/test_brcd_lookup_service.py @@ -19,15 +19,11 @@ """Unit tests for fc san lookup service.""" -from oslo_log import log as logging - from cinder import exception from cinder import test from cinder.volume import configuration as conf from cinder.zonemanager import fc_san_lookup_service as san_service -LOG = logging.getLogger(__name__) - _target_ns_map = {'100000051e55a100': ['20240002ac000a50']} _initiator_ns_map = {'100000051e55a100': ['10008c7cff523b01']} _device_map_to_verify = {