Add check for volume backup_driver, remove unneeded code
This commit is contained in:
@@ -15,17 +15,7 @@
|
||||
"""Code for configuring cinder-backup-swift."""
|
||||
|
||||
import zaza.model as zaza_model
|
||||
import time
|
||||
|
||||
|
||||
def basic_setup():
|
||||
"""Run setup for testing cinder-backup-swift.
|
||||
|
||||
Cinder backup setup for testing cinder-backup is currently part of
|
||||
cinder-backup functional tests.
|
||||
Volume backup setup for other tests to use should go here.
|
||||
"""
|
||||
|
||||
import zaza.openstack.charm_tests.test_utils
|
||||
|
||||
def configure_cinder_backup():
|
||||
"""Configure cinder-backup-swift."""
|
||||
@@ -48,4 +38,8 @@ def configure_cinder_backup():
|
||||
juju_service = 'cinder-backup-swift'
|
||||
zaza_model.set_application_config(juju_service, cinder_backup_swift_conf)
|
||||
zaza_model.wait_for_application_states()
|
||||
time.sleep(300)
|
||||
_singleton = zaza.openstack.charm_tests.test_utils.OpenStackBaseTest()
|
||||
_singleton.setUpClass()
|
||||
with _singleton.config_change(cinder_backup_swift_conf, cinder_backup_swift_conf):
|
||||
# wait for configuration to be applied then return
|
||||
pass
|
||||
|
||||
@@ -33,7 +33,7 @@ class CinderBackupSwiftTest(test_utils.OpenStackBaseTest):
|
||||
cls.keystone_session)
|
||||
|
||||
def test_cinder_volume_backup_create_delete(self):
|
||||
"""Create an volume backup and then delete it."""
|
||||
"""Create volume backup and then delete it."""
|
||||
# Create volume
|
||||
logging.info('Creating volume')
|
||||
size = 1
|
||||
@@ -45,6 +45,14 @@ class CinderBackupSwiftTest(test_utils.OpenStackBaseTest):
|
||||
volume_backup = openstack_utils.create_volume_backup(
|
||||
self.cinder_client,
|
||||
volume.id)
|
||||
record = openstack_utils.get_volume_backup_metadata(
|
||||
self.cinder_client,
|
||||
volume_backup.id
|
||||
)
|
||||
|
||||
#Check if backup was created via Swift
|
||||
assert record['backup_service'] == 'cinder.backup.drivers.swift.SwiftBackupDriver'
|
||||
|
||||
# Delete volume backup
|
||||
logging.info('Deleting volume backup')
|
||||
openstack_utils.delete_volume_backup(
|
||||
|
||||
@@ -1690,8 +1690,6 @@ def delete_image(glance, img_id):
|
||||
delete_resource(glance.images, img_id, msg="glance image")
|
||||
|
||||
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=60),
|
||||
reraise=True, stop=tenacity.stop_after_attempt(5))
|
||||
def delete_volume(cinder, vol_id):
|
||||
"""Delete the given volume from cinder.
|
||||
:param cinder: Authenticated cinderclient
|
||||
@@ -1702,8 +1700,6 @@ def delete_volume(cinder, vol_id):
|
||||
delete_resource(cinder.volumes, vol_id, msg="deleting cinder volume")
|
||||
|
||||
|
||||
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=60),
|
||||
reraise=True, stop=tenacity.stop_after_attempt(5))
|
||||
def delete_volume_backup(cinder, vol_backup_id):
|
||||
"""Delete the given volume from cinder.
|
||||
:param cinder: Authenticated cinderclient
|
||||
@@ -1807,8 +1803,6 @@ def create_volume(cinder, size, name=None, image=None):
|
||||
:rtype: cinderclient.common.utils.RequestIdProxy
|
||||
"""
|
||||
logging.debug('Creating volume')
|
||||
if not size:
|
||||
raise Exception("Size for volume not specified")
|
||||
# Create volume
|
||||
volume = cinder.volumes.create(
|
||||
size=size,
|
||||
@@ -1835,8 +1829,6 @@ def create_volume_backup(cinder, volume_id, name=None):
|
||||
:rtype: cinderclient.common.utils.RequestIdProxy
|
||||
"""
|
||||
logging.debug('Creating volume backup')
|
||||
if not volume_id:
|
||||
raise Exception("volume_id not specified")
|
||||
# Create volume backup
|
||||
volume_backup = cinder.backups.create(
|
||||
volume_id,
|
||||
@@ -1850,6 +1842,20 @@ def create_volume_backup(cinder, volume_id, name=None):
|
||||
return volume_backup
|
||||
|
||||
|
||||
def get_volume_backup_metadata(cinder, backup_id):
|
||||
"""Get cinder volume backup record
|
||||
:param cinder: Authenticated cinderclient
|
||||
:type cinder: cinder.Client
|
||||
:param backup_id: the source backup id
|
||||
"""
|
||||
logging.debug('Request volume backup record')
|
||||
# Request volume backup record
|
||||
volume_backup_record = cinder.backups.export_record(
|
||||
backup_id)
|
||||
|
||||
return volume_backup_record
|
||||
|
||||
|
||||
def create_ssh_key(nova_client, keypair_name, replace=False):
|
||||
"""Create ssh key.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user