Ported volumes and snapshots smoke to v2 from v1

* Fixed issues with v1 tests importing datasets and composites
  from old locations.

Change-Id: I1122a0da82ab607c2e2572e70a4f22873fa94d2b
This commit is contained in:
Jose Idar
2014-02-27 15:44:23 -06:00
parent 49358c87f3
commit fbde5ba22a
9 changed files with 250 additions and 13 deletions

View File

@@ -7,8 +7,8 @@ from cloudcafe.blockstorage.volumes_api.v1.client import VolumesClient
from cloudcafe.blockstorage.volumes_api.v1.behaviors import \
VolumesAPI_Behaviors
from cloudroast.blockstorage.fixtures import \
BaseBlockstorageTestFixture, BlockstorageAuthComposite
from cloudroast.blockstorage.fixtures import BaseBlockstorageTestFixture
from cloudroast.blockstorage.composites import BlockstorageAuthComposite
class VolumesComposite(object):

View File

@@ -16,7 +16,7 @@ from cloudcafe.compute.volume_attachments_api.config \
import VolumeAttachmentsAPIConfig
from cloudroast.blockstorage.volumes_api.v1.fixtures import VolumesTestFixture
from cloudroast.blockstorage.fixtures import AuthComposite
from cloudroast.blockstorage.composites import AuthComposite
class ComputeAuthComposite(object):

View File

@@ -27,7 +27,7 @@ from cloudroast.blockstorage.volumes_api.v1.fixtures import \
class SnapshotActions(VolumesTestFixture):
@data_driven_test(VolumesDatasets.volume_types())
@tags('smoke')
@tags('snapshots', 'smoke')
def ddtest_create_minimum_size_volume_snapshot(
self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)

View File

@@ -17,6 +17,7 @@ limitations under the License.
from cafe.drivers.unittest.decorators import \
data_driven_test, DataDrivenFixture
from cafe.drivers.unittest.decorators import tags
from cloudcafe.blockstorage.volumes_api.v1.models import statuses
from cloudroast.blockstorage.volumes_api.v1.fixtures import \
VolumesTestFixture, VolumesDatasets
@@ -35,7 +36,7 @@ class VolumeActions(VolumesTestFixture):
display_name = self.random_volume_name()
display_description = "{0}".format(self.__class__.__name__)
metadata = {"metadata_key_one": "metadata_value_one"}
availability_zone = self.blockstorage.config.region
availability_zone = self.blockstorage.config.availability_zone or None
resp = self.volumes.client.create_volume(
size, volume_type_id, display_name=display_name,
@@ -64,7 +65,7 @@ class VolumeActions(VolumesTestFixture):
self.assertIsNone(volume.snapshot_id)
@data_driven_test(VolumesDatasets.volume_types())
@tags('smoke')
@tags('volumes', 'smoke')
def ddtest_get_volume_info(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
resp = self.volumes.client.get_volume_info(volume.id_)
@@ -88,7 +89,7 @@ class VolumeActions(VolumesTestFixture):
self.assertEquals(volume.volume_type, volume_info.volume_type)
@data_driven_test(VolumesDatasets.volume_types())
@tags('smoke')
@tags('volumes', 'smoke')
def ddtest_list_volumes(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
resp = self.volumes.client.list_all_volumes()
@@ -97,10 +98,14 @@ class VolumeActions(VolumesTestFixture):
self.assertResponseIsDeserialized(resp)
volume_list = resp.entity
self.assertIn(volume, volume_list, 'Volume not found in volume list')
expected_volumes = [v for v in volume_list if v.id_ == volume.id_]
self.assertTrue(
len(expected_volumes) > 0,
'No volumes where found in the volume list with an id == '
'{0}'.format(volume.id_))
@data_driven_test(VolumesDatasets.volume_types())
@tags('smoke')
@tags('volumes', 'smoke')
def ddtest_list_volume_details(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
resp = self.volumes.client.list_all_volumes_info()
@@ -109,8 +114,12 @@ class VolumeActions(VolumesTestFixture):
self.assertResponseIsDeserialized(resp)
volume_list = resp.entity
self.assertIn(volume, volume_list, 'Volume not found in volume list')
volume_info = [v for v in volume_list if v == volume][0]
expected_volumes = [v for v in volume_list if v.id_ == volume.id_]
self.assertTrue(
len(expected_volumes) > 0,
'No volumes where found in the volume list with an id == '
'{0}'.format(volume.id_))
volume_info = expected_volumes[0]
#Test
self.assertEquals(volume.display_name, volume_info.display_name)
@@ -127,8 +136,9 @@ class VolumeActions(VolumesTestFixture):
self.assertEquals(volume.volume_type, volume_info.volume_type)
@data_driven_test(VolumesDatasets.volume_types())
@tags('smoked')
@tags('volumes', 'smoke')
def ddtest_delete_volume(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
self.volumes.behaviors.wait_for_volume_status(volume.id_, 'available')
result = self.volumes.behaviors.delete_volume_confirmed(volume.id_)
self.assertTrue(result)

View File

@@ -29,7 +29,7 @@ class VolumesDatasets(BaseDataset):
@classmethod
@memoized
def volume_type(
def volume_types(
cls, max_datasets=None, randomize=False, volume_type_filter=None):
"""Returns a DatasetList of Volume Type names and id's"""

View File

@@ -0,0 +1,15 @@
"""
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.
"""

View File

@@ -0,0 +1,54 @@
"""
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.
"""
from cafe.drivers.unittest.decorators import (
data_driven_test, DataDrivenFixture)
from cafe.drivers.unittest.decorators import tags
from cloudcafe.blockstorage.volumes_api.v2.models import statuses
from cloudroast.blockstorage.volumes_api.v2.fixtures import VolumesTestFixture
from cloudroast.blockstorage.volumes_api.v2.datasets import VolumesDatasets
@DataDrivenFixture
class SnapshotActions(VolumesTestFixture):
@data_driven_test(VolumesDatasets.volume_types())
@tags('snapshots', 'smoke')
def ddtest_create_minimum_size_volume_snapshot(
self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
snapshot_display_name = self.random_snapshot_name()
snapshot_display_description = "Test snapshot"
resp = self.volumes.client.create_snapshot(
volume.id_, display_name=snapshot_display_name,
display_description=snapshot_display_description,
force_create=True)
self.assertExactResponseStatus(
resp, 200, msg='Volume Snapshot create failed')
self.assertResponseIsDeserialized(resp)
snapshot = resp.entity
self.assertEquals(snapshot.volume_id, volume.id_)
self.assertEquals(snapshot.display_name, snapshot_display_name)
self.assertEquals(
snapshot.display_description,
snapshot_display_description)
self.assertIn(
snapshot.status,
[statuses.Snapshot.AVAILABLE, statuses.Snapshot.CREATING])
self.assertEquals(snapshot.size, volume.size)

View File

@@ -0,0 +1,15 @@
"""
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.
"""

View File

@@ -0,0 +1,143 @@
"""
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.
"""
from cafe.drivers.unittest.decorators import (
data_driven_test, DataDrivenFixture)
from cafe.drivers.unittest.decorators import tags
from cloudcafe.blockstorage.volumes_api.v2.models import statuses
from cloudroast.blockstorage.volumes_api.v2.fixtures import VolumesTestFixture
from cloudroast.blockstorage.volumes_api.v2.datasets import VolumesDatasets
@DataDrivenFixture
class VolumeActions(VolumesTestFixture):
@data_driven_test(VolumesDatasets.volume_types())
@tags('volumes', 'smoke')
def ddtest_create_minimum_size_default_volume(
self, volume_type_name, volume_type_id):
#Setup
size = self.volumes.config.min_volume_size
name = self.random_volume_name()
description = "{0}".format(self.__class__.__name__)
metadata = {"metadata_key_one": "metadata_value_one"}
availability_zone = self.blockstorage.config.availability_zone or None
resp = self.volumes.client.create_volume(
size, volume_type_id, name=name,
description=description,
availability_zone=availability_zone, metadata=metadata)
self.assertExactResponseStatus(resp, 200, msg='Volume create failed')
self.assertResponseIsDeserialized(resp)
volume = resp.entity
self.addCleanup(
self.volumes.behaviors.delete_volume_confirmed, volume.id_)
#Test
self.assertEquals(volume.name, name)
self.assertEquals(volume.description, description)
self.assertEquals(str(volume.size), str(size))
self.assertEquals(volume.metadata, metadata)
self.assertEquals(volume.availability_zone, availability_zone)
self.assertEquals(volume.attachments, list())
self.assertIsNotNone(volume.created_at)
self.assertIsNotNone(volume.status)
self.assertIn(
volume.status.lower(),
[statuses.Volume.AVAILABLE.lower(),
statuses.Volume.CREATING.lower()])
self.assertIsNone(volume.snapshot_id)
@data_driven_test(VolumesDatasets.volume_types())
@tags('volumes', 'smoke')
def ddtest_get_volume_info(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
resp = self.volumes.client.get_volume_info(volume.id_)
self.assertExactResponseStatus(
resp, 200, msg='Get volume info call failed')
self.assertResponseIsDeserialized(resp)
volume_info = resp.entity
#Test
self.assertEquals(volume.name, volume_info.name)
self.assertEquals(
volume.description, volume_info.description)
self.assertEquals(str(volume.size), str(volume_info.size))
self.assertEquals(volume.metadata, volume_info.metadata)
self.assertEquals(
volume.availability_zone, volume_info.availability_zone)
self.assertEquals(volume.attachments, volume_info.attachments)
self.assertEquals(volume.created_at, volume_info.created_at)
self.assertEquals(volume.status, volume_info.status)
self.assertIsNone(volume.snapshot_id, volume_info.snapshot_id)
self.assertEquals(volume.volume_type, volume_info.volume_type)
@data_driven_test(VolumesDatasets.volume_types())
@tags('volumes', 'smoke')
def ddtest_list_volumes(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
resp = self.volumes.client.list_all_volumes()
self.assertExactResponseStatus(
resp, 200, msg='Get volume list call failed')
self.assertResponseIsDeserialized(resp)
volume_list = resp.entity
expected_volumes = [v for v in volume_list if v.id_ == volume.id_]
self.assertTrue(
len(expected_volumes) > 0,
'No volumes where found in the volume list with an id == '
'{0}'.format(volume.id_))
@data_driven_test(VolumesDatasets.volume_types())
@tags('volumes', 'smoke')
def ddtest_list_volume_details(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
resp = self.volumes.client.list_all_volumes_info()
self.assertExactResponseStatus(
resp, 200, msg='Get volume list call failed')
self.assertResponseIsDeserialized(resp)
volume_list = resp.entity
expected_volumes = [v for v in volume_list if v.id_ == volume.id_]
self.assertTrue(
len(expected_volumes) > 0,
'No volumes where found in the volume list with an id == '
'{0}'.format(volume.id_))
volume_info = expected_volumes[0]
#Test
self.assertEquals(volume.name, volume_info.name)
self.assertEquals(
volume.description, volume_info.description)
self.assertEquals(str(volume.size), str(volume_info.size))
self.assertEquals(volume.metadata, volume_info.metadata)
self.assertEquals(
volume.availability_zone, volume_info.availability_zone)
self.assertEquals(volume.attachments, volume_info.attachments)
self.assertEquals(volume.created_at, volume_info.created_at)
self.assertEquals(volume.status, volume_info.status)
self.assertIsNone(volume.snapshot_id, volume_info.snapshot_id)
self.assertEquals(volume.volume_type, volume_info.volume_type)
@data_driven_test(VolumesDatasets.volume_types())
@tags('volumes', 'smoke')
def ddtest_delete_volume(self, volume_type_name, volume_type_id):
volume = self.new_volume(vol_type=volume_type_id)
result = self.volumes.behaviors.delete_volume_confirmed(volume.id_)
self.assertTrue(result)