from xml.dom import minidom
import mock
-from oslo_log import log as logging
from oslo_utils import timeutils
import webob
import cinder.volume
-LOG = logging.getLogger(__name__)
-
-
class BackupsAPITestCase(test.TestCase):
"""Test Case for backups API."""
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'
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'])
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)
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'])
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 '
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 '
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
from cinder import test
from cinder import utils
-LOG = logging.getLogger(__name__)
-
CONF = cfg.CONF
FAKE_BACKUP_ENABLE_PROGRESS_TIMER = True
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.
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.
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.
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.
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.
# 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):
# 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):
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):
@classmethod
def Connection(self, *args, **kargs):
- LOG.debug("fake FakeSwiftClient Connection")
return FakeSwiftConnection()
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)
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'},
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:
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
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)
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 = []
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
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
import mock
from oslo_config import cfg
-from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import timeutils
CONF = cfg.CONF
-LOG = logging.getLogger(__name__)
-
class FakeBackupException(Exception):
pass
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
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().
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
from cinder.tests.unit.backup import fake_swift_client2
-LOG = logging.getLogger(__name__)
-
CONF = cfg.CONF
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.
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.
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.
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.
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.
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
from cinder import test
from cinder import utils
-LOG = logging.getLogger(__name__)
SIM = None
VOLUME_PATH = '/dev/null'