Remove oslo logging from backup unit tests

Many of the unit tests for backup services import oslo_log and
invoke LOG.debug, LOG.info, etc.  There appears to be no current
reason to do this and, more generally, unit tests for everything
but oslo_log itself should not be doing logging themselves.

This commit removes oslo logging from the backup unit tests.
Closes-bug: 1464772

Change-Id: I2c9f258a43a155e785bac4158cb5e5e0ecfcc797
This commit is contained in:
Tom Barron 2015-06-11 13:07:07 -04:00
parent 82a2b66a90
commit 39207fa601
10 changed files with 4 additions and 75 deletions

View File

@ -21,7 +21,6 @@ import json
from xml.dom import minidom
import mock
from oslo_log import log as logging
from oslo_utils import timeutils
import webob
@ -38,9 +37,6 @@ from cinder.tests.unit import utils
import cinder.volume
LOG = logging.getLogger(__name__)
class BackupsAPITestCase(test.TestCase):
"""Test Case for backups API."""
@ -90,7 +86,6 @@ class BackupsAPITestCase(test.TestCase):
volume_id = utils.create_volume(self.context, size=5,
status='creating')['id']
backup_id = self._create_backup(volume_id)
LOG.debug('Created backup with id %s' % backup_id)
req = webob.Request.blank('/v2/fake/backups/%s' %
backup_id)
req.method = 'GET'
@ -404,7 +399,6 @@ class BackupsAPITestCase(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['backup'])
@ -435,7 +429,6 @@ class BackupsAPITestCase(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['backup'])
self.assertTrue(_mock_service_get_all_by_topic.called)
@ -490,7 +483,6 @@ class BackupsAPITestCase(test.TestCase):
req.body = json.dumps(body)
res = req.get_response(fakes.wsgi_app())
res_dict = json.loads(res.body)
LOG.info(res_dict)
self.assertEqual(202, res.status_int)
self.assertIn('id', res_dict['backup'])
@ -523,7 +515,6 @@ class BackupsAPITestCase(test.TestCase):
req.body = json.dumps(body)
res = req.get_response(fakes.wsgi_app())
res_dict = json.loads(res.body)
LOG.info(res_dict)
self.assertEqual(400, res_dict['badRequest']['code'])
self.assertEqual('Invalid backup: The parent backup must be '
@ -686,7 +677,6 @@ class BackupsAPITestCase(test.TestCase):
req.body = json.dumps(body)
res = req.get_response(fakes.wsgi_app())
res_dict = json.loads(res.body)
LOG.info(res_dict)
self.assertEqual(400, res_dict['badRequest']['code'])
self.assertEqual('Invalid backup: No backups available to do '

View File

@ -28,7 +28,6 @@ import zlib
import mock
from os_brick.remotefs import remotefs as remotefs_brick
from oslo_config import cfg
from oslo_log import log as logging
from six.moves import builtins
from cinder.backup.drivers import nfs
@ -40,8 +39,6 @@ from cinder import objects
from cinder import test
from cinder import utils
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
FAKE_BACKUP_ENABLE_PROGRESS_TIMER = True
@ -390,7 +387,6 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -420,7 +416,6 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -463,7 +458,6 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -513,7 +507,6 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -666,7 +659,6 @@ class BackupNFSSwiftBasedTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.

View File

@ -13,12 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from cinder.backup import driver
LOG = logging.getLogger(__name__)
class FakeBackupService(driver.BackupDriver):
def __init__(self, context, db_driver=None):

View File

@ -13,13 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_log import log as logging
from cinder.backup import driver
from cinder.tests.unit.backup import fake_service
LOG = logging.getLogger(__name__)
class FakeBackupServiceWithVerify(driver.BackupDriverWithVerify,
fake_service.FakeBackupService):

View File

@ -18,12 +18,10 @@ import os
import socket
import zlib
from oslo_log import log as logging
import six
from six.moves import http_client
from swiftclient import client as swift
LOG = logging.getLogger(__name__)
from swiftclient import client as swift
class FakeSwiftClient(object):
@ -33,7 +31,6 @@ class FakeSwiftClient(object):
@classmethod
def Connection(self, *args, **kargs):
LOG.debug("fake FakeSwiftClient Connection")
return FakeSwiftConnection()
@ -43,7 +40,6 @@ class FakeSwiftConnection(object):
pass
def head_container(self, container):
LOG.debug("fake head_container(%s)" % container)
if container == 'missing_container':
raise swift.ClientException('fake exception',
http_status=http_client.NOT_FOUND)
@ -55,11 +51,9 @@ class FakeSwiftConnection(object):
pass
def put_container(self, container):
LOG.debug("fake put_container(%s)" % container)
pass
def get_container(self, container, **kwargs):
LOG.debug("fake get_container(%s)" % container)
fake_header = None
fake_body = [{'name': 'backup_001'},
{'name': 'backup_002'},
@ -67,11 +61,9 @@ class FakeSwiftConnection(object):
return fake_header, fake_body
def head_object(self, container, name):
LOG.debug("fake put_container(%s, %s)" % (container, name))
return {'etag': 'fake-md5-sum'}
def get_object(self, container, name):
LOG.debug("fake get_object(%s, %s)" % (container, name))
if container == 'socket_error_on_get':
raise socket.error(111, 'ECONNREFUSED')
if 'metadata' in name:
@ -107,13 +99,11 @@ class FakeSwiftConnection(object):
def put_object(self, container, name, reader, content_length=None,
etag=None, chunk_size=None, content_type=None,
headers=None, query_string=None):
LOG.debug("fake put_object(%s, %s)" % (container, name))
if container == 'socket_error_on_put':
raise socket.error(111, 'ECONNREFUSED')
return 'fake-md5-sum'
def delete_object(self, container, name):
LOG.debug("fake delete_object(%s, %s)" % (container, name))
if container == 'socket_error_on_delete':
raise socket.error(111, 'ECONNREFUSED')
pass

View File

@ -19,33 +19,27 @@ import os
import socket
import tempfile
from oslo_log import log as logging
from six.moves import http_client
from swiftclient import client as swift
from cinder.openstack.common import fileutils
LOG = logging.getLogger(__name__)
class FakeSwiftClient2(object):
"""Logs calls instead of executing."""
def __init__(self, *args, **kwargs):
pass
@classmethod
def Connection(self, *args, **kargs):
LOG.debug("fake FakeSwiftClient Connection")
return FakeSwiftConnection2()
class FakeSwiftConnection2(object):
"""Logging calls instead of executing."""
def __init__(self, *args, **kwargs):
self.tempdir = tempfile.mkdtemp()
def head_container(self, container):
LOG.debug("fake head_container(%s)", container)
if container == 'missing_container':
raise swift.ClientException('fake exception',
http_status=http_client.NOT_FOUND)
@ -56,11 +50,9 @@ class FakeSwiftConnection2(object):
raise socket.error(111, 'ECONNREFUSED')
def put_container(self, container):
LOG.debug("fake put_container(%s)", container)
pass
def get_container(self, container, **kwargs):
LOG.debug("fake get_container %(container)s.",
{'container': container})
fake_header = None
container_dir = tempfile.gettempdir() + '/' + container
fake_body = []
@ -74,15 +66,9 @@ class FakeSwiftConnection2(object):
return fake_header, fake_body
def head_object(self, container, name):
LOG.debug("fake head_object %(container)s, %(name)s.",
{'container': container,
'name': name})
return {'etag': 'fake-md5-sum'}
def get_object(self, container, name):
LOG.debug("fake get_object %(container)s, %(name)s.",
{'container': container,
'name': name})
if container == 'socket_error_on_get':
raise socket.error(111, 'ECONNREFUSED')
object_path = tempfile.gettempdir() + '/' + container + '/' + name
@ -92,15 +78,10 @@ class FakeSwiftConnection2(object):
def put_object(self, container, name, reader, content_length=None,
etag=None, chunk_size=None, content_type=None,
headers=None, query_string=None):
LOG.debug("fake put_object %(container)s, %(name)s.",
{'container': container,
'name': name})
object_path = tempfile.gettempdir() + '/' + container + '/' + name
with fileutils.file_open(object_path, 'wb') as object_file:
object_file.write(reader.read())
return hashlib.md5(reader.read()).hexdigest()
def delete_object(self, container, name):
LOG.debug("fake delete_object %(container)s, %(name)s.",
{'container': container,
'name': name})
pass

View File

@ -21,7 +21,6 @@ import tempfile
import mock
from oslo_config import cfg
from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import timeutils
@ -36,8 +35,6 @@ from cinder.tests.unit.backup import fake_service_with_verify as fake_service
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
class FakeBackupException(Exception):
pass

View File

@ -21,7 +21,6 @@ import uuid
import mock
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_serialization import jsonutils
import six
from six.moves import range
@ -36,8 +35,6 @@ from cinder import objects
from cinder import test
from cinder.volume.drivers import rbd as rbddriver
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().

View File

@ -27,7 +27,6 @@ import zlib
import mock
from oslo_config import cfg
from oslo_log import log as logging
from swiftclient import client as swift
from cinder.backup.drivers import swift as swift_dr
@ -41,8 +40,6 @@ from cinder.tests.unit.backup import fake_swift_client
from cinder.tests.unit.backup import fake_swift_client2
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
@ -219,7 +216,6 @@ class BackupSwiftTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -251,7 +247,6 @@ class BackupSwiftTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -297,7 +292,6 @@ class BackupSwiftTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -351,7 +345,6 @@ class BackupSwiftTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.
@ -478,7 +471,6 @@ class BackupSwiftTestCase(test.TestCase):
backup_name = '%s_backup_%s' % (az, backup['id'])
volume = 'volume_%s' % (backup['volume_id'])
prefix = volume + '_' + backup_name
LOG.debug('_generate_object_name_prefix: %s', prefix)
return prefix
# Raise a pseudo exception.BackupDriverException.

View File

@ -22,7 +22,6 @@ import os
import posix
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from oslo_utils import timeutils
from cinder.backup.drivers import tsm
@ -33,7 +32,6 @@ from cinder import objects
from cinder import test
from cinder import utils
LOG = logging.getLogger(__name__)
SIM = None
VOLUME_PATH = '/dev/null'