Example #1
0
class CreateVolumeFromImageTest(BaseVolumeTest):
    def __init__(self):
        try:
            self.volume = Base()
            self.image_client = Manager().image_client_v2
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, traceback: '
                    '%(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed

    def test_create_volume_from_image(self):
        try:
            image_name = CONF.compute.image_name
            params = {"name": image_name}
            images = self.image_client.list_images(params)
            volume_created = self.volume.\
                create_volume(imageRef=images[0].get('id'))
            status = self.volume._get_volume_status(volume_created['id'])
            if status != "available":
                raise exceptions.VolumeBuildErrorException()
        except Exception as e:
            LOG.warning(
                _LW('Create volume from image failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise e
        finally:
            self.volume.delete_all()
Example #2
0
    def test_create_volume_type(self):
        try:
            volume = Base()
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, '
                    'traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed

        try:
            volume_type_created = \
                volume.create_test_volume_type()
            LOG.debug(_LI("The new volume_type is %s"), volume_type_created)
        except Exception as e:
            LOG.warning(
                _LW('Create volume type failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise
        finally:
            volume.delete_all()
 def __init__(self):
     try:
         self.volume = Base()
     except Exception as e:
         LOG.warning(_LW('Init test env failed, msg: %(msg)s, traceback: '
                     '%(tb)s.'), {'msg': e, 'tb': traceback.format_exc()})
         raise exceptions.InitFailed
class CreateVolumeFromSnapshotTest(BaseVolumeTest):

    def __init__(self):
        try:
            self.volume = Base()
        except Exception as e:
            LOG.warning(_LW('Init test env failed, msg: %(msg)s, traceback: '
                        '%(tb)s.'), {'msg': e, 'tb': traceback.format_exc()})
            raise exceptions.InitFailed

    def test_create_volume_from_image(self):
        try:
            volume_created = \
                self.volume.create_volume()
        except Exception as e:
            LOG.warning(_LW('Create volume before snapshot failed, '
                            'msg: %(msg)s, traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            self.volume.delete_all()
            raise exceptions.VolumeBuildErrorException()

        try:
            kwargs = dict(force=True)
            snapshot = self.volume.create_snapshot(volume_created['id'],
                                                   **kwargs)
        except Exception as e:
            LOG.warning(_LE('create volume snapshot failed, msg: '
                            '%(msg)s, traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            self.volume.delete_all()
            raise exceptions.SnapshotBuildErrorException()

        try:
            volume_created = self.volume.\
                create_volume(snapshot_id=snapshot.get('id'))
            status = self.volume._get_volume_status(volume_created['id'])
            if status != "available":
                raise exceptions.VolumeBuildErrorException()
        except Exception as e:
            LOG.warning(_LW('Create volume from snapshot failed, '
                            'msg: %(msg)s, traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            raise e
        finally:
            self.volume.delete_all()
Example #5
0
    def test_create_qos_type(self):
        try:
            volume = Base()
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, '
                    'traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed

        try:
            qos_type_created = \
                volume.create_test_qos_specs(**self.__disk_qos_low)
        except Exception as e:
            LOG.warning(
                _LW('Create qos type for volume tests failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            volume.show_qos_type(qos_type_created['id'])
        except Exception as e:
            LOG.warning(
                _LE('show volume type failed, msg: '
                    '%(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise
        finally:
            volume.delete_all()
    def test_rename_volume(self):
        try:
            volume = Base()
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, '
                    'traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed

        try:
            volume_created = volume.create_volume()
        except Exception as e:
            LOG.warning(
                _LW('Create volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            params = {'name': 'newname'}
            volume.update_volume(volume_created['id'], **params)
        except Exception as e:
            LOG.warning(
                _LE('Update volume name failed, msg: '
                    '%(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise
        finally:
            volume.delete_all()
Example #7
0
class CreateVolumeFromImageTest(BaseVolumeTest):
    def __init__(self):
        try:
            self.volume = Base()
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, traceback: '
                    '%(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed

    def test_create_volume_from_image(self):
        try:
            volume_created = \
                self.volume.create_volume()
        except Exception as e:
            LOG.warning(
                _LW('Create volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.VolumeBuildErrorException()

        try:
            Manager().volumes_v2_client.delete_volume(volume_created.get("id"))
        except Exception as e:
            LOG.warning(
                _LW('Delete volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise e
# !/usr/bin/python
import traceback

from automation.common import exceptions
from automation import config
from automation.i18n import _LW
from oslo_log import log as logging
from testcases.volume_tests.base import Base

CONF = config.CONF
LOG = logging.getLogger(__name__)

if __name__ == '__main__':
    try:
        volume = Base()
    except Exception as e:
        LOG.warning(
            _LW('Init test env failed, msg: %(msg)s, traceback: '
                '%(tb)s.'), {
                    'msg': e,
                    'tb': traceback.format_exc()
                })
        raise exceptions.InitFailed
    try:
        volume_created = volume.create_volume()
        volume.extend_volume(volume_created['id'])
    except Exception as e:
        LOG.warning(
            _LW('Test create volume failed, msg: %(msg)s, traceback: '
                '%(tb)s.'), {
                    'msg': e,
# !/usr/bin/python
import traceback

from automation.common import exceptions
from automation import config
from automation.i18n import _LW
from oslo_log import log as logging
from testcases.volume_tests.base import Base

CONF = config.CONF
LOG = logging.getLogger(__name__)

if __name__ == '__main__':
    try:
        volume = Base()
    except Exception as e:
        LOG.warning(
            _LW('Init test env failed, msg: %(msg)s, traceback: '
                '%(tb)s.'), {
                    'msg': e,
                    'tb': traceback.format_exc()
                })
        raise exceptions.InitFailed
    try:
        volume_created = volume.create_volume()
    except Exception as e:
        LOG.warning(
            _LW('Test create volume failed, msg: %(msg)s, traceback: '
                '%(tb)s.'), {
                    'msg': e,
                    'tb': traceback.format_exc()
Example #10
0
# !/usr/bin/python
import traceback

from automation.common import exceptions
from automation import config
from automation.i18n import _LW
from oslo_log import log as logging
from testcases.compute_tests.base_compute import Base as BaseCompute
from testcases.volume_tests.base import Base as BaseVolume

CONF = config.CONF
LOG = logging.getLogger(__name__)

if __name__ == '__main__':
    try:
        volume = BaseVolume()
        server = BaseCompute()
    except Exception as e:
        LOG.warning(
            _LW('Init test env failed, msg: %(msg)s, traceback: '
                '%(tb)s.'), {
                    'msg': e,
                    'tb': traceback.format_exc()
                })
        raise exceptions.InitFailed
    try:
        server_created = server.create_server()
        volume_created = volume.create_volume()
        server.attach_volume(server_created['id'], volume_created['id'])
        volume.check_volume_status_interval(volume_created['id'], 'in-use')
        server.detach_volume(server_created['id'], volume_created['id'])
    def test_create_volume_snapshot(self):
        try:
            volume = Base()
        except Exception as e:
            LOG.warning(_LW('Init test env failed, msg: %(msg)s, '
                            'traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            raise exceptions.InitFailed

        try:
            volume_created = \
                volume.create_volume()
        except Exception as e:
            LOG.warning(_LW('Create volume before snapshot failed, '
                            'msg: %(msg)s, traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            volume.delete_all()
            raise exceptions.VolumeBuildErrorException()

        try:
            kwargs = dict(force=True)
            volume.create_snapshot(volume_created['id'], **kwargs)
        except Exception as e:
            LOG.warning(_LE('create volume snapshot failed, msg: '
                            '%(msg)s, traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            volume.delete_all()
            raise exceptions.SnapshotBuildErrorException()
        finally:
            volume.delete_all()
Example #12
0
    def test_create_volume_with_qos(self):
        try:
            volume = Base()
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, '
                    'traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed
        '''
        try:
            compute = compute_base()
        except Exception as e:
            LOG.warning(_LW('Init test env failed, msg: %(msg)s, '
                            'traceback: %(tb)s.'),
                        {'msg': e, 'tb': traceback.format_exc()})
            raise exceptions.ServerFault
        '''

        try:
            volume_type = volume.create_test_volume_type()
        except Exception as e:
            LOG.warning(
                _LW('Create volume_type before create volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise
            # raise exceptions.VolumeBuildErrorException()

        try:
            volumetype_randname, fixedname = volume_type['name'].split('-')
            LOG.info(_LI("Volume_type fixedname is %s"), fixedname)
            qos_name = volumetype_randname + '-Qos'
            qos_type = volume.create_test_qos_specs(qos_name,
                                                    **self.__disk_qos_low)
        except Exception as e:
            LOG.warning(
                _LW('Create qos_type before create volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            volume.associate_volumetype_with_qos(qos_type['id'],
                                                 volume_type['id'])
        except Exception as e:
            LOG.warning(
                _LW('Associate qos_type with volume_type failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            volume_name = str(uuid.uuid4())
            params = {'volume_type': volume_type['id'], 'name': volume_name}
            single_volume = volume.create_volume(**params)
            LOG.debug("current test volume is %s", single_volume)
            # volume.check_volume_status_interval(single_volume['id'],
            #                                    'available')
        except Exception as e:
            LOG.warning(
                _LW('Create volume before snapshot failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise
        finally:
            volume.delete_all()
        '''
Example #13
0
    def test_update_volume_qos(self):
        try:
            volume = Base()
        except Exception as e:
            LOG.warning(
                _LW('Init test env failed, msg: %(msg)s, '
                    'traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise exceptions.InitFailed

        try:
            low_volume_type = volume.create_test_volume_type(
                name=self.__low_io_volumetype_name)
            medium_volume_type = volume.create_test_volume_type(
                name=self.__medium_io_volumetype_name)
        except Exception as e:
            LOG.warning(
                _LW('Create volume_type before create volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            low_qos_name = self.__low_io_volumetype_name + '-Qos'
            low_qos_type = volume.create_test_qos_specs(name=low_qos_name,
                                                        **self.__disk_qos_low)
            medium_qos_name = self.__medium_io_volumetype_name + '-Qos'
            medium_qos_type = \
                volume.create_test_qos_specs(name=medium_qos_name,
                                             **self.__disk_qos_medium)

        except Exception as e:
            LOG.warning(
                _LW('Create qos_type before create volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            volume.associate_volumetype_with_qos(low_qos_type['id'],
                                                 low_volume_type['id'])
            volume.associate_volumetype_with_qos(medium_qos_type['id'],
                                                 medium_volume_type['id'])
        except Exception as e:
            LOG.warning(
                _LW('Associate qos_type with volume_type failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            volume_name = str(uuid.uuid4())
            params = {
                'volume_type': low_volume_type['id'],
                'name': volume_name
            }
            single_volume = \
                volume.create_volume(**params)
        except Exception as e:
            LOG.warning(
                _LW('Create volume before snapshot failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            volume.retype_volume(single_volume['id'], medium_volume_type['id'])
            volume.check_volume_status_interval(single_volume['id'],
                                                'available')
        except Exception as e:
            LOG.warning(
                _LW('Retype volume failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            volume.delete_all()
            raise

        try:
            retyped_volume = volume.show_volume(single_volume['id'])
            current_volume_type = retyped_volume['volume_type']
            if current_volume_type == medium_volume_type['name']:
                LOG.info("The volume has been retype successfully.")
            else:
                LOG.warning(_LW('Retype volume failed'))
                volume.delete_all()
        except Exception as e:
            LOG.warning(
                _LW('Retype volume result check failed, '
                    'msg: %(msg)s, traceback: %(tb)s.'), {
                        'msg': e,
                        'tb': traceback.format_exc()
                    })
            raise
        finally:
            volume.delete_all()