Merge "Wait for FIP status to get to DOWN in test_router_rescheduling"
diff --git a/README.rst b/README.rst
index fc4de5e..bc58cc0 100644
--- a/README.rst
+++ b/README.rst
@@ -1,3 +1,12 @@
+========================
+Team and repository tags
+========================
+
+.. image:: http://governance.openstack.org/badges/tempest.svg
+ :target: http://governance.openstack.org/reference/tags/index.html
+
+.. Change things from this point on
+
Tempest - The OpenStack Integration Test Suite
==============================================
diff --git a/doc/source/library/api_microversion_testing.rst b/doc/source/library/api_microversion_testing.rst
index b7a4ba8..8be924d 100644
--- a/doc/source/library/api_microversion_testing.rst
+++ b/doc/source/library/api_microversion_testing.rst
@@ -1,6 +1,6 @@
.. _api_microversion_testing:
-API Microversion Testing Support in Temepst
+API Microversion Testing Support in Tempest
===========================================
---------------------------------------------
diff --git a/releasenotes/notes/move-cinder-v3-to-lib-service-be3ba0c20753b594.yaml b/releasenotes/notes/move-cinder-v3-to-lib-service-be3ba0c20753b594.yaml
new file mode 100644
index 0000000..9223ba5
--- /dev/null
+++ b/releasenotes/notes/move-cinder-v3-to-lib-service-be3ba0c20753b594.yaml
@@ -0,0 +1,7 @@
+features:
+ - |
+ Define the Volume v3 service clients as library interfaces,
+ allowing other projects to use these modules as stable
+ libraries without maintenance changes.
+
+ * messages_client(v3)
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index 667d30b..1233a2b 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -18,9 +18,12 @@
from tempest.api.compute import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils import data_utils
+from tempest import config
from tempest.lib.common.utils import test_utils
from tempest import test
+CONF = config.CONF
+
class AggregatesAdminTestJSON(base.BaseV2ComputeAdminTest):
"""Tests Aggregates API that require admin privileges"""
@@ -39,14 +42,22 @@
cls.host = None
hypers = cls.os_adm.hypervisor_client.list_hypervisors(
detail=True)['hypervisors']
+
+ if CONF.compute.hypervisor_type:
+ hypers = [hyper for hyper in hypers
+ if (hyper['hypervisor_type'] ==
+ CONF.compute.hypervisor_type)]
+
hosts_available = [hyper['service']['host'] for hyper in hypers
if (hyper['state'] == 'up' and
hyper['status'] == 'enabled')]
if hosts_available:
cls.host = hosts_available[0]
else:
- raise testtools.TestCase.failureException(
- "no available compute node found")
+ msg = "no available compute node found"
+ if CONF.compute.hypervisor_type:
+ msg += " for hypervisor_type %s" % CONF.compute.hypervisor_type
+ raise testtools.TestCase.failureException(msg)
@test.idempotent_id('0d148aa3-d54c-4317-aa8d-42040a475e20')
def test_aggregate_create_delete(self):
diff --git a/tempest/api/compute/images/test_image_metadata_negative.py b/tempest/api/compute/images/test_image_metadata_negative.py
index 9cb9e03..489bfbc 100644
--- a/tempest/api/compute/images/test_image_metadata_negative.py
+++ b/tempest/api/compute/images/test_image_metadata_negative.py
@@ -19,11 +19,11 @@
from tempest import test
-class ImagesMetadataTestJSON(base.BaseV2ComputeTest):
+class ImagesMetadataNegativeTestJSON(base.BaseV2ComputeTest):
@classmethod
def setup_clients(cls):
- super(ImagesMetadataTestJSON, cls).setup_clients()
+ super(ImagesMetadataNegativeTestJSON, cls).setup_clients()
cls.client = cls.compute_images_client
@test.attr(type=['negative'])
diff --git a/tempest/api/compute/volumes/test_attach_volume.py b/tempest/api/compute/volumes/test_attach_volume.py
index d4831b1..ee6ac25 100644
--- a/tempest/api/compute/volumes/test_attach_volume.py
+++ b/tempest/api/compute/volumes/test_attach_volume.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import logging
import testtools
from tempest.api.compute import base
@@ -20,18 +21,17 @@
from tempest.common.utils.linux import remote_client
from tempest.common import waiters
from tempest import config
+from tempest.lib import exceptions as lib_exc
from tempest import test
CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
class AttachVolumeTestJSON(base.BaseV2ComputeTest):
max_microversion = '2.19'
- def __init__(self, *args, **kwargs):
- super(AttachVolumeTestJSON, self).__init__(*args, **kwargs)
- self.attachment = None
-
@classmethod
def skip_checks(cls):
super(AttachVolumeTestJSON, cls).skip_checks()
@@ -47,50 +47,52 @@
@classmethod
def resource_setup(cls):
cls.set_validation_resources()
-
super(AttachVolumeTestJSON, cls).resource_setup()
cls.device = CONF.compute.volume_device_name
- def _detach(self, server_id, volume_id):
- if self.attachment:
- self.servers_client.detach_volume(server_id, volume_id)
- waiters.wait_for_volume_status(self.volumes_client,
- volume_id, 'available')
-
def _create_server(self):
# Start a server and wait for it to become ready
server = self.create_test_server(
validatable=True,
wait_until='ACTIVE',
adminPass=self.image_ssh_password)
-
# Record addresses so that we can ssh later
server['addresses'] = self.servers_client.list_addresses(
server['id'])['addresses']
return server
- def _create_and_attach_volume(self, server):
- # Create a volume and wait for it to become ready
- volume = self.create_volume()
- self.addCleanup(self.delete_volume, volume['id'])
+ def _detach_volume(self, server_id, volume_id):
+ try:
+ self.servers_client.detach_volume(server_id, volume_id)
+ waiters.wait_for_volume_status(self.volumes_client,
+ volume_id, 'available')
+ except lib_exc.NotFound:
+ LOG.warning("Unable to detach volume %s from server %s "
+ "possibly it was already detached" % (volume_id,
+ server_id))
+ def _attach_volume(self, server_id, volume_id, device=None):
# Attach the volume to the server
- self.attachment = self.servers_client.attach_volume(
- server['id'],
- volumeId=volume['id'],
- device='/dev/%s' % self.device)['volumeAttachment']
+ kwargs = {'volumeId': volume_id}
+ if device:
+ kwargs.update({'device': '/dev/%s' % device})
+ attachment = self.servers_client.attach_volume(
+ server_id, **kwargs)['volumeAttachment']
waiters.wait_for_volume_status(self.volumes_client,
- volume['id'], 'in-use')
+ volume_id, 'in-use')
+ self.addCleanup(self._detach_volume, server_id,
+ volume_id)
- self.addCleanup(self._detach, server['id'], volume['id'])
- return volume
+ return attachment
@test.idempotent_id('52e9045a-e90d-4c0d-9087-79d657faffff')
def test_attach_detach_volume(self):
# Stop and Start a server with an attached volume, ensuring that
# the volume remains attached.
server = self._create_server()
- volume = self._create_and_attach_volume(server)
+ volume = self.create_volume()
+ attachment = self._attach_volume(server['id'], volume['id'],
+ device=self.device)
self.servers_client.stop_server(server['id'])
waiters.wait_for_server_status(self.servers_client, server['id'],
@@ -113,8 +115,7 @@
device_name_to_match = ' ' + self.device + '\n'
self.assertIn(device_name_to_match, partitions)
- self._detach(server['id'], volume['id'])
- self.attachment = None
+ self._detach_volume(server['id'], attachment['volumeId'])
self.servers_client.stop_server(server['id'])
waiters.wait_for_server_status(self.servers_client, server['id'],
'SHUTOFF')
@@ -137,23 +138,23 @@
@test.idempotent_id('7fa563fe-f0f7-43eb-9e22-a1ece036b513')
def test_list_get_volume_attachments(self):
- # Create Server, Volume and attach that Volume to Server
+ # List volume attachment of the server
server = self._create_server()
- volume = self._create_and_attach_volume(server)
-
- # List Volume attachment of the server
+ volume = self.create_volume()
+ attachment = self._attach_volume(server['id'], volume['id'],
+ device=self.device)
body = self.servers_client.list_volume_attachments(
server['id'])['volumeAttachments']
self.assertEqual(1, len(body))
- self.assertIn(self.attachment, body)
+ self.assertIn(attachment, body)
- # Get Volume attachment of the server
+ # Get volume attachment of the server
body = self.servers_client.show_volume_attachment(
server['id'],
- self.attachment['id'])['volumeAttachment']
+ attachment['id'])['volumeAttachment']
self.assertEqual(server['id'], body['serverId'])
self.assertEqual(volume['id'], body['volumeId'])
- self.assertEqual(self.attachment['id'], body['id'])
+ self.assertEqual(attachment['id'], body['id'])
class AttachVolumeShelveTestJSON(AttachVolumeTestJSON):
@@ -219,19 +220,21 @@
# Create server, count number of volumes on it, shelve
# server and attach pre-created volume to shelved server
server = self._create_server()
+ volume = self.create_volume()
num_vol = self._count_volumes(server)
self._shelve_server(server)
- self._create_and_attach_volume(server)
+ attachment = self._attach_volume(server['id'], volume['id'],
+ device=self.device)
# Unshelve the instance and check that attached volume exists
self._unshelve_server_and_check_volumes(server, num_vol + 1)
- # Get Volume attachment of the server
+ # Get volume attachment of the server
volume_attachment = self.servers_client.show_volume_attachment(
server['id'],
- self.attachment['id'])['volumeAttachment']
+ attachment['id'])['volumeAttachment']
self.assertEqual(server['id'], volume_attachment['serverId'])
- self.assertEqual(self.attachment['id'], volume_attachment['id'])
+ self.assertEqual(attachment['id'], volume_attachment['id'])
# Check the mountpoint is not None after unshelve server even in
# case of shelved_offloaded.
self.assertIsNotNone(volume_attachment['device'])
@@ -240,16 +243,15 @@
@testtools.skipUnless(CONF.compute_feature_enabled.shelve,
'Shelve is not available.')
def test_detach_volume_shelved_or_offload_server(self):
- # Create server, count number of volumes on it, shelve
+ # Count number of volumes on instance, shelve
# server and attach pre-created volume to shelved server
server = self._create_server()
+ volume = self.create_volume()
num_vol = self._count_volumes(server)
self._shelve_server(server)
- volume = self._create_and_attach_volume(server)
-
+ self._attach_volume(server['id'], volume['id'], device=self.device)
# Detach the volume
- self._detach(server['id'], volume['id'])
- self.attachment = None
+ self._detach_volume(server['id'], volume['id'])
# Unshelve the instance and check that we have the expected number of
# volume(s)
diff --git a/tempest/api/image/admin/v2/test_images.py b/tempest/api/image/admin/v2/test_images.py
index 9844a67..f22f321 100644
--- a/tempest/api/image/admin/v2/test_images.py
+++ b/tempest/api/image/admin/v2/test_images.py
@@ -34,11 +34,10 @@
def test_admin_deactivate_reactivate_image(self):
# Create image by non-admin tenant
image_name = data_utils.rand_name('image')
- image = self.client.create_image(name=image_name,
- container_format='bare',
- disk_format='raw',
- visibility='private')
- self.addCleanup(self.client.delete_image, image['id'])
+ image = self.create_image(name=image_name,
+ container_format='bare',
+ disk_format='raw',
+ visibility='private')
# upload an image file
content = data_utils.random_bytes()
image_file = six.BytesIO(content)
diff --git a/tempest/api/image/v2/test_images.py b/tempest/api/image/v2/test_images.py
index 42912f0..7b9244b 100644
--- a/tempest/api/image/v2/test_images.py
+++ b/tempest/api/image/v2/test_images.py
@@ -83,10 +83,10 @@
image_name = data_utils.rand_name('image')
container_format = CONF.image.container_formats[0]
disk_format = CONF.image.disk_formats[0]
- image = self.client.create_image(name=image_name,
- container_format=container_format,
- disk_format=disk_format,
- visibility='private')
+ image = self.create_image(name=image_name,
+ container_format=container_format,
+ disk_format=disk_format,
+ visibility='private')
# Delete Image
self.client.delete_image(image['id'])
self.client.wait_for_resource_deletion(image['id'])
@@ -105,11 +105,10 @@
image_name = data_utils.rand_name('image')
container_format = CONF.image.container_formats[0]
disk_format = CONF.image.disk_formats[0]
- image = self.client.create_image(name=image_name,
- container_format=container_format,
- disk_format=disk_format,
- visibility='private')
- self.addCleanup(self.client.delete_image, image['id'])
+ image = self.create_image(name=image_name,
+ container_format=container_format,
+ disk_format=disk_format,
+ visibility='private')
self.assertEqual('queued', image['status'])
# Now try uploading an image file
diff --git a/tempest/api/network/base.py b/tempest/api/network/base.py
index 629926d..deefbeb 100644
--- a/tempest/api/network/base.py
+++ b/tempest/api/network/base.py
@@ -135,12 +135,12 @@
super(BaseNetworkTest, cls).resource_cleanup()
@classmethod
- def create_network(cls, network_name=None):
+ def create_network(cls, network_name=None, **kwargs):
"""Wrapper utility that returns a test network."""
network_name = network_name or data_utils.rand_name(
- cls.__name__ + "-network")
+ cls.__name__ + '-test-network')
- body = cls.networks_client.create_network(name=network_name)
+ body = cls.networks_client.create_network(name=network_name, **kwargs)
network = body['network']
cls.networks.append(network)
return network
diff --git a/tempest/api/network/test_networks.py b/tempest/api/network/test_networks.py
index d2056c4..acac22b 100644
--- a/tempest/api/network/test_networks.py
+++ b/tempest/api/network/test_networks.py
@@ -209,12 +209,16 @@
def test_show_network_fields(self):
# Verify specific fields of a network
fields = ['id', 'name']
+ if test.is_extension_enabled('net-mtu', 'network'):
+ fields.append('mtu')
body = self.networks_client.show_network(self.network['id'],
fields=fields)
network = body['network']
self.assertEqual(sorted(network.keys()), sorted(fields))
for field_name in fields:
self.assertEqual(network[field_name], self.network[field_name])
+ self.assertNotIn('tenant_id', network)
+ self.assertNotIn('project_id', network)
@test.attr(type='smoke')
@test.idempotent_id('f7ffdeda-e200-4a7a-bcbe-05716e86bf43')
@@ -229,6 +233,8 @@
def test_list_networks_fields(self):
# Verify specific fields of the networks
fields = ['id', 'name']
+ if test.is_extension_enabled('net-mtu', 'network'):
+ fields.append('mtu')
body = self.networks_client.list_networks(fields=fields)
networks = body['networks']
self.assertNotEmpty(networks, "Network list returned is empty")
@@ -385,6 +391,21 @@
network_id=CONF.network.public_network_id)
self.assertEmpty(body['subnets'], "Public subnets visible")
+ @test.idempotent_id('c72c1c0c-2193-4aca-ccc4-b1442640bbbb')
+ @test.requires_ext(extension="standard-attr-description",
+ service="network")
+ def test_create_update_network_description(self):
+ body = self.create_network(description='d1')
+ self.assertEqual('d1', body['description'])
+ net_id = body['id']
+ body = self.networks_client.list_networks(id=net_id)['networks'][0]
+ self.assertEqual('d1', body['description'])
+ body = self.networks_client.update_network(body['id'],
+ description='d2')
+ self.assertEqual('d2', body['network']['description'])
+ body = self.networks_client.list_networks(id=net_id)['networks'][0]
+ self.assertEqual('d2', body['description'])
+
class BulkNetworkOpsTest(base.BaseNetworkTest):
"""Tests the following operations in the Neutron API:
diff --git a/tempest/api/volume/admin/test_snapshots_actions.py b/tempest/api/volume/admin/test_snapshots_actions.py
index 5af83b3..29a161b 100644
--- a/tempest/api/volume/admin/test_snapshots_actions.py
+++ b/tempest/api/volume/admin/test_snapshots_actions.py
@@ -28,11 +28,6 @@
raise cls.skipException("Cinder snapshot feature disabled")
@classmethod
- def setup_clients(cls):
- super(SnapshotsActionsV2Test, cls).setup_clients()
- cls.client = cls.snapshots_client
-
- @classmethod
def resource_setup(cls):
super(SnapshotsActionsV2Test, cls).resource_setup()
@@ -59,7 +54,7 @@
reset_snapshot_status(temp_snapshot['id'], status)
self.admin_snapshots_client.\
force_delete_snapshot(temp_snapshot['id'])
- self.client.wait_for_resource_deletion(temp_snapshot['id'])
+ self.snapshots_client.wait_for_resource_deletion(temp_snapshot['id'])
def _get_progress_alias(self):
return 'os-extended-snapshot-attributes:progress'
@@ -85,8 +80,9 @@
progress = '80%'
status = 'error'
progress_alias = self._get_progress_alias()
- self.client.update_snapshot_status(self.snapshot['id'],
- status=status, progress=progress)
+ self.snapshots_client.update_snapshot_status(self.snapshot['id'],
+ status=status,
+ progress=progress)
snapshot_get = self.admin_snapshots_client.show_snapshot(
self.snapshot['id'])['snapshot']
self.assertEqual(status, snapshot_get['status'])
diff --git a/tempest/api/volume/admin/test_volumes_actions.py b/tempest/api/volume/admin/test_volumes_actions.py
index e7a3f62..261e652 100644
--- a/tempest/api/volume/admin/test_volumes_actions.py
+++ b/tempest/api/volume/admin/test_volumes_actions.py
@@ -23,11 +23,6 @@
class VolumesActionsV2Test(base.BaseVolumeAdminTest):
@classmethod
- def setup_clients(cls):
- super(VolumesActionsV2Test, cls).setup_clients()
- cls.client = cls.volumes_client
-
- @classmethod
def resource_setup(cls):
super(VolumesActionsV2Test, cls).resource_setup()
@@ -47,7 +42,7 @@
self.admin_volume_client.reset_volume_status(
temp_volume['id'], status=status)
self.admin_volume_client.force_delete_volume(temp_volume['id'])
- self.client.wait_for_resource_deletion(temp_volume['id'])
+ self.volumes_client.wait_for_resource_deletion(temp_volume['id'])
@test.idempotent_id('d063f96e-a2e0-4f34-8b8a-395c42de1845')
def test_volume_reset_status(self):
diff --git a/tempest/api/volume/admin/test_volumes_backup.py b/tempest/api/volume/admin/test_volumes_backup.py
index 73f1f8f..61d4ba7 100644
--- a/tempest/api/volume/admin/test_volumes_backup.py
+++ b/tempest/api/volume/admin/test_volumes_backup.py
@@ -33,12 +33,6 @@
if not CONF.volume_feature_enabled.backup:
raise cls.skipException("Cinder backup feature disabled")
- @classmethod
- def resource_setup(cls):
- super(VolumesBackupsAdminV2Test, cls).resource_setup()
-
- cls.volume = cls.create_volume()
-
def _delete_backup(self, backup_id):
self.admin_backups_client.delete_backup(backup_id)
self.admin_backups_client.wait_for_resource_deletion(backup_id)
@@ -62,14 +56,13 @@
Cinder allows exporting DB backup information through its API so it can
be imported back in case of a DB loss.
"""
+ volume = self.create_volume()
# Create backup
backup_name = data_utils.rand_name(self.__class__.__name__ + '-Backup')
- backup = (self.admin_backups_client.create_backup(
- volume_id=self.volume['id'], name=backup_name)['backup'])
- self.addCleanup(self._delete_backup, backup['id'])
+ backup = (self.create_backup(backup_client=self.admin_backups_client,
+ volume_id=volume['id'],
+ name=backup_name))
self.assertEqual(backup_name, backup['name'])
- waiters.wait_for_backup_status(self.admin_backups_client,
- backup['id'], 'available')
# Export Backup
export_backup = (self.admin_backups_client.export_backup(backup['id'])
@@ -126,16 +119,15 @@
@test.idempotent_id('47a35425-a891-4e13-961c-c45deea21e94')
def test_volume_backup_reset_status(self):
+ # Create a volume
+ volume = self.create_volume()
# Create a backup
backup_name = data_utils.rand_name(
self.__class__.__name__ + '-Backup')
- backup = self.admin_backups_client.create_backup(
- volume_id=self.volume['id'], name=backup_name)['backup']
- self.addCleanup(self.admin_backups_client.delete_backup,
- backup['id'])
+ backup = self.create_backup(backup_client=self.admin_backups_client,
+ volume_id=volume['id'],
+ name=backup_name)
self.assertEqual(backup_name, backup['name'])
- waiters.wait_for_backup_status(self.admin_backups_client,
- backup['id'], 'available')
# Reset backup status to error
self.admin_backups_client.reset_backup_status(backup_id=backup['id'],
status="error")
diff --git a/tempest/api/volume/api_microversion_fixture.py b/tempest/api/volume/api_microversion_fixture.py
index 6817eaa..64bc537 100644
--- a/tempest/api/volume/api_microversion_fixture.py
+++ b/tempest/api/volume/api_microversion_fixture.py
@@ -13,7 +13,7 @@
import fixtures
-from tempest.services.volume.base import base_v3_client
+from tempest.lib.services.volume.v3 import base_client
class APIMicroversionFixture(fixtures.Fixture):
@@ -23,8 +23,8 @@
def _setUp(self):
super(APIMicroversionFixture, self)._setUp()
- base_v3_client.VOLUME_MICROVERSION = self.volume_microversion
+ base_client.VOLUME_MICROVERSION = self.volume_microversion
self.addCleanup(self._reset_volume_microversion)
def _reset_volume_microversion(self):
- base_v3_client.VOLUME_MICROVERSION = None
+ base_client.VOLUME_MICROVERSION = None
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 178b0b1..01e2c82 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -150,6 +150,18 @@
snapshot['id'], 'available')
return snapshot
+ def create_backup(self, volume_id, backup_client=None, **kwargs):
+ """Wrapper utility that returns a test backup."""
+ if backup_client is None:
+ backup_client = self.backups_client
+
+ backup = backup_client.create_backup(
+ volume_id=volume_id, **kwargs)['backup']
+ self.addCleanup(backup_client.delete_backup, backup['id'])
+ waiters.wait_for_backup_status(backup_client, backup['id'],
+ 'available')
+ return backup
+
# NOTE(afazekas): these create_* and clean_* could be defined
# only in a single location in the source, and could be more general.
diff --git a/tempest/api/volume/test_snapshot_metadata.py b/tempest/api/volume/test_snapshot_metadata.py
index 688baf5..171e241 100644
--- a/tempest/api/volume/test_snapshot_metadata.py
+++ b/tempest/api/volume/test_snapshot_metadata.py
@@ -30,11 +30,6 @@
raise cls.skipException("Cinder snapshot feature disabled")
@classmethod
- def setup_clients(cls):
- super(SnapshotV2MetadataTestJSON, cls).setup_clients()
- cls.client = cls.snapshots_client
-
- @classmethod
def resource_setup(cls):
super(SnapshotV2MetadataTestJSON, cls).resource_setup()
# Create a volume
@@ -45,7 +40,8 @@
def tearDown(self):
# Update the metadata to {}
- self.client.update_snapshot_metadata(self.snapshot_id, metadata={})
+ self.snapshots_client.update_snapshot_metadata(
+ self.snapshot_id, metadata={})
super(SnapshotV2MetadataTestJSON, self).tearDown()
@test.idempotent_id('a2f20f99-e363-4584-be97-bc33afb1a56c')
@@ -56,17 +52,17 @@
"key3": "value3"}
expected = {"key2": "value2",
"key3": "value3"}
- body = self.client.create_snapshot_metadata(
+ body = self.snapshots_client.create_snapshot_metadata(
self.snapshot_id, metadata)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(
+ body = self.snapshots_client.show_snapshot_metadata(
self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Delete one item metadata of the snapshot
- self.client.delete_snapshot_metadata_item(
+ self.snapshots_client.delete_snapshot_metadata_item(
self.snapshot_id, "key1")
- body = self.client.show_snapshot_metadata(
+ body = self.snapshots_client.show_snapshot_metadata(
self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(expected.items()))
self.assertNotIn("key1", body)
@@ -80,18 +76,18 @@
update = {"key3": "value3_update",
"key4": "value4"}
# Create metadata for the snapshot
- body = self.client.create_snapshot_metadata(
+ body = self.snapshots_client.create_snapshot_metadata(
self.snapshot_id, metadata)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(
+ body = self.snapshots_client.show_snapshot_metadata(
self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
- body = self.client.update_snapshot_metadata(
+ body = self.snapshots_client.update_snapshot_metadata(
self.snapshot_id, metadata=update)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(
+ body = self.snapshots_client.show_snapshot_metadata(
self.snapshot_id)['metadata']
self.assertEqual(update, body)
@@ -106,17 +102,17 @@
"key2": "value2",
"key3": "value3_update"}
# Create metadata for the snapshot
- body = self.client.create_snapshot_metadata(
+ body = self.snapshots_client.create_snapshot_metadata(
self.snapshot_id, metadata)['metadata']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(
+ body = self.snapshots_client.show_snapshot_metadata(
self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Update metadata item
- body = self.client.update_snapshot_metadata_item(
+ body = self.snapshots_client.update_snapshot_metadata_item(
self.snapshot_id, "key3", meta=update_item)['meta']
# Get the metadata of the snapshot
- body = self.client.show_snapshot_metadata(
+ body = self.snapshots_client.show_snapshot_metadata(
self.snapshot_id)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(expect.items()))
diff --git a/tempest/api/volume/test_volumes_backup.py b/tempest/api/volume/test_volumes_backup.py
index 141336f..972dd58 100644
--- a/tempest/api/volume/test_volumes_backup.py
+++ b/tempest/api/volume/test_volumes_backup.py
@@ -38,16 +38,11 @@
volume['id'])
backup_name = data_utils.rand_name(
self.__class__.__name__ + '-Backup')
- create_backup = self.backups_client.create_backup
- backup = create_backup(volume_id=volume['id'],
- name=backup_name)['backup']
- self.addCleanup(self.backups_client.delete_backup,
- backup['id'])
+ backup = self.create_backup(volume_id=volume['id'],
+ name=backup_name)
self.assertEqual(backup_name, backup['name'])
waiters.wait_for_volume_status(self.volumes_client,
volume['id'], 'available')
- waiters.wait_for_backup_status(self.backups_client,
- backup['id'], 'available')
# Get a given backup
backup = self.backups_client.show_backup(backup['id'])['backup']
@@ -97,12 +92,8 @@
# Create backup using force flag
backup_name = data_utils.rand_name(
self.__class__.__name__ + '-Backup')
- backup = self.backups_client.create_backup(
- volume_id=volume['id'],
- name=backup_name, force=True)['backup']
- self.addCleanup(self.backups_client.delete_backup, backup['id'])
- waiters.wait_for_backup_status(self.backups_client,
- backup['id'], 'available')
+ backup = self.create_backup(volume_id=volume['id'],
+ name=backup_name, force=True)
self.assertEqual(backup_name, backup['name'])
diff --git a/tempest/api/volume/test_volumes_clone.py b/tempest/api/volume/test_volumes_clone.py
index 7529dc2..2cedb4e 100644
--- a/tempest/api/volume/test_volumes_clone.py
+++ b/tempest/api/volume/test_volumes_clone.py
@@ -21,11 +21,11 @@
CONF = config.CONF
-class VolumesCloneTest(base.BaseVolumeTest):
+class VolumesV2CloneTest(base.BaseVolumeTest):
@classmethod
def skip_checks(cls):
- super(VolumesCloneTest, cls).skip_checks()
+ super(VolumesV2CloneTest, cls).skip_checks()
if not CONF.volume_feature_enabled.clone:
raise cls.skipException("Cinder volume clones are disabled")
@@ -45,6 +45,22 @@
self.assertEqual(volume['source_volid'], src_vol['id'])
self.assertEqual(int(volume['size']), src_size + 1)
+ @test.idempotent_id('cbbcd7c6-5a6c-481a-97ac-ca55ab715d16')
+ def test_create_from_bootable_volume(self):
+ # Create volume from image
+ img_uuid = CONF.compute.image_ref
+ src_vol = self.create_volume(imageRef=img_uuid)
-class VolumesV1CloneTest(VolumesCloneTest):
+ # Create a volume from the bootable volume
+ cloned_vol = self.create_volume(source_volid=src_vol['id'])
+ cloned_vol_details = self.volumes_client.show_volume(
+ cloned_vol['id'])['volume']
+
+ # Verify cloned volume creation as expected
+ self.assertEqual('true', cloned_vol_details['bootable'])
+ self.assertEqual(src_vol['id'], cloned_vol_details['source_volid'])
+ self.assertEqual(src_vol['size'], cloned_vol_details['size'])
+
+
+class VolumesV1CloneTest(VolumesV2CloneTest):
_api_version = 1
diff --git a/tempest/api/volume/test_volumes_clone_negative.py b/tempest/api/volume/test_volumes_clone_negative.py
index d1bedb4..5c54e1e 100644
--- a/tempest/api/volume/test_volumes_clone_negative.py
+++ b/tempest/api/volume/test_volumes_clone_negative.py
@@ -22,11 +22,11 @@
CONF = config.CONF
-class VolumesCloneTest(base.BaseVolumeTest):
+class VolumesV2CloneNegativeTest(base.BaseVolumeTest):
@classmethod
def skip_checks(cls):
- super(VolumesCloneTest, cls).skip_checks()
+ super(VolumesV2CloneNegativeTest, cls).skip_checks()
if not CONF.volume_feature_enabled.clone:
raise cls.skipException("Cinder volume clones are disabled")
@@ -44,5 +44,5 @@
source_volid=src_vol['id'])
-class VolumesV1CloneTest(VolumesCloneTest):
+class VolumesV1CloneNegativeTest(VolumesV2CloneNegativeTest):
_api_version = 1
diff --git a/tempest/api/volume/test_volumes_extend.py b/tempest/api/volume/test_volumes_extend.py
index 7aea1c4..c3d6dbb 100644
--- a/tempest/api/volume/test_volumes_extend.py
+++ b/tempest/api/volume/test_volumes_extend.py
@@ -20,20 +20,16 @@
class VolumesV2ExtendTest(base.BaseVolumeTest):
- @classmethod
- def setup_clients(cls):
- super(VolumesV2ExtendTest, cls).setup_clients()
- cls.client = cls.volumes_client
-
@test.idempotent_id('9a36df71-a257-43a5-9555-dc7c88e66e0e')
def test_volume_extend(self):
# Extend Volume Test.
self.volume = self.create_volume()
extend_size = int(self.volume['size']) + 1
- self.client.extend_volume(self.volume['id'], new_size=extend_size)
- waiters.wait_for_volume_status(self.client,
+ self.volumes_client.extend_volume(self.volume['id'],
+ new_size=extend_size)
+ waiters.wait_for_volume_status(self.volumes_client,
self.volume['id'], 'available')
- volume = self.client.show_volume(self.volume['id'])['volume']
+ volume = self.volumes_client.show_volume(self.volume['id'])['volume']
self.assertEqual(int(volume['size']), extend_size)
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 51de2be..7507ce6 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -28,11 +28,6 @@
class VolumesV2GetTest(base.BaseVolumeTest):
@classmethod
- def setup_clients(cls):
- super(VolumesV2GetTest, cls).setup_clients()
- cls.client = cls.volumes_client
-
- @classmethod
def resource_setup(cls):
super(VolumesV2GetTest, cls).resource_setup()
@@ -46,10 +41,11 @@
# Create a volume
kwargs[self.name_field] = v_name
kwargs['metadata'] = metadata
- volume = self.client.create_volume(**kwargs)['volume']
+ volume = self.volumes_client.create_volume(**kwargs)['volume']
self.assertIn('id', volume)
- self.addCleanup(self.delete_volume, self.client, volume['id'])
- waiters.wait_for_volume_status(self.client, volume['id'], 'available')
+ self.addCleanup(self.delete_volume, self.volumes_client, volume['id'])
+ waiters.wait_for_volume_status(self.volumes_client, volume['id'],
+ 'available')
self.assertIn(self.name_field, volume)
self.assertEqual(volume[self.name_field], v_name,
"The created volume name is not equal "
@@ -57,7 +53,8 @@
self.assertIsNotNone(volume['id'],
"Field volume id is empty or not found.")
# Get Volume information
- fetched_volume = self.client.show_volume(volume['id'])['volume']
+ fetched_volume = self.volumes_client.show_volume(
+ volume['id'])['volume']
self.assertEqual(v_name,
fetched_volume[self.name_field],
'The fetched Volume name is different '
@@ -79,20 +76,21 @@
# Update Volume
# Test volume update when display_name is same with original value
params = {self.name_field: v_name}
- self.client.update_volume(volume['id'], **params)
+ self.volumes_client.update_volume(volume['id'], **params)
# Test volume update when display_name is new
new_v_name = data_utils.rand_name(
self.__class__.__name__ + '-new-Volume')
new_desc = 'This is the new description of volume'
params = {self.name_field: new_v_name,
self.descrip_field: new_desc}
- update_volume = self.client.update_volume(
+ update_volume = self.volumes_client.update_volume(
volume['id'], **params)['volume']
# Assert response body for update_volume method
self.assertEqual(new_v_name, update_volume[self.name_field])
self.assertEqual(new_desc, update_volume[self.descrip_field])
# Assert response body for show_volume method
- updated_volume = self.client.show_volume(volume['id'])['volume']
+ updated_volume = self.volumes_client.show_volume(
+ volume['id'])['volume']
self.assertEqual(volume['id'], updated_volume['id'])
self.assertEqual(new_v_name, updated_volume[self.name_field])
self.assertEqual(new_desc, updated_volume[self.descrip_field])
@@ -107,15 +105,16 @@
params = {self.descrip_field: new_v_desc,
'availability_zone': volume['availability_zone'],
'size': CONF.volume.volume_size}
- new_volume = self.client.create_volume(**params)['volume']
+ new_volume = self.volumes_client.create_volume(**params)['volume']
self.assertIn('id', new_volume)
- self.addCleanup(self.delete_volume, self.client, new_volume['id'])
- waiters.wait_for_volume_status(self.client,
+ self.addCleanup(self.delete_volume, self.volumes_client,
+ new_volume['id'])
+ waiters.wait_for_volume_status(self.volumes_client,
new_volume['id'], 'available')
params = {self.name_field: volume[self.name_field],
self.descrip_field: volume[self.descrip_field]}
- self.client.update_volume(new_volume['id'], **params)
+ self.volumes_client.update_volume(new_volume['id'], **params)
if 'imageRef' in kwargs:
self.assertEqual('true', updated_volume['bootable'])
diff --git a/tempest/api/volume/test_volumes_list.py b/tempest/api/volume/test_volumes_list.py
index 40793ec..030ea6c 100644
--- a/tempest/api/volume/test_volumes_list.py
+++ b/tempest/api/volume/test_volumes_list.py
@@ -55,11 +55,6 @@
[str_vol(v) for v in fetched_list]))
@classmethod
- def setup_clients(cls):
- super(VolumesV2ListTestJSON, cls).setup_clients()
- cls.client = cls.volumes_client
-
- @classmethod
def resource_setup(cls):
super(VolumesV2ListTestJSON, cls).resource_setup()
cls.name = cls.VOLUME_FIELDS[1]
@@ -68,16 +63,17 @@
cls.metadata = {'Type': 'work'}
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
- volume = cls.client.show_volume(volume['id'])['volume']
+ volume = cls.volumes_client.show_volume(volume['id'])['volume']
cls.volume_list.append(volume)
def _list_by_param_value_and_assert(self, params, with_detail=False):
"""list or list_details with given params and validates result"""
if with_detail:
fetched_vol_list = \
- self.client.list_volumes(detail=True, params=params)['volumes']
+ self.volumes_client.list_volumes(detail=True,
+ params=params)['volumes']
else:
- fetched_vol_list = self.client.list_volumes(
+ fetched_vol_list = self.volumes_client.list_volumes(
params=params)['volumes']
# Validating params of fetched volumes
@@ -103,7 +99,7 @@
def test_volume_list(self):
# Get a list of Volumes
# Fetch all volumes
- fetched_list = self.client.list_volumes()['volumes']
+ fetched_list = self.volumes_client.list_volumes()['volumes']
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -111,14 +107,15 @@
def test_volume_list_with_details(self):
# Get a list of Volumes with details
# Fetch all Volumes
- fetched_list = self.client.list_volumes(detail=True)['volumes']
+ fetched_list = self.volumes_client.list_volumes(detail=True)['volumes']
self.assertVolumesIn(fetched_list, self.volume_list)
@test.idempotent_id('a28e8da4-0b56-472f-87a8-0f4d3f819c02')
def test_volume_list_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
- fetched_vol = self.client.list_volumes(params=params)['volumes']
+ fetched_vol = self.volumes_client.list_volumes(
+ params=params)['volumes']
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
volume[self.name])
@@ -127,7 +124,7 @@
def test_volume_list_details_by_name(self):
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
params = {self.name: volume[self.name]}
- fetched_vol = self.client.list_volumes(
+ fetched_vol = self.volumes_client.list_volumes(
detail=True, params=params)['volumes']
self.assertEqual(1, len(fetched_vol), str(fetched_vol))
self.assertEqual(fetched_vol[0][self.name],
@@ -136,7 +133,8 @@
@test.idempotent_id('39654e13-734c-4dab-95ce-7613bf8407ce')
def test_volumes_list_by_status(self):
params = {'status': 'available'}
- fetched_list = self.client.list_volumes(params=params)['volumes']
+ fetched_list = self.volumes_client.list_volumes(
+ params=params)['volumes']
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -144,7 +142,7 @@
@test.idempotent_id('2943f712-71ec-482a-bf49-d5ca06216b9f')
def test_volumes_list_details_by_status(self):
params = {'status': 'available'}
- fetched_list = self.client.list_volumes(
+ fetched_list = self.volumes_client.list_volumes(
detail=True, params=params)['volumes']
for volume in fetched_list:
self.assertEqual('available', volume['status'])
@@ -158,7 +156,8 @@
in volume_list are not a bootable volume.
"""
params = {'bootable': 'false'}
- fetched_list = self.client.list_volumes(params=params)['volumes']
+ fetched_list = self.volumes_client.list_volumes(
+ params=params)['volumes']
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -166,7 +165,7 @@
@test.idempotent_id('2016a939-72ec-482a-bf49-d5ca06216b9f')
def test_volumes_list_details_by_bootable(self):
params = {'bootable': 'false'}
- fetched_list = self.client.list_volumes(
+ fetched_list = self.volumes_client.list_volumes(
detail=True, params=params)['volumes']
for volume in fetched_list:
self.assertEqual('false', volume['bootable'])
@@ -177,7 +176,8 @@
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
- fetched_list = self.client.list_volumes(params=params)['volumes']
+ fetched_list = self.volumes_client.list_volumes(
+ params=params)['volumes']
self._list_by_param_value_and_assert(params)
self.assertVolumesIn(fetched_list, self.volume_list,
fields=self.VOLUME_FIELDS)
@@ -187,7 +187,7 @@
volume = self.volume_list[data_utils.rand_int_id(0, 2)]
zone = volume['availability_zone']
params = {'availability_zone': zone}
- fetched_list = self.client.list_volumes(
+ fetched_list = self.volumes_client.list_volumes(
detail=True, params=params)['volumes']
for volume in fetched_list:
self.assertEqual(zone, volume['availability_zone'])
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 6ed6b9c..c45ace6 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -22,11 +22,6 @@
class VolumesV2NegativeTest(base.BaseVolumeTest):
@classmethod
- def setup_clients(cls):
- super(VolumesV2NegativeTest, cls).setup_clients()
- cls.client = cls.volumes_client
-
- @classmethod
def resource_setup(cls):
super(VolumesV2NegativeTest, cls).resource_setup()
@@ -40,14 +35,14 @@
@test.idempotent_id('f131c586-9448-44a4-a8b0-54ca838aa43e')
def test_volume_get_nonexistent_volume_id(self):
# Should not be able to get a non-existent volume
- self.assertRaises(lib_exc.NotFound, self.client.show_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume,
data_utils.rand_uuid())
@test.attr(type=['negative'])
@test.idempotent_id('555efa6e-efcd-44ef-8a3b-4a7ca4837a29')
def test_volume_delete_nonexistent_volume_id(self):
# Should not be able to delete a non-existent Volume
- self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
data_utils.rand_uuid())
@test.attr(type=['negative'])
@@ -57,7 +52,8 @@
# in request
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.create_volume,
size='#$%', display_name=v_name, metadata=metadata)
@test.attr(type=['negative'])
@@ -67,7 +63,8 @@
# in request
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.create_volume,
size='', display_name=v_name, metadata=metadata)
@test.attr(type=['negative'])
@@ -76,7 +73,8 @@
# Should not be able to create volume with size zero
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.create_volume,
size='0', display_name=v_name, metadata=metadata)
@test.attr(type=['negative'])
@@ -85,7 +83,8 @@
# Should not be able to create volume with size negative
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.BadRequest, self.client.create_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.create_volume,
size='-1', display_name=v_name, metadata=metadata)
@test.attr(type=['negative'])
@@ -94,7 +93,7 @@
# Should not be able to create volume with non-existent volume type
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.NotFound, self.client.create_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size='1', volume_type=data_utils.rand_uuid(),
display_name=v_name, metadata=metadata)
@@ -104,7 +103,7 @@
# Should not be able to create volume with non-existent snapshot
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.NotFound, self.client.create_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size='1', snapshot_id=data_utils.rand_uuid(),
display_name=v_name, metadata=metadata)
@@ -114,7 +113,7 @@
# Should not be able to create volume with non-existent source volume
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.NotFound, self.client.create_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,
size='1', source_volid=data_utils.rand_uuid(),
display_name=v_name, metadata=metadata)
@@ -123,7 +122,7 @@
def test_update_volume_with_nonexistent_volume_id(self):
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.NotFound, self.client.update_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
volume_id=data_utils.rand_uuid(),
display_name=v_name,
metadata=metadata)
@@ -133,7 +132,7 @@
def test_update_volume_with_invalid_volume_id(self):
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.NotFound, self.client.update_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
volume_id='#$%%&^&^', display_name=v_name,
metadata=metadata)
@@ -142,7 +141,7 @@
def test_update_volume_with_empty_volume_id(self):
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
metadata = {'Type': 'work'}
- self.assertRaises(lib_exc.NotFound, self.client.update_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.update_volume,
volume_id='', display_name=v_name,
metadata=metadata)
@@ -150,27 +149,29 @@
@test.idempotent_id('30799cfd-7ee4-446c-b66c-45b383ed211b')
def test_get_invalid_volume_id(self):
# Should not be able to get volume with invalid id
- self.assertRaises(lib_exc.NotFound, self.client.show_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.show_volume,
'#$%%&^&^')
@test.attr(type=['negative'])
@test.idempotent_id('c6c3db06-29ad-4e91-beb0-2ab195fe49e3')
def test_get_volume_without_passing_volume_id(self):
# Should not be able to get volume when empty ID is passed
- self.assertRaises(lib_exc.NotFound, self.client.show_volume, '')
+ self.assertRaises(lib_exc.NotFound,
+ self.volumes_client.show_volume, '')
@test.attr(type=['negative'])
@test.idempotent_id('1f035827-7c32-4019-9240-b4ec2dbd9dfd')
def test_delete_invalid_volume_id(self):
# Should not be able to delete volume when invalid ID is passed
- self.assertRaises(lib_exc.NotFound, self.client.delete_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.delete_volume,
'!@#$%^&*()')
@test.attr(type=['negative'])
@test.idempotent_id('441a1550-5d44-4b30-af0f-a6d402f52026')
def test_delete_volume_without_passing_volume_id(self):
# Should not be able to delete volume when empty ID is passed
- self.assertRaises(lib_exc.NotFound, self.client.delete_volume, '')
+ self.assertRaises(lib_exc.NotFound,
+ self.volumes_client.delete_volume, '')
@test.attr(type=['negative'])
@test.idempotent_id('f5e56b0a-5d02-43c1-a2a7-c9b792c2e3f6')
@@ -179,7 +180,7 @@
server = self.create_server(wait_until='ACTIVE')
self.assertRaises(lib_exc.NotFound,
- self.client.attach_volume,
+ self.volumes_client.attach_volume,
data_utils.rand_uuid(),
instance_uuid=server['id'],
mountpoint=self.mountpoint)
@@ -188,7 +189,7 @@
@test.idempotent_id('9f9c24e4-011d-46b5-b992-952140ce237a')
def test_detach_volumes_with_invalid_volume_id(self):
self.assertRaises(lib_exc.NotFound,
- self.client.detach_volume,
+ self.volumes_client.detach_volume,
'xxx')
@test.attr(type=['negative'])
@@ -196,7 +197,8 @@
def test_volume_extend_with_size_smaller_than_original_size(self):
# Extend volume with smaller size than original size.
extend_size = 0
- self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.extend_volume,
self.volume['id'], new_size=extend_size)
@test.attr(type=['negative'])
@@ -204,7 +206,8 @@
def test_volume_extend_with_non_number_size(self):
# Extend volume when size is non number.
extend_size = 'abc'
- self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.extend_volume,
self.volume['id'], new_size=extend_size)
@test.attr(type=['negative'])
@@ -212,7 +215,8 @@
def test_volume_extend_with_None_size(self):
# Extend volume with None size.
extend_size = None
- self.assertRaises(lib_exc.BadRequest, self.client.extend_volume,
+ self.assertRaises(lib_exc.BadRequest,
+ self.volumes_client.extend_volume,
self.volume['id'], new_size=extend_size)
@test.attr(type=['negative'])
@@ -220,7 +224,7 @@
def test_volume_extend_with_nonexistent_volume_id(self):
# Extend volume size when volume is nonexistent.
extend_size = int(self.volume['size']) + 1
- self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
data_utils.rand_uuid(), new_size=extend_size)
@test.attr(type=['negative'])
@@ -228,41 +232,42 @@
def test_volume_extend_without_passing_volume_id(self):
# Extend volume size when passing volume id is None.
extend_size = int(self.volume['size']) + 1
- self.assertRaises(lib_exc.NotFound, self.client.extend_volume,
+ self.assertRaises(lib_exc.NotFound, self.volumes_client.extend_volume,
None, new_size=extend_size)
@test.attr(type=['negative'])
@test.idempotent_id('ac6084c0-0546-45f9-b284-38a367e0e0e2')
def test_reserve_volume_with_nonexistent_volume_id(self):
self.assertRaises(lib_exc.NotFound,
- self.client.reserve_volume,
+ self.volumes_client.reserve_volume,
data_utils.rand_uuid())
@test.attr(type=['negative'])
@test.idempotent_id('eb467654-3dc1-4a72-9b46-47c29d22654c')
def test_unreserve_volume_with_nonexistent_volume_id(self):
self.assertRaises(lib_exc.NotFound,
- self.client.unreserve_volume,
+ self.volumes_client.unreserve_volume,
data_utils.rand_uuid())
@test.attr(type=['negative'])
@test.idempotent_id('449c4ed2-ecdd-47bb-98dc-072aeccf158c')
def test_reserve_volume_with_negative_volume_status(self):
# Mark volume as reserved.
- self.client.reserve_volume(self.volume['id'])
+ self.volumes_client.reserve_volume(self.volume['id'])
# Mark volume which is marked as reserved before
self.assertRaises(lib_exc.BadRequest,
- self.client.reserve_volume,
+ self.volumes_client.reserve_volume,
self.volume['id'])
# Unmark volume as reserved.
- self.client.unreserve_volume(self.volume['id'])
+ self.volumes_client.unreserve_volume(self.volume['id'])
@test.attr(type=['negative'])
@test.idempotent_id('0f4aa809-8c7b-418f-8fb3-84c7a5dfc52f')
def test_list_volumes_with_nonexistent_name(self):
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
params = {self.name_field: v_name}
- fetched_volume = self.client.list_volumes(params=params)['volumes']
+ fetched_volume = self.volumes_client.list_volumes(
+ params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative'])
@@ -271,14 +276,16 @@
v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
params = {self.name_field: v_name}
fetched_volume = \
- self.client.list_volumes(detail=True, params=params)['volumes']
+ self.volumes_client.list_volumes(
+ detail=True, params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative'])
@test.idempotent_id('143b279b-7522-466b-81be-34a87d564a7c')
def test_list_volumes_with_invalid_status(self):
params = {'status': 'null'}
- fetched_volume = self.client.list_volumes(params=params)['volumes']
+ fetched_volume = self.volumes_client.list_volumes(
+ params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
@test.attr(type=['negative'])
@@ -286,7 +293,8 @@
def test_list_volumes_detail_with_invalid_status(self):
params = {'status': 'null'}
fetched_volume = \
- self.client.list_volumes(detail=True, params=params)['volumes']
+ self.volumes_client.list_volumes(detail=True,
+ params=params)['volumes']
self.assertEqual(0, len(fetched_volume))
diff --git a/tempest/api/volume/v2/test_volumes_list.py b/tempest/api/volume/v2/test_volumes_list.py
index 03996af..fb8c65d 100644
--- a/tempest/api/volume/v2/test_volumes_list.py
+++ b/tempest/api/volume/v2/test_volumes_list.py
@@ -33,11 +33,6 @@
"""
@classmethod
- def setup_clients(cls):
- super(VolumesV2ListTestJSON, cls).setup_clients()
- cls.client = cls.volumes_client
-
- @classmethod
def resource_setup(cls):
super(VolumesV2ListTestJSON, cls).resource_setup()
@@ -45,7 +40,7 @@
cls.metadata = {'Type': 'work'}
# NOTE(zhufl): When using pre-provisioned credentials, the project
# may have volumes other than those created below.
- existing_volumes = cls.client.list_volumes()['volumes']
+ existing_volumes = cls.volumes_client.list_volumes()['volumes']
cls.volume_id_list = [vol['id'] for vol in existing_volumes]
for i in range(3):
volume = cls.create_volume(metadata=cls.metadata)
@@ -63,7 +58,7 @@
'sort_dir': sort_dir,
'sort_key': sort_key
}
- fetched_volume = self.client.list_volumes(
+ fetched_volume = self.volumes_client.list_volumes(
detail=True, params=params)['volumes']
self.assertEqual(limit, len(fetched_volume),
"The count of volumes is %s, expected:%s " %
@@ -192,8 +187,8 @@
params = {'marker': random_volume}
# Running volume list using marker parameter
- vol_with_marker = self.client.list_volumes(detail=True,
- params=params)['volumes']
+ vol_with_marker = self.volumes_client.list_volumes(
+ detail=True, params=params)['volumes']
# Fetching the index of the random volume from volume_id_list
index_marker = self.volume_id_list.index(random_volume)
diff --git a/tempest/clients.py b/tempest/clients.py
index 53f3775..b3290ac 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -25,7 +25,6 @@
from tempest.services import identity
from tempest.services import object_storage
from tempest.services import orchestration
-from tempest.services import volume
CONF = config.CONF
LOG = logging.getLogger(__name__)
@@ -275,8 +274,6 @@
raise lib_exc.InvalidConfiguration(msg)
def _set_volume_clients(self):
- # Mandatory parameters (always defined)
- params = self.parameters['volume']
self.volume_qos_client = self.volume_v1.QosSpecsClient()
self.volume_qos_v2_client = self.volume_v2.QosSpecsClient()
@@ -291,8 +288,7 @@
self.snapshots_v2_client = self.volume_v2.SnapshotsClient()
self.volumes_client = self.volume_v1.VolumesClient()
self.volumes_v2_client = self.volume_v2.VolumesClient()
- self.volume_v3_messages_client = volume.v3.MessagesClient(
- self.auth_provider, **params)
+ self.volume_v3_messages_client = self.volume_v3.MessagesClient()
self.volume_types_client = self.volume_v1.TypesClient()
self.volume_types_v2_client = self.volume_v2.TypesClient()
self.volume_hosts_client = self.volume_v1.HostsClient()
diff --git a/tempest/config.py b/tempest/config.py
index 70ede55..7550287 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -278,6 +278,11 @@
'be utilized by some multinode specific tests to ensure '
'that requests match the expected size of the cluster '
'you are testing with.')),
+ cfg.StrOpt('hypervisor_type',
+ default=None,
+ help="Hypervisor type of the test target on heterogeneous "
+ "compute environment. The value can be 'QEMU', 'xen' or "
+ "something."),
cfg.StrOpt('min_microversion',
default=None,
help="Lower version of the test target microversion range. "
diff --git a/tempest/lib/cli/base.py b/tempest/lib/cli/base.py
index a43d002..72a15b5 100644
--- a/tempest/lib/cli/base.py
+++ b/tempest/lib/cli/base.py
@@ -29,7 +29,7 @@
def execute(cmd, action, flags='', params='', fail_ok=False,
- merge_stderr=False, cli_dir='/usr/bin'):
+ merge_stderr=False, cli_dir='/usr/bin', prefix=''):
"""Executes specified command for the given action.
:param cmd: command to be executed
@@ -48,9 +48,12 @@
:type merge_stderr: boolean
:param cli_dir: The path where the cmd can be executed
:type cli_dir: string
+ :param prefix: prefix to insert before command
+ :type prefix: string
"""
- cmd = ' '.join([os.path.join(cli_dir, cmd),
+ cmd = ' '.join([prefix, os.path.join(cli_dir, cmd),
flags, action, params])
+ cmd = cmd.strip()
LOG.info("running: '%s'" % cmd)
if six.PY2:
cmd = cmd.encode('utf-8')
@@ -88,10 +91,12 @@
:type cli_dir: string
:param insecure: if True, --insecure is passed to python client binaries.
:type insecure: boolean
+ :param prefix: prefix to insert before commands
+ :type prefix: string
"""
def __init__(self, username='', password='', tenant_name='', uri='',
- cli_dir='', insecure=False, *args, **kwargs):
+ cli_dir='', insecure=False, prefix='', *args, **kwargs):
"""Initialize a new CLIClient object."""
super(CLIClient, self).__init__()
self.cli_dir = cli_dir if cli_dir else '/usr/bin'
@@ -100,6 +105,7 @@
self.password = password
self.uri = uri
self.insecure = insecure
+ self.prefix = prefix
def nova(self, action, flags='', params='', fail_ok=False,
endpoint_type='publicURL', merge_stderr=False):
@@ -365,7 +371,7 @@
else:
flags = creds + ' ' + flags
return execute(cmd, action, flags, params, fail_ok, merge_stderr,
- self.cli_dir)
+ self.cli_dir, prefix=self.prefix)
class ClientTestBase(base.BaseTestCase):
diff --git a/tempest/lib/services/clients.py b/tempest/lib/services/clients.py
index 9e58872..0e8e3c6 100644
--- a/tempest/lib/services/clients.py
+++ b/tempest/lib/services/clients.py
@@ -45,7 +45,8 @@
'image.v2': image.v2,
'network': network,
'volume.v1': volume.v1,
- 'volume.v2': volume.v2
+ 'volume.v2': volume.v2,
+ 'volume.v3': volume.v3
}
@@ -54,7 +55,7 @@
# NOTE(andreaf) This list will exists only as long the remain clients
# are migrated to tempest.lib, and it will then be deleted without
# deprecation or advance notice
- return set(['identity.v3', 'object-storage', 'volume.v3'])
+ return set(['identity.v3', 'object-storage'])
def available_modules():
diff --git a/tempest/lib/services/identity/v3/role_assignments_client.py b/tempest/lib/services/identity/v3/role_assignments_client.py
index c2dc3eb..10de03f 100644
--- a/tempest/lib/services/identity/v3/role_assignments_client.py
+++ b/tempest/lib/services/identity/v3/role_assignments_client.py
@@ -29,7 +29,8 @@
http://developer.openstack.org/api-ref/identity/v3/?expanded=list-effective-role-assignments-detail
:param effective: If True, returns the effective assignments, including
- any assignments gained by virtue of group membership.
+ any assignments gained by virtue of group membership
+ or inherited roles.
"""
url = 'role_assignments'
if kwargs:
diff --git a/tempest/lib/services/volume/__init__.py b/tempest/lib/services/volume/__init__.py
index 11da06c..6855d8e 100644
--- a/tempest/lib/services/volume/__init__.py
+++ b/tempest/lib/services/volume/__init__.py
@@ -14,5 +14,6 @@
from tempest.lib.services.volume import v1
from tempest.lib.services.volume import v2
+from tempest.lib.services.volume import v3
-__all__ = ['v1', 'v2']
+__all__ = ['v1', 'v2', 'v3']
diff --git a/tempest/services/volume/__init__.py b/tempest/lib/services/volume/v3/__init__.py
similarity index 77%
rename from tempest/services/volume/__init__.py
rename to tempest/lib/services/volume/v3/__init__.py
index c62dd53..a4600a8 100644
--- a/tempest/services/volume/__init__.py
+++ b/tempest/lib/services/volume/v3/__init__.py
@@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations under
# the License.
-from tempest.services.volume import v3
+from tempest.lib.services.volume.v3.base_client import BaseClient
+from tempest.lib.services.volume.v3.messages_client import MessagesClient
-__all__ = ['v3']
+__all__ = ['MessagesClient', 'BaseClient']
diff --git a/tempest/services/volume/base/base_v3_client.py b/tempest/lib/services/volume/v3/base_client.py
similarity index 90%
rename from tempest/services/volume/base/base_v3_client.py
rename to tempest/lib/services/volume/v3/base_client.py
index ad6f760..958212a 100644
--- a/tempest/services/volume/base/base_v3_client.py
+++ b/tempest/lib/services/volume/v3/base_client.py
@@ -19,13 +19,13 @@
VOLUME_MICROVERSION = None
-class BaseV3Client(rest_client.RestClient):
+class BaseClient(rest_client.RestClient):
"""Base class to handle Cinder v3 client microversion support."""
api_version = 'v3'
api_microversion_header_name = 'Openstack-Api-Version'
def get_headers(self, accept_type=None, send_type=None):
- headers = super(BaseV3Client, self).get_headers(
+ headers = super(BaseClient, self).get_headers(
accept_type=accept_type, send_type=send_type)
if VOLUME_MICROVERSION:
headers[self.api_microversion_header_name] = ('volume %s' %
@@ -35,7 +35,7 @@
def request(self, method, url, extra_headers=False, headers=None,
body=None, chunked=False):
- resp, resp_body = super(BaseV3Client, self).request(
+ resp, resp_body = super(BaseClient, self).request(
method, url, extra_headers, headers, body, chunked)
if (VOLUME_MICROVERSION and
VOLUME_MICROVERSION != api_version_utils.LATEST_MICROVERSION):
diff --git a/tempest/services/volume/v3/json/messages_client.py b/tempest/lib/services/volume/v3/messages_client.py
similarity index 94%
rename from tempest/services/volume/v3/json/messages_client.py
rename to tempest/lib/services/volume/v3/messages_client.py
index 6be6d59..8a01864 100644
--- a/tempest/services/volume/v3/json/messages_client.py
+++ b/tempest/lib/services/volume/v3/messages_client.py
@@ -17,10 +17,10 @@
from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc
-from tempest.services.volume.base import base_v3_client
+from tempest.lib.services.volume.v3 import base_client
-class MessagesClient(base_v3_client.BaseV3Client):
+class MessagesClient(base_client.BaseClient):
"""Client class to send user messages API requests."""
def show_message(self, message_id):
diff --git a/tempest/services/volume/v3/__init__.py b/tempest/services/volume/v3/__init__.py
deleted file mode 100644
index d50098c..0000000
--- a/tempest/services/volume/v3/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (c) 2016 Hewlett-Packard Enterprise Development Company, L.P.
-#
-# 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 tempest.services.volume.v3.json.messages_client import MessagesClient
-
-__all__ = ['MessagesClient']
diff --git a/tempest/services/volume/v3/json/__init__.py b/tempest/services/volume/v3/json/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/tempest/services/volume/v3/json/__init__.py
+++ /dev/null
diff --git a/tempest/tests/lib/cli/test_execute.py b/tempest/tests/lib/cli/test_execute.py
index cc9c94c..aaeb6f4 100644
--- a/tempest/tests/lib/cli/test_execute.py
+++ b/tempest/tests/lib/cli/test_execute.py
@@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-
import mock
import subprocess
@@ -74,3 +73,20 @@
self.assertRaises(exceptions.CommandFailed, cli_base.execute,
"/bin/ls", action="tempest", flags="--foobar",
merge_stderr=True)
+
+ def test_execute_with_prefix(self):
+ result = cli_base.execute("env", action="",
+ prefix="env NEW_VAR=1")
+ self.assertIsInstance(result, str)
+ self.assertIn("NEW_VAR=1", result)
+
+
+class TestCLIClient(base.TestCase):
+
+ @mock.patch.object(cli_base, 'execute')
+ def test_execute_with_prefix(self, mock_execute):
+ cli = cli_base.CLIClient(prefix='env LAC_ALL=C')
+ cli.glance('action')
+ self.assertEqual(mock_execute.call_count, 1)
+ self.assertEqual(mock_execute.call_args[1],
+ {'prefix': 'env LAC_ALL=C'})
diff --git a/tempest/services/volume/base/__init__.py b/tempest/tests/lib/services/volume/v3/__init__.py
similarity index 100%
rename from tempest/services/volume/base/__init__.py
rename to tempest/tests/lib/services/volume/v3/__init__.py
diff --git a/tempest/tests/lib/services/volume/v3/test_user_messages.py b/tempest/tests/lib/services/volume/v3/test_user_messages.py
new file mode 100644
index 0000000..4aeed5f
--- /dev/null
+++ b/tempest/tests/lib/services/volume/v3/test_user_messages.py
@@ -0,0 +1,92 @@
+# Copyright 2016 Red Hat. All rights reserved.
+#
+# 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 tempest.lib.services.volume.v3 import messages_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestUserMessagesClient(base.BaseServiceTest):
+ USER_MESSAGE_INFO = {
+ "created_at": "2016-11-21T06:16:34.000000",
+ "guaranteed_until": "2016-12-21T06:16:34.000000",
+ "user_message": "No storage could be allocated for this volume "
+ "request. You may be able to try another size or"
+ " volume type.",
+ "resource_uuid": "c570b406-bf0b-4067-9398-f0bb09a7d9d7",
+ "request_id": "req-8f68681e-9b6b-4009-b94c-ac0811595451",
+ "message_level": "ERROR",
+ "id": "9a7dafbd-a156-4540-8996-50e71b5dcadf",
+ "resource_type": "VOLUME",
+ "links": [
+ {"href": "http://192.168.100.230:8776/v3/"
+ "a678cb65f701462ea2257245cd640829/messages/"
+ "9a7dafbd-a156-4540-8996-50e71b5dcadf",
+ "rel": "self"},
+ {"href": "http://192.168.100.230:8776/"
+ "a678cb65f701462ea2257245cd640829/messages/"
+ "9a7dafbd-a156-4540-8996-50e71b5dcadf",
+ "rel": "bookmark"}]
+ }
+ FAKE_SHOW_USER_MESSAGE = {
+ "message": dict(event_id="000002", **USER_MESSAGE_INFO)}
+
+ FAKE_LIST_USER_MESSAGES = {
+ "messages": [
+ dict(event_id="000003", **USER_MESSAGE_INFO),
+ dict(event_id="000004", **USER_MESSAGE_INFO)
+ ]
+ }
+
+ def setUp(self):
+ super(TestUserMessagesClient, self).setUp()
+ fake_auth = fake_auth_provider.FakeAuthProvider()
+ self.client = messages_client.MessagesClient(fake_auth,
+ 'volume',
+ 'regionOne')
+
+ def _test_show_user_message(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.show_message,
+ 'tempest.lib.common.rest_client.RestClient.get',
+ self.FAKE_SHOW_USER_MESSAGE,
+ bytes_body,
+ message_id="9a7dafbd-a156-4540-8996-50e71b5dcadf")
+
+ def _test_list_user_message(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.list_messages,
+ 'tempest.lib.common.rest_client.RestClient.get',
+ self.FAKE_LIST_USER_MESSAGES,
+ bytes_body)
+
+ def test_list_user_message_with_str_body(self):
+ self._test_list_user_message()
+
+ def test_list_user_message_with_bytes_body(self):
+ self._test_list_user_message(bytes_body=True)
+
+ def test_show_user_message_with_str_body(self):
+ self._test_show_user_message()
+
+ def test_show_user_message_with_bytes_body(self):
+ self._test_show_user_message(bytes_body=True)
+
+ def test_delete_user_message(self):
+ self.check_service_client_function(
+ self.client.delete_message,
+ 'tempest.lib.common.rest_client.RestClient.delete',
+ {},
+ message_id="9a7dafbd-a156-4540-8996-50e71b5dcadf",
+ status=204)