Moved blockstorage-specific tests to blockstorage
* Moved (blockstorage-specific) fixtures and tests to blockstorage project folder. Change-Id: I10dfdaad866a87cdf05a2218947d05de28620e1c
This commit is contained in:
parent
ba536ce40a
commit
6bdd03095f
|
@ -1,15 +0,0 @@
|
|||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
|
@ -1,73 +0,0 @@
|
|||
from cafe.drivers.unittest.fixtures import BaseTestFixture
|
||||
from cafe.drivers.unittest.datasets import DatasetList
|
||||
from cafe.drivers.unittest.decorators import memoized
|
||||
|
||||
from cloudcafe.common.tools.datagen import random_string
|
||||
from cloudcafe.openstackcli.cindercli.client import CinderCLI
|
||||
from cloudcafe.openstackcli.common.config import OpenstackCLI_CommonConfig
|
||||
from cloudcafe.openstackcli.cindercli.config import CinderCLI_Config
|
||||
from cloudcafe.openstackcli.cindercli.behaviors import CinderCLI_Behaviors
|
||||
|
||||
from cloudroast.blockstorage.volumes_api.v1.fixtures import VolumesComposite
|
||||
|
||||
|
||||
class CinderCLI_Composite(object):
|
||||
|
||||
def __init__(self):
|
||||
self.openstack_config = OpenstackCLI_CommonConfig()
|
||||
self.config = CinderCLI_Config()
|
||||
self._cinder_cli_kwargs = {
|
||||
'volume_service_name': self.config.volume_service_name,
|
||||
'os_volume_api_version': self.config.os_volume_api_version,
|
||||
'os_username': self.openstack_config.os_username,
|
||||
'os_password': self.openstack_config.os_password,
|
||||
'os_tenant_name': self.openstack_config.os_tenant_name,
|
||||
'os_auth_url': self.openstack_config.os_auth_url,
|
||||
'os_region_name': self.openstack_config.os_region_name,
|
||||
'os_cacert': self.openstack_config.os_cacert,
|
||||
'retries': self.openstack_config.retries,
|
||||
'debug': self.openstack_config.debug}
|
||||
self.client = CinderCLI(**self._cinder_cli_kwargs)
|
||||
self.client.set_environment_variables(
|
||||
self.config.environment_variable_dictionary)
|
||||
self.behaviors = CinderCLI_Behaviors(self.client, self.config)
|
||||
|
||||
|
||||
class CinderVerticalIntegrationComposite(object):
|
||||
def __init__(self):
|
||||
self.cli = CinderCLI_Composite()
|
||||
self.api = VolumesComposite()
|
||||
|
||||
|
||||
class CinderCLI_Datasets():
|
||||
"""Collection of dataset generators for blockstorage data driven tests"""
|
||||
|
||||
@classmethod
|
||||
@memoized
|
||||
def volume_types(cls):
|
||||
"""Returns a DatasetList of Volume Type names and id's"""
|
||||
|
||||
cinder_cli = CinderCLI_Composite()
|
||||
volume_type_list = cinder_cli.behaviors.list_volume_types()
|
||||
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
|
||||
|
||||
|
||||
class CinderTestFixture(BaseTestFixture):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(CinderTestFixture, cls).setUpClass()
|
||||
cls.cinder = CinderVerticalIntegrationComposite()
|
||||
|
||||
@staticmethod
|
||||
def random_volume_name():
|
||||
return random_string(prefix="Volume_", size=10)
|
||||
|
||||
@staticmethod
|
||||
def random_snapshot_name():
|
||||
return random_string(prefix="Snapshot_", size=10)
|
|
@ -1,72 +0,0 @@
|
|||
from cafe.drivers.unittest.decorators import \
|
||||
DataDrivenFixture, data_driven_test
|
||||
|
||||
from cloudroast.openstackcli.cindercli.fixtures import \
|
||||
CinderCLI_Datasets, CinderTestFixture
|
||||
|
||||
from cloudcafe.blockstorage.volumes_api.v1.models.statuses import \
|
||||
Snapshot as SnapshotStatuses
|
||||
|
||||
|
||||
@DataDrivenFixture
|
||||
class CinderCLI_SnapshotSmoke(CinderTestFixture):
|
||||
|
||||
@data_driven_test(CinderCLI_Datasets.volume_types())
|
||||
def ddtest_snapshot_create(self, volume_type_name, volume_type_id):
|
||||
"""Snapshots take a relative eternity to test compared to volumes.
|
||||
To facilitate this smoke test running as quickly as possible,
|
||||
it is a composite of logic that would normally be broken up into
|
||||
several different tests."""
|
||||
|
||||
# Setup
|
||||
volume = self.cinder.cli.behaviors.create_available_volume(
|
||||
type_=volume_type_id)
|
||||
self.addCleanup(self.cinder.cli.client.delete_volume, volume.id_)
|
||||
|
||||
# Test create response
|
||||
display_name = self.random_snapshot_name()
|
||||
display_description = "Snapshot_Description"
|
||||
|
||||
resp = self.cinder.cli.client.create_snapshot(
|
||||
volume.id_, display_name=display_name,
|
||||
display_description=display_description)
|
||||
|
||||
self.assertIsNotNone(
|
||||
resp.entity, 'Could not parse snapshot-create output')
|
||||
|
||||
snapshot = resp.entity
|
||||
|
||||
self.assertEquals(
|
||||
snapshot.display_name, display_name,
|
||||
"Display name did not match expected display name")
|
||||
self.assertEquals(
|
||||
snapshot.display_description, display_description,
|
||||
"Display description did not match expected display description")
|
||||
self.assertEquals(
|
||||
snapshot.size, volume.size,
|
||||
"Size did not match source volume size")
|
||||
self.assertEquals(
|
||||
snapshot.volume_id, volume.id_,
|
||||
"Volume id did not match source volume id")
|
||||
self.assertIn(
|
||||
snapshot.status,
|
||||
[SnapshotStatuses.AVAILABLE, SnapshotStatuses.CREATING],
|
||||
"Snapshot created with unexpected status: {0}".format(
|
||||
snapshot.status))
|
||||
|
||||
# Wait for snapshot to attain 'available' status
|
||||
snapshot_timeout = \
|
||||
self.cinder.api.behaviors.calculate_snapshot_create_timeout(
|
||||
volume.size)
|
||||
|
||||
self.cinder.cli.behaviors.wait_for_snapshot_status(
|
||||
snapshot.id_, SnapshotStatuses.AVAILABLE, snapshot_timeout)
|
||||
|
||||
# Make sure snapshot progress is at 100%
|
||||
resp = self.cinder.cli.client.show_snapshot(snapshot.id_)
|
||||
self.assertIsNotNone(
|
||||
resp.entity, 'Could not parse snapshot-show output')
|
||||
snapshot = resp.entity
|
||||
self.assertEquals(
|
||||
snapshot.progress, '100%',
|
||||
"Snapshot attained 'AVAILABLE' status, but progress is not 100%")
|
|
@ -1,47 +0,0 @@
|
|||
from cafe.drivers.unittest.decorators import \
|
||||
DataDrivenFixture, data_driven_test
|
||||
|
||||
from cloudroast.openstackcli.cindercli.fixtures import \
|
||||
CinderCLI_Datasets, CinderTestFixture
|
||||
|
||||
|
||||
@DataDrivenFixture
|
||||
class CinderCLI_VolumeSmoke(CinderTestFixture):
|
||||
|
||||
@data_driven_test(CinderCLI_Datasets.volume_types())
|
||||
def ddtest_create_volume(self, volume_type_name, volume_type_id):
|
||||
name = self.random_volume_name()
|
||||
size = self.cinder.api.config.min_volume_size
|
||||
resp = self.cinder.cli.client.create_volume(
|
||||
size=size, volume_type=volume_type_id,display_name=name)
|
||||
|
||||
self.assertIsNotNone(
|
||||
resp.entity, 'Could not parse cinder create response')
|
||||
|
||||
self.assertEquals(
|
||||
resp.return_code, 0, "Cinder command returned an error code.")
|
||||
|
||||
volume = resp.entity
|
||||
|
||||
self.addCleanup(self.cinder.cli.client.delete_volume, volume.id_)
|
||||
|
||||
self.assertEqual(size, volume.size, "Volume size reported incorrectly")
|
||||
self.assertEqual(
|
||||
name, volume.display_name,
|
||||
"Volume display name reported incorrectly")
|
||||
|
||||
@data_driven_test(CinderCLI_Datasets.volume_types())
|
||||
def ddtest_delete_volume_by_id(self, volume_type_name, volume_type_id):
|
||||
# setup
|
||||
volume = self.cinder.cli.behaviors.create_available_volume(
|
||||
type_=volume_type_id)
|
||||
resp = self.cinder.cli.client.delete_volume(volume.id_)
|
||||
|
||||
self.assertEquals(
|
||||
len(resp.standard_out), 0,
|
||||
"Volume delete returned output on standard error")
|
||||
self.addCleanup(self.cinder.cli.client.delete_volume, volume.id_)
|
||||
|
||||
self.assertTrue(
|
||||
self.cinder.cli.behaviors.wait_for_volume_delete(volume.id_),
|
||||
"Could not confirm that volume {0} was deleted".format(volume.id_))
|
Loading…
Reference in New Issue