From 406959ad1c0e69e03df521ac3712c66fdbf61873 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 22 Nov 2017 08:50:51 -0600 Subject: [PATCH] Update unity tests to use our test base Deprecation warnings were being emitted due to use of assertRaisesRegex, even though a py2/3 wrapper was created in I3cf8e29184a68a07d35fb121c816e40b89df393e. This was due to the Unity tests inheriting from unittest.TestCase instead of our own base TestCase. Switched test cases over to use cinder.test.TestCase gets rid of the deprecation warning for assertRaisesRegex. Our base test installs a logging fixture to make sure log messages are OK. This uncovered that the driver code was trying to pass an object in as if it were a dict of formatting values, resulting in an error. This patch fixes this my creating a dict of the needed values to pass in so the tests will pass under the new inheritance. Change-Id: I2a6643ab4827dae244212c90c73402ff6d61cf76 --- .../volume/drivers/dell_emc/unity/test_adapter.py | 11 +++++++---- cinder/volume/drivers/dell_emc/unity/adapter.py | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py index e353c2cad0d..b97388d5dd1 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/unity/test_adapter.py @@ -15,12 +15,12 @@ import contextlib import functools -import unittest import mock from oslo_utils import units from cinder import exception +from cinder import test from cinder.tests.unit.volume.drivers.dell_emc.unity \ import fake_exception as ex from cinder.tests.unit.volume.drivers.dell_emc.unity import test_client @@ -329,8 +329,9 @@ class IdMatcher(object): ######################## @mock.patch.object(adapter, 'storops_ex', new=ex) -class CommonAdapterTest(unittest.TestCase): +class CommonAdapterTest(test.TestCase): def setUp(self): + super(CommonAdapterTest, self).setUp() self.adapter = mock_adapter(adapter.CommonAdapter) def test_get_managed_pools(self): @@ -686,8 +687,9 @@ class CommonAdapterTest(unittest.TestCase): self.adapter.normalize_config(config) -class FCAdapterTest(unittest.TestCase): +class FCAdapterTest(test.TestCase): def setUp(self): + super(FCAdapterTest, self).setUp() self.adapter = mock_adapter(adapter.FCAdapter) def test_setup(self): @@ -799,8 +801,9 @@ class FCAdapterTest(unittest.TestCase): self.adapter.validate_ports(['spa_iom*', 'spc_invalid']) -class ISCSIAdapterTest(unittest.TestCase): +class ISCSIAdapterTest(test.TestCase): def setUp(self): + super(ISCSIAdapterTest, self).setUp() self.adapter = mock_adapter(adapter.ISCSIAdapter) def test_iscsi_protocol(self): diff --git a/cinder/volume/drivers/dell_emc/unity/adapter.py b/cinder/volume/drivers/dell_emc/unity/adapter.py index aa8d1e105a7..953e677fc53 100644 --- a/cinder/volume/drivers/dell_emc/unity/adapter.py +++ b/cinder/volume/drivers/dell_emc/unity/adapter.py @@ -264,10 +264,16 @@ class CommonAdapter(object): :param volume: volume information """ params = VolumeParams(self, volume) + log_params = { + 'name': params.name, + 'size': params.size, + 'description': params.description, + 'pool': params.pool, + 'io_limit_policy': params.io_limit_policy} LOG.info('Create Volume: %(name)s, size: %(size)s, description: ' '%(description)s, pool: %(pool)s, io limit policy: ' - '%(io_limit_policy)s.', params) + '%(io_limit_policy)s.', log_params) return self.makeup_model( self.client.create_lun(name=params.name,