Exemplo n.º 1
0
class VolumesDatasets(BaseDataset):
    """Collection of dataset generators for blockstorage data driven tests"""
    volumes = VolumesAutoComposite()

    @classmethod
    @memoized
    def _volume_types(cls):
        """Get volume type list"""
        try:
            return cls.volumes.behaviors.get_volume_types()
        except:
            raise DatasetGeneratorError(
                "Unable to retrieve list of volume types during "
                "data-driven-test setup.")

    @classmethod
    @memoized
    def volume_types(
            cls, max_datasets=None, randomize=False, volume_type_filter=None):
        """Returns a DatasetList of Volume Type names and id's"""

        volume_type_list = cls._filter_model_list(
            cls._volume_types(), volume_type_filter)
        dataset_list = DatasetList()
        for vol_type in volume_type_list:
            data = {'volume_type_name': vol_type.name,
                    'volume_type_id': vol_type.id_}
            dataset_list.append_new_dataset(vol_type.name, data)
        return dataset_list
    def setUpClass(cls):
        """
        Perform actions that setup the necessary resources for testing

        The following resources are accessed from a parent class:
            - An instance from LiveMigratationServerTests

        The following resources are created during this setup:
            - A volume with the minimum volume size and the volume
              type from the test configuration
            - An attachment between the create volume and the instance
              from the parent class
        """
        super(LiveMigratateServerWithVolumeTests, cls).setUpClass()
        cls.volumes = VolumesAutoComposite()

        # Create a volume
        cls.device = '/dev/xvdm'
        cls.volume = cls.volumes.behaviors.create_available_volume(
            cls.volumes.config.min_volume_size,
            cls.volumes.config.default_volume_type, rand_name('volume'))
        cls.resources.add(cls.volume.id_, cls.volumes.client.delete_volume)

        # Attach the volume to the server
        cls.volume_attachments_client.attach_volume(cls.server.id,
                                                    cls.volume.id_,
                                                    device=cls.device)
        cls.volumes.behaviors.wait_for_volume_status(
            cls.volume.id_, statuses.Volume.IN_USE,
            cls.volumes.config.volume_create_max_timeout)
        cls.resources.add(cls.server.id, cls.servers_client.delete_server)
Exemplo n.º 3
0
 def __init__(self):
     super(ComputeIntegrationComposite, self).__init__()
     self.volumes = VolumesAutoComposite()
     self.volume_attachments.behaviors = \
         self.volume_attachments.behavior_class(
             self.volume_attachments.client,
             self.volume_attachments.config,
             self.volumes.client)
Exemplo n.º 4
0
    def setUpClass(cls):
        """
        Perform actions that setup the necessary resources for testing

        Presents an instance of the
        :class:`cloudcafe.blockstorage.composites.VolumesAutoComposite` class.
        """

        super(VolumesTestFixture, cls).setUpClass()
        cls.volumes = VolumesAutoComposite()
Exemplo n.º 5
0
 def setUpClass(cls):
     super(NovaCLI_IntegrationFixture, cls).setUpClass()
     cls.nova = NovaCLI_Composite()
     cls.compute = ComputeComposite()
     cls.volumes = VolumesAutoComposite()
     cls.compute.volume_attachments.behaviors = \
         cls.compute.volume_attachments.behavior_class(
             cls.compute.volume_attachments.client,
             cls.compute.volume_attachments.config,
             cls.volumes.client)
Exemplo n.º 6
0
    def __init__(self,
                 compute_auth_composite=None,
                 blockstorage_auth_composite=None):

        super(ComputeIntegrationComposite,
              self).__init__(auth_composite=compute_auth_composite)

        self.volumes = VolumesAutoComposite(
            auth_composite=blockstorage_auth_composite)

        self.volume_attachments.behaviors = \
            self.volume_attachments.behavior_class(
                self.volume_attachments.client,
                self.volume_attachments.config,
                self.volumes.client)
Exemplo n.º 7
0
    def __init__(self):
        self.servers = ServersComposite()
        self.flavors = FlavorsComposite()
        self.images = ImagesComposite()
        self.volumes = VolumesAutoComposite()
        self.volume_attachments = VolumeAttachmentsComposite()

        self.servers.behaviors = self.servers.behavior_class(
            self.servers.client, self.servers.config, self.images.config,
            self.flavors.config)

        self.images.behaviors = self.images.behavior_class(
            self.images.client, self.servers.client, self.images.config)

        self.volume_attachments.behaviors = \
            self.volume_attachments.behavior_class(
                self.volume_attachments.client, self.volume_attachments.config,
                self.volumes.client)
Exemplo n.º 8
0
    def setUpClass(cls):
        super(LiveMigratateServerWithVolumeTests, cls).setUpClass()
        cls.volumes = VolumesAutoComposite()

        # Create a volume
        cls.device = '/dev/xvdm'
        cls.volume = cls.volumes.behaviors.create_available_volume(
            cls.volumes.config.min_volume_size,
            cls.volumes.config.default_volume_type, rand_name('volume'))
        cls.resources.add(cls.volume.id_, cls.volumes.client.delete_volume)

        # Attach the volume to the server
        cls.volume_attachments_client.attach_volume(cls.server.id,
                                                    cls.volume.id_,
                                                    device=cls.device)
        cls.volumes.behaviors.wait_for_volume_status(
            cls.volume.id_, statuses.Volume.IN_USE,
            cls.volumes.config.volume_create_max_timeout)
        cls.resources.add(cls.server.id, cls.servers_client.delete_server)
Exemplo n.º 9
0
 def setUpClass(cls):
     super(VolumesTestFixture, cls).setUpClass()
     cls.volumes = VolumesAutoComposite()
Exemplo n.º 10
0
class BlockstorageDatasets(ModelBasedDatasetToolkit):
    """Collection of dataset generators for blockstorage data driven tests"""
    _volumes = VolumesAutoComposite()

    @classmethod
    @memoized
    def _get_volume_types(cls):
        """Gets list of all Volume Types in the environment, and caches it for
        future calls"""
        return cls._get_model_list(cls._volumes.client.list_all_volume_types,
                                   'volume_types')

    @classmethod
    def _get_volume_type_names(cls):
        """Gets list of all Volume Type Names in the environment, and caches it
        for future calls"""
        vtype_names = []
        for vtype in cls._get_volume_types():
            vtype_names.append(vtype.name)
        return vtype_names

    @classmethod
    def default_volume_type_model(cls):
        for vtype in cls._get_volume_types():
            if (vtype.id_ == cls._volumes.config.default_volume_type
                    or vtype.name == cls._volumes.config.default_volume_type):
                return vtype

        raise Exception("Unable to get configured default volume type")

    @classmethod
    def default_volume_type(cls):
        vol_type = cls.default_volume_type_model()
        dataset = _Dataset(name=vol_type.name,
                           data_dict={
                               'volume_type_name': vol_type.name,
                               'volume_type_id': vol_type.id_
                           })
        dataset_list = DatasetList()
        dataset_list.append(dataset)
        return dataset_list

    @classmethod
    def volume_types(cls,
                     max_datasets=None,
                     randomize=None,
                     model_filter=None,
                     filter_mode=ModelBasedDatasetToolkit.INCLUSION_MODE,
                     tags=None):
        """Returns a DatasetList of all VolumeTypes
        Filters should be dictionaries with model attributes as keys and
        lists of attributes as key values
        """

        volume_type_list = cls._get_volume_types()
        volume_type_list = cls._filter_model_list(volume_type_list,
                                                  model_filter=model_filter,
                                                  filter_mode=filter_mode)

        dataset_list = DatasetList()
        for vol_type in volume_type_list:
            data = {
                'volume_type_name': vol_type.name,
                'volume_type_id': vol_type.id_
            }
            dataset_list.append_new_dataset(vol_type.name, data)

        # Apply modifiers
        dataset_list = cls._modify_dataset_list(dataset_list,
                                                max_datasets=max_datasets,
                                                randomize=randomize)

        # Apply Tags
        if tags:
            dataset_list.apply_test_tags(*tags)

        return dataset_list

    @classmethod
    def configured_volume_types(cls,
                                max_datasets=None,
                                randomize=False,
                                tags=None):
        """Returns a DatasetList of permuations of Volume Types and Images.
        Requests all available images and volume types from API, and applies
        pre-configured image and volume_type filters.
        """

        volume_type_filter = cls._volumes.config.volume_type_filter
        volume_type_filter_mode = cls._volumes.config.volume_type_filter_mode
        return cls.volume_types(max_datasets=max_datasets,
                                randomize=randomize,
                                model_filter=volume_type_filter,
                                filter_mode=volume_type_filter_mode,
                                tags=tags)
Exemplo n.º 11
0
 def setUpClass(cls):
     super(CinderCLI_IntegrationFixture, cls).setUpClass()
     cls.cinder = CinderCLI_Composite()
     cls.volumes = VolumesAutoComposite()