Add a generic "wait_for_volume_resource_status" function
This function waits for a volume resource to reach a given status. The function is a common function for volume, snapshot and backup resources. Change-Id: I070a9f84b8b199df22765391482f7d69a5414db3
This commit is contained in:
parent
9913cbbb4c
commit
52d7b0d626
@ -60,10 +60,10 @@ class TestVolumeSwap(base.BaseV2ComputeAdminTest):
|
|||||||
# Swap volume from "volume1" to "volume2"
|
# Swap volume from "volume1" to "volume2"
|
||||||
self.servers_admin_client.update_attached_volume(
|
self.servers_admin_client.update_attached_volume(
|
||||||
server['id'], volume1['id'], volumeId=volume2['id'])
|
server['id'], volume1['id'], volumeId=volume2['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume1['id'], 'available')
|
volume1['id'], 'available')
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume2['id'], 'in-use')
|
volume2['id'], 'in-use')
|
||||||
self.addCleanup(self.servers_client.detach_volume,
|
self.addCleanup(self.servers_client.detach_volume,
|
||||||
server['id'], volume2['id'])
|
server['id'], volume2['id'])
|
||||||
# Verify "volume2" is attached to the server
|
# Verify "volume2" is attached to the server
|
||||||
|
@ -406,8 +406,8 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest,
|
|||||||
kwargs['imageRef'] = image_ref
|
kwargs['imageRef'] = image_ref
|
||||||
volume = cls.volumes_client.create_volume(**kwargs)['volume']
|
volume = cls.volumes_client.create_volume(**kwargs)['volume']
|
||||||
cls.volumes.append(volume)
|
cls.volumes.append(volume)
|
||||||
waiters.wait_for_volume_status(cls.volumes_client,
|
waiters.wait_for_volume_resource_status(cls.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
return volume
|
return volume
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -446,15 +446,15 @@ class BaseV2ComputeTest(api_version_utils.BaseMicroversionTest,
|
|||||||
# On teardown detach the volume and wait for it to be available. This
|
# On teardown detach the volume and wait for it to be available. This
|
||||||
# is so we don't error out when trying to delete the volume during
|
# is so we don't error out when trying to delete the volume during
|
||||||
# teardown.
|
# teardown.
|
||||||
self.addCleanup(waiters.wait_for_volume_status,
|
self.addCleanup(waiters.wait_for_volume_resource_status,
|
||||||
self.volumes_client, volume['id'], 'available')
|
self.volumes_client, volume['id'], 'available')
|
||||||
# Ignore 404s on detach in case the server is deleted or the volume
|
# Ignore 404s on detach in case the server is deleted or the volume
|
||||||
# is already detached.
|
# is already detached.
|
||||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||||
self.servers_client.detach_volume,
|
self.servers_client.detach_volume,
|
||||||
server['id'], volume['id'])
|
server['id'], volume['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'in-use')
|
volume['id'], 'in-use')
|
||||||
|
|
||||||
|
|
||||||
class BaseV2ComputeAdminTest(BaseV2ComputeTest):
|
class BaseV2ComputeAdminTest(BaseV2ComputeTest):
|
||||||
|
@ -115,8 +115,8 @@ class DeleteServersTestJSON(base.BaseV2ComputeTest):
|
|||||||
|
|
||||||
self.client.delete_server(server['id'])
|
self.client.delete_server(server['id'])
|
||||||
waiters.wait_for_server_termination(self.client, server['id'])
|
waiters.wait_for_server_termination(self.client, server['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
|
|
||||||
|
|
||||||
class DeleteServersAdminTestJSON(base.BaseV2ComputeAdminTest):
|
class DeleteServersAdminTestJSON(base.BaseV2ComputeAdminTest):
|
||||||
|
@ -64,8 +64,8 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest):
|
|||||||
def _detach_volume(self, server_id, volume_id):
|
def _detach_volume(self, server_id, volume_id):
|
||||||
try:
|
try:
|
||||||
self.servers_client.detach_volume(server_id, volume_id)
|
self.servers_client.detach_volume(server_id, volume_id)
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume_id, 'available')
|
volume_id, 'available')
|
||||||
except lib_exc.NotFound:
|
except lib_exc.NotFound:
|
||||||
LOG.warning("Unable to detach volume %s from server %s "
|
LOG.warning("Unable to detach volume %s from server %s "
|
||||||
"possibly it was already detached", volume_id,
|
"possibly it was already detached", volume_id,
|
||||||
@ -78,8 +78,8 @@ class AttachVolumeTestJSON(base.BaseV2ComputeTest):
|
|||||||
kwargs.update({'device': '/dev/%s' % device})
|
kwargs.update({'device': '/dev/%s' % device})
|
||||||
attachment = self.servers_client.attach_volume(
|
attachment = self.servers_client.attach_volume(
|
||||||
server_id, **kwargs)['volumeAttachment']
|
server_id, **kwargs)['volumeAttachment']
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume_id, 'in-use')
|
volume_id, 'in-use')
|
||||||
self.addCleanup(self._detach_volume, server_id,
|
self.addCleanup(self._detach_volume, server_id,
|
||||||
volume_id)
|
volume_id)
|
||||||
|
|
||||||
|
@ -54,9 +54,9 @@ class VolumesSnapshotsTestJSON(base.BaseV2ComputeTest):
|
|||||||
display_name=s_name)['snapshot']
|
display_name=s_name)['snapshot']
|
||||||
|
|
||||||
def delete_snapshot(snapshot_id):
|
def delete_snapshot(snapshot_id):
|
||||||
waiters.wait_for_snapshot_status(self.snapshots_client,
|
waiters.wait_for_volume_resource_status(self.snapshots_client,
|
||||||
snapshot_id,
|
snapshot_id,
|
||||||
'available')
|
'available')
|
||||||
# Delete snapshot
|
# Delete snapshot
|
||||||
self.snapshots_client.delete_snapshot(snapshot_id)
|
self.snapshots_client.delete_snapshot(snapshot_id)
|
||||||
self.snapshots_client.wait_for_resource_deletion(snapshot_id)
|
self.snapshots_client.wait_for_resource_deletion(snapshot_id)
|
||||||
|
@ -57,7 +57,8 @@ class VolumesGetTestJSON(base.BaseV2ComputeTest):
|
|||||||
self.assertIsNotNone(volume['id'],
|
self.assertIsNotNone(volume['id'],
|
||||||
"Field volume id is empty or not found.")
|
"Field volume id is empty or not found.")
|
||||||
# Wait for Volume status to become ACTIVE
|
# Wait for Volume status to become ACTIVE
|
||||||
waiters.wait_for_volume_status(self.client, volume['id'], 'available')
|
waiters.wait_for_volume_resource_status(self.client, volume['id'],
|
||||||
|
'available')
|
||||||
# GET Volume
|
# GET Volume
|
||||||
fetched_volume = self.client.show_volume(volume['id'])['volume']
|
fetched_volume = self.client.show_volume(volume['id'])['volume']
|
||||||
# Verification of details of fetched Volume
|
# Verification of details of fetched Volume
|
||||||
|
@ -74,8 +74,8 @@ class VolumeMultiBackendV2Test(base.BaseVolumeAdminTest):
|
|||||||
else:
|
else:
|
||||||
cls.volume_id_list_without_prefix.append(
|
cls.volume_id_list_without_prefix.append(
|
||||||
cls.volume['id'])
|
cls.volume['id'])
|
||||||
waiters.wait_for_volume_status(cls.admin_volume_client,
|
waiters.wait_for_volume_resource_status(cls.admin_volume_client,
|
||||||
cls.volume['id'], 'available')
|
cls.volume['id'], 'available')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resource_cleanup(cls):
|
def resource_cleanup(cls):
|
||||||
|
@ -146,7 +146,7 @@ class BaseVolumeQuotasAdminV2TestJSON(base.BaseVolumeAdminTest):
|
|||||||
transfer_id, auth_key=auth_key)['transfer']
|
transfer_id, auth_key=auth_key)['transfer']
|
||||||
|
|
||||||
# Verify volume transferred is available
|
# Verify volume transferred is available
|
||||||
waiters.wait_for_volume_status(
|
waiters.wait_for_volume_resource_status(
|
||||||
self.alt_client, volume['id'], 'available')
|
self.alt_client, volume['id'], 'available')
|
||||||
|
|
||||||
# List of tenants quota usage post transfer
|
# List of tenants quota usage post transfer
|
||||||
|
@ -58,14 +58,14 @@ class VolumeTypesV2Test(base.BaseVolumeAdminTest):
|
|||||||
"to the requested name")
|
"to the requested name")
|
||||||
self.assertIsNotNone(volume['id'],
|
self.assertIsNotNone(volume['id'],
|
||||||
"Field volume id is empty or not found.")
|
"Field volume id is empty or not found.")
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
|
|
||||||
# Update volume with new volume_type
|
# Update volume with new volume_type
|
||||||
self.volumes_client.retype_volume(volume['id'],
|
self.volumes_client.retype_volume(volume['id'],
|
||||||
new_type=volume_types[1]['id'])
|
new_type=volume_types[1]['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
|
|
||||||
# Get volume details and Verify
|
# Get volume details and Verify
|
||||||
fetched_volume = self.volumes_client.show_volume(
|
fetched_volume = self.volumes_client.show_volume(
|
||||||
|
@ -94,8 +94,9 @@ class VolumesBackupsAdminV2Test(base.BaseVolumeAdminTest):
|
|||||||
self.addCleanup(self._delete_backup, new_id)
|
self.addCleanup(self._delete_backup, new_id)
|
||||||
self.assertIn("id", import_backup)
|
self.assertIn("id", import_backup)
|
||||||
self.assertEqual(new_id, import_backup['id'])
|
self.assertEqual(new_id, import_backup['id'])
|
||||||
waiters.wait_for_backup_status(self.admin_backups_client,
|
waiters.wait_for_volume_resource_status(self.admin_backups_client,
|
||||||
import_backup['id'], 'available')
|
import_backup['id'],
|
||||||
|
'available')
|
||||||
|
|
||||||
# Verify Import Backup
|
# Verify Import Backup
|
||||||
backups = self.admin_backups_client.list_backups(
|
backups = self.admin_backups_client.list_backups(
|
||||||
@ -108,14 +109,16 @@ class VolumesBackupsAdminV2Test(base.BaseVolumeAdminTest):
|
|||||||
self.addCleanup(self.admin_volume_client.delete_volume,
|
self.addCleanup(self.admin_volume_client.delete_volume,
|
||||||
restore['volume_id'])
|
restore['volume_id'])
|
||||||
self.assertEqual(backup['id'], restore['backup_id'])
|
self.assertEqual(backup['id'], restore['backup_id'])
|
||||||
waiters.wait_for_volume_status(self.admin_volume_client,
|
waiters.wait_for_volume_resource_status(self.admin_volume_client,
|
||||||
restore['volume_id'], 'available')
|
restore['volume_id'],
|
||||||
|
'available')
|
||||||
|
|
||||||
# Verify if restored volume is there in volume list
|
# Verify if restored volume is there in volume list
|
||||||
volumes = self.admin_volume_client.list_volumes()['volumes']
|
volumes = self.admin_volume_client.list_volumes()['volumes']
|
||||||
self.assertIn(restore['volume_id'], [v['id'] for v in volumes])
|
self.assertIn(restore['volume_id'], [v['id'] for v in volumes])
|
||||||
waiters.wait_for_backup_status(self.admin_backups_client,
|
waiters.wait_for_volume_resource_status(self.admin_backups_client,
|
||||||
import_backup['id'], 'available')
|
import_backup['id'],
|
||||||
|
'available')
|
||||||
|
|
||||||
@decorators.idempotent_id('47a35425-a891-4e13-961c-c45deea21e94')
|
@decorators.idempotent_id('47a35425-a891-4e13-961c-c45deea21e94')
|
||||||
def test_volume_backup_reset_status(self):
|
def test_volume_backup_reset_status(self):
|
||||||
@ -131,8 +134,8 @@ class VolumesBackupsAdminV2Test(base.BaseVolumeAdminTest):
|
|||||||
# Reset backup status to error
|
# Reset backup status to error
|
||||||
self.admin_backups_client.reset_backup_status(backup_id=backup['id'],
|
self.admin_backups_client.reset_backup_status(backup_id=backup['id'],
|
||||||
status="error")
|
status="error")
|
||||||
waiters.wait_for_backup_status(self.admin_backups_client,
|
waiters.wait_for_volume_resource_status(self.admin_backups_client,
|
||||||
backup['id'], 'error')
|
backup['id'], 'error')
|
||||||
|
|
||||||
|
|
||||||
class VolumesBackupsAdminV1Test(VolumesBackupsAdminV2Test):
|
class VolumesBackupsAdminV1Test(VolumesBackupsAdminV2Test):
|
||||||
|
@ -65,9 +65,9 @@ class SnapshotManageAdminV2Test(base.BaseVolumeAdminTest):
|
|||||||
self.admin_snapshots_client, new_snapshot['id'])
|
self.admin_snapshots_client, new_snapshot['id'])
|
||||||
|
|
||||||
# Wait for the snapshot to be available after manage operation
|
# Wait for the snapshot to be available after manage operation
|
||||||
waiters.wait_for_snapshot_status(self.admin_snapshots_client,
|
waiters.wait_for_volume_resource_status(self.admin_snapshots_client,
|
||||||
new_snapshot['id'],
|
new_snapshot['id'],
|
||||||
'available')
|
'available')
|
||||||
|
|
||||||
# Verify the managed snapshot has the expected parent volume
|
# Verify the managed snapshot has the expected parent volume
|
||||||
self.assertEqual(new_snapshot['volume_id'], volume['id'])
|
self.assertEqual(new_snapshot['volume_id'], volume['id'])
|
||||||
|
@ -45,8 +45,8 @@ class VolumesListAdminV2TestJSON(base.BaseVolumeAdminTest):
|
|||||||
# Create a volume in admin tenant
|
# Create a volume in admin tenant
|
||||||
adm_vol = self.admin_volume_client.create_volume(
|
adm_vol = self.admin_volume_client.create_volume(
|
||||||
size=CONF.volume.volume_size)['volume']
|
size=CONF.volume.volume_size)['volume']
|
||||||
waiters.wait_for_volume_status(self.admin_volume_client,
|
waiters.wait_for_volume_resource_status(self.admin_volume_client,
|
||||||
adm_vol['id'], 'available')
|
adm_vol['id'], 'available')
|
||||||
self.addCleanup(self.admin_volume_client.delete_volume, adm_vol['id'])
|
self.addCleanup(self.admin_volume_client.delete_volume, adm_vol['id'])
|
||||||
params = {'all_tenants': 1,
|
params = {'all_tenants': 1,
|
||||||
'project_id': self.volumes_client.tenant_id}
|
'project_id': self.volumes_client.tenant_id}
|
||||||
|
@ -131,8 +131,8 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
|
|||||||
|
|
||||||
volume = cls.volumes_client.create_volume(**kwargs)['volume']
|
volume = cls.volumes_client.create_volume(**kwargs)['volume']
|
||||||
cls.volumes.append(volume)
|
cls.volumes.append(volume)
|
||||||
waiters.wait_for_volume_status(cls.volumes_client, volume['id'],
|
waiters.wait_for_volume_resource_status(cls.volumes_client,
|
||||||
wait_until)
|
volume['id'], wait_until)
|
||||||
return volume
|
return volume
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -146,8 +146,8 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
|
|||||||
snapshot = cls.snapshots_client.create_snapshot(
|
snapshot = cls.snapshots_client.create_snapshot(
|
||||||
volume_id=volume_id, **kwargs)['snapshot']
|
volume_id=volume_id, **kwargs)['snapshot']
|
||||||
cls.snapshots.append(snapshot)
|
cls.snapshots.append(snapshot)
|
||||||
waiters.wait_for_snapshot_status(cls.snapshots_client,
|
waiters.wait_for_volume_resource_status(cls.snapshots_client,
|
||||||
snapshot['id'], 'available')
|
snapshot['id'], 'available')
|
||||||
return snapshot
|
return snapshot
|
||||||
|
|
||||||
def create_backup(self, volume_id, backup_client=None, **kwargs):
|
def create_backup(self, volume_id, backup_client=None, **kwargs):
|
||||||
@ -158,8 +158,8 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
|
|||||||
backup = backup_client.create_backup(
|
backup = backup_client.create_backup(
|
||||||
volume_id=volume_id, **kwargs)['backup']
|
volume_id=volume_id, **kwargs)['backup']
|
||||||
self.addCleanup(backup_client.delete_backup, backup['id'])
|
self.addCleanup(backup_client.delete_backup, backup['id'])
|
||||||
waiters.wait_for_backup_status(backup_client, backup['id'],
|
waiters.wait_for_volume_resource_status(backup_client, backup['id'],
|
||||||
'available')
|
'available')
|
||||||
return backup
|
return backup
|
||||||
|
|
||||||
# NOTE(afazekas): these create_* and clean_* could be defined
|
# NOTE(afazekas): these create_* and clean_* could be defined
|
||||||
@ -182,10 +182,10 @@ class BaseVolumeTest(tempest.test.BaseTestCase):
|
|||||||
self.servers_client.attach_volume(
|
self.servers_client.attach_volume(
|
||||||
server_id, volumeId=volume_id,
|
server_id, volumeId=volume_id,
|
||||||
device='/dev/%s' % CONF.compute.volume_device_name)
|
device='/dev/%s' % CONF.compute.volume_device_name)
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume_id, 'in-use')
|
volume_id, 'in-use')
|
||||||
self.addCleanup(waiters.wait_for_volume_status, self.volumes_client,
|
self.addCleanup(waiters.wait_for_volume_resource_status,
|
||||||
volume_id, 'available')
|
self.volumes_client, volume_id, 'available')
|
||||||
self.addCleanup(self.servers_client.detach_volume, server_id,
|
self.addCleanup(self.servers_client.detach_volume, server_id,
|
||||||
volume_id)
|
volume_id)
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ class VolumesV2TransfersTest(base.BaseVolumeTest):
|
|||||||
volume_id=volume['id'])['transfer']
|
volume_id=volume['id'])['transfer']
|
||||||
transfer_id = transfer['id']
|
transfer_id = transfer['id']
|
||||||
auth_key = transfer['auth_key']
|
auth_key = transfer['auth_key']
|
||||||
waiters.wait_for_volume_status(self.client,
|
waiters.wait_for_volume_resource_status(
|
||||||
volume['id'], 'awaiting-transfer')
|
self.client, volume['id'], 'awaiting-transfer')
|
||||||
|
|
||||||
# Get a volume transfer
|
# Get a volume transfer
|
||||||
body = self.client.show_volume_transfer(transfer_id)['transfer']
|
body = self.client.show_volume_transfer(transfer_id)['transfer']
|
||||||
@ -58,8 +58,8 @@ class VolumesV2TransfersTest(base.BaseVolumeTest):
|
|||||||
# Accept a volume transfer by alt_tenant
|
# Accept a volume transfer by alt_tenant
|
||||||
body = self.alt_client.accept_volume_transfer(
|
body = self.alt_client.accept_volume_transfer(
|
||||||
transfer_id, auth_key=auth_key)['transfer']
|
transfer_id, auth_key=auth_key)['transfer']
|
||||||
waiters.wait_for_volume_status(self.alt_client,
|
waiters.wait_for_volume_resource_status(self.alt_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
|
|
||||||
@decorators.idempotent_id('ab526943-b725-4c07-b875-8e8ef87a2c30')
|
@decorators.idempotent_id('ab526943-b725-4c07-b875-8e8ef87a2c30')
|
||||||
def test_create_list_delete_volume_transfer(self):
|
def test_create_list_delete_volume_transfer(self):
|
||||||
@ -71,8 +71,8 @@ class VolumesV2TransfersTest(base.BaseVolumeTest):
|
|||||||
body = self.client.create_volume_transfer(
|
body = self.client.create_volume_transfer(
|
||||||
volume_id=volume['id'])['transfer']
|
volume_id=volume['id'])['transfer']
|
||||||
transfer_id = body['id']
|
transfer_id = body['id']
|
||||||
waiters.wait_for_volume_status(self.client,
|
waiters.wait_for_volume_resource_status(
|
||||||
volume['id'], 'awaiting-transfer')
|
self.client, volume['id'], 'awaiting-transfer')
|
||||||
|
|
||||||
# List all volume transfers (looking for the one we created)
|
# List all volume transfers (looking for the one we created)
|
||||||
body = self.client.list_volume_transfers()['transfers']
|
body = self.client.list_volume_transfers()['transfers']
|
||||||
@ -84,7 +84,8 @@ class VolumesV2TransfersTest(base.BaseVolumeTest):
|
|||||||
|
|
||||||
# Delete a volume transfer
|
# Delete a volume transfer
|
||||||
self.client.delete_volume_transfer(transfer_id)
|
self.client.delete_volume_transfer(transfer_id)
|
||||||
waiters.wait_for_volume_status(self.client, volume['id'], 'available')
|
waiters.wait_for_volume_resource_status(
|
||||||
|
self.client, volume['id'], 'available')
|
||||||
|
|
||||||
|
|
||||||
class VolumesV1TransfersTest(VolumesV2TransfersTest):
|
class VolumesV1TransfersTest(VolumesV2TransfersTest):
|
||||||
|
@ -60,11 +60,11 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
|
|||||||
instance_uuid=server['id'],
|
instance_uuid=server['id'],
|
||||||
mountpoint='/dev/%s' %
|
mountpoint='/dev/%s' %
|
||||||
CONF.compute.volume_device_name)
|
CONF.compute.volume_device_name)
|
||||||
waiters.wait_for_volume_status(self.client,
|
waiters.wait_for_volume_resource_status(self.client,
|
||||||
self.volume['id'], 'in-use')
|
self.volume['id'], 'in-use')
|
||||||
self.client.detach_volume(self.volume['id'])
|
self.client.detach_volume(self.volume['id'])
|
||||||
waiters.wait_for_volume_status(self.client,
|
waiters.wait_for_volume_resource_status(self.client,
|
||||||
self.volume['id'], 'available')
|
self.volume['id'], 'available')
|
||||||
|
|
||||||
@decorators.idempotent_id('63e21b4c-0a0c-41f6-bfc3-7c2816815599')
|
@decorators.idempotent_id('63e21b4c-0a0c-41f6-bfc3-7c2816815599')
|
||||||
def test_volume_bootable(self):
|
def test_volume_bootable(self):
|
||||||
@ -91,11 +91,10 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
|
|||||||
instance_uuid=server['id'],
|
instance_uuid=server['id'],
|
||||||
mountpoint='/dev/%s' %
|
mountpoint='/dev/%s' %
|
||||||
CONF.compute.volume_device_name)
|
CONF.compute.volume_device_name)
|
||||||
waiters.wait_for_volume_status(self.client,
|
waiters.wait_for_volume_resource_status(self.client, self.volume['id'],
|
||||||
self.volume['id'], 'in-use')
|
'in-use')
|
||||||
self.addCleanup(waiters.wait_for_volume_status, self.client,
|
self.addCleanup(waiters.wait_for_volume_resource_status, self.client,
|
||||||
self.volume['id'],
|
self.volume['id'], 'available')
|
||||||
'available')
|
|
||||||
self.addCleanup(self.client.detach_volume, self.volume['id'])
|
self.addCleanup(self.client.detach_volume, self.volume['id'])
|
||||||
volume = self.client.show_volume(self.volume['id'])['volume']
|
volume = self.client.show_volume(self.volume['id'])['volume']
|
||||||
self.assertIn('attachments', volume)
|
self.assertIn('attachments', volume)
|
||||||
@ -124,8 +123,8 @@ class VolumesV2ActionsTest(base.BaseVolumeTest):
|
|||||||
self.image_client.delete_image,
|
self.image_client.delete_image,
|
||||||
image_id)
|
image_id)
|
||||||
waiters.wait_for_image_status(self.image_client, image_id, 'active')
|
waiters.wait_for_image_status(self.image_client, image_id, 'active')
|
||||||
waiters.wait_for_volume_status(self.client,
|
waiters.wait_for_volume_resource_status(self.client,
|
||||||
self.volume['id'], 'available')
|
self.volume['id'], 'available')
|
||||||
|
|
||||||
@decorators.idempotent_id('92c4ef64-51b2-40c0-9f7e-4749fbaaba33')
|
@decorators.idempotent_id('92c4ef64-51b2-40c0-9f7e-4749fbaaba33')
|
||||||
def test_reserve_unreserve_volume(self):
|
def test_reserve_unreserve_volume(self):
|
||||||
|
@ -40,11 +40,11 @@ class VolumesBackupsV2Test(base.BaseVolumeTest):
|
|||||||
self.addCleanup(self.volumes_client.delete_volume,
|
self.addCleanup(self.volumes_client.delete_volume,
|
||||||
restored_volume['volume_id'])
|
restored_volume['volume_id'])
|
||||||
self.assertEqual(backup_id, restored_volume['backup_id'])
|
self.assertEqual(backup_id, restored_volume['backup_id'])
|
||||||
waiters.wait_for_backup_status(self.backups_client,
|
waiters.wait_for_volume_resource_status(self.backups_client,
|
||||||
backup_id, 'available')
|
backup_id, 'available')
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
restored_volume['volume_id'],
|
restored_volume['volume_id'],
|
||||||
'available')
|
'available')
|
||||||
return restored_volume
|
return restored_volume
|
||||||
|
|
||||||
@decorators.idempotent_id('a66eb488-8ee1-47d4-8e9f-575a095728c6')
|
@decorators.idempotent_id('a66eb488-8ee1-47d4-8e9f-575a095728c6')
|
||||||
@ -60,8 +60,8 @@ class VolumesBackupsV2Test(base.BaseVolumeTest):
|
|||||||
name=backup_name,
|
name=backup_name,
|
||||||
description=description)
|
description=description)
|
||||||
self.assertEqual(backup_name, backup['name'])
|
self.assertEqual(backup_name, backup['name'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
|
|
||||||
# Get a given backup
|
# Get a given backup
|
||||||
backup = self.backups_client.show_backup(backup['id'])['backup']
|
backup = self.backups_client.show_backup(backup['id'])['backup']
|
||||||
|
@ -27,8 +27,8 @@ class VolumesV2ExtendTest(base.BaseVolumeTest):
|
|||||||
extend_size = int(volume['size']) + 1
|
extend_size = int(volume['size']) + 1
|
||||||
self.volumes_client.extend_volume(volume['id'],
|
self.volumes_client.extend_volume(volume['id'],
|
||||||
new_size=extend_size)
|
new_size=extend_size)
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
volume = self.volumes_client.show_volume(volume['id'])['volume']
|
volume = self.volumes_client.show_volume(volume['id'])['volume']
|
||||||
self.assertEqual(int(volume['size']), extend_size)
|
self.assertEqual(int(volume['size']), extend_size)
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ class VolumesV2GetTest(base.BaseVolumeTest):
|
|||||||
volume = self.volumes_client.create_volume(**kwargs)['volume']
|
volume = self.volumes_client.create_volume(**kwargs)['volume']
|
||||||
self.assertIn('id', volume)
|
self.assertIn('id', volume)
|
||||||
self.addCleanup(self.delete_volume, self.volumes_client, volume['id'])
|
self.addCleanup(self.delete_volume, self.volumes_client, volume['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client, volume['id'],
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
'available')
|
volume['id'], 'available')
|
||||||
self.assertIn(name_field, volume)
|
self.assertIn(name_field, volume)
|
||||||
self.assertEqual(volume[name_field], v_name,
|
self.assertEqual(volume[name_field], v_name,
|
||||||
"The created volume name is not equal "
|
"The created volume name is not equal "
|
||||||
@ -106,8 +106,8 @@ class VolumesV2GetTest(base.BaseVolumeTest):
|
|||||||
self.assertIn('id', new_volume)
|
self.assertIn('id', new_volume)
|
||||||
self.addCleanup(self.delete_volume, self.volumes_client,
|
self.addCleanup(self.delete_volume, self.volumes_client,
|
||||||
new_volume['id'])
|
new_volume['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
new_volume['id'], 'available')
|
new_volume['id'], 'available')
|
||||||
|
|
||||||
params = {name_field: volume[name_field],
|
params = {name_field: volume[name_field],
|
||||||
descrip_field: volume[descrip_field]}
|
descrip_field: volume[descrip_field]}
|
||||||
|
@ -124,8 +124,9 @@ def create_test_server(clients, validatable=False, validation_resources=None,
|
|||||||
'imageRef': image_id,
|
'imageRef': image_id,
|
||||||
'size': CONF.volume.volume_size}
|
'size': CONF.volume.volume_size}
|
||||||
volume = volumes_client.create_volume(**params)
|
volume = volumes_client.create_volume(**params)
|
||||||
waiters.wait_for_volume_status(volumes_client,
|
waiters.wait_for_volume_resource_status(volumes_client,
|
||||||
volume['volume']['id'], 'available')
|
volume['volume']['id'],
|
||||||
|
'available')
|
||||||
|
|
||||||
bd_map_v2 = [{
|
bd_map_v2 = [{
|
||||||
'uuid': volume['volume']['id'],
|
'uuid': volume['volume']['id'],
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
@ -179,25 +179,33 @@ def wait_for_image_status(client, image_id, status):
|
|||||||
raise lib_exc.TimeoutException(message)
|
raise lib_exc.TimeoutException(message)
|
||||||
|
|
||||||
|
|
||||||
def wait_for_volume_status(client, volume_id, status):
|
def wait_for_volume_resource_status(client, resource_id, status):
|
||||||
"""Waits for a Volume to reach a given status."""
|
"""Waits for a volume resource to reach a given status.
|
||||||
body = client.show_volume(volume_id)['volume']
|
|
||||||
volume_status = body['status']
|
This function is a common function for volume, snapshot and backup
|
||||||
|
resources. The function extracts the name of the desired resource from
|
||||||
|
the client class name of the resource.
|
||||||
|
"""
|
||||||
|
resource_name = re.findall(r'(Volume|Snapshot|Backup)',
|
||||||
|
client.__class__.__name__)[0].lower()
|
||||||
|
show_resource = getattr(client, 'show_' + resource_name)
|
||||||
|
resource_status = show_resource(resource_id)[resource_name]['status']
|
||||||
start = int(time.time())
|
start = int(time.time())
|
||||||
|
|
||||||
while volume_status != status:
|
while resource_status != status:
|
||||||
time.sleep(client.build_interval)
|
time.sleep(client.build_interval)
|
||||||
body = client.show_volume(volume_id)['volume']
|
resource_status = show_resource(resource_id)[
|
||||||
volume_status = body['status']
|
'{}'.format(resource_name)]['status']
|
||||||
if volume_status == 'error' and status != 'error':
|
if resource_status == 'error' and resource_status != status:
|
||||||
raise exceptions.VolumeBuildErrorException(volume_id=volume_id)
|
raise exceptions.VolumeResourceBuildErrorException(
|
||||||
if volume_status == 'error_restoring':
|
resource_name=resource_name, resource_id=resource_id)
|
||||||
raise exceptions.VolumeRestoreErrorException(volume_id=volume_id)
|
if resource_name == 'volume' and resource_status == 'error_restoring':
|
||||||
|
raise exceptions.VolumeRestoreErrorException(volume_id=resource_id)
|
||||||
|
|
||||||
if int(time.time()) - start >= client.build_timeout:
|
if int(time.time()) - start >= client.build_timeout:
|
||||||
message = ('Volume %s failed to reach %s status (current %s) '
|
message = ('%s %s failed to reach %s status (current %s) '
|
||||||
'within the required time (%s s).' %
|
'within the required time (%s s).' %
|
||||||
(volume_id, status, volume_status,
|
(resource_name, resource_id, status, resource_status,
|
||||||
client.build_timeout))
|
client.build_timeout))
|
||||||
raise lib_exc.TimeoutException(message)
|
raise lib_exc.TimeoutException(message)
|
||||||
|
|
||||||
@ -221,48 +229,6 @@ def wait_for_volume_retype(client, volume_id, new_volume_type):
|
|||||||
raise lib_exc.TimeoutException(message)
|
raise lib_exc.TimeoutException(message)
|
||||||
|
|
||||||
|
|
||||||
def wait_for_snapshot_status(client, snapshot_id, status):
|
|
||||||
"""Waits for a Snapshot to reach a given status."""
|
|
||||||
body = client.show_snapshot(snapshot_id)['snapshot']
|
|
||||||
snapshot_status = body['status']
|
|
||||||
start = int(time.time())
|
|
||||||
|
|
||||||
while snapshot_status != status:
|
|
||||||
time.sleep(client.build_interval)
|
|
||||||
body = client.show_snapshot(snapshot_id)['snapshot']
|
|
||||||
snapshot_status = body['status']
|
|
||||||
if snapshot_status == 'error':
|
|
||||||
raise exceptions.SnapshotBuildErrorException(
|
|
||||||
snapshot_id=snapshot_id)
|
|
||||||
if int(time.time()) - start >= client.build_timeout:
|
|
||||||
message = ('Snapshot %s failed to reach %s status (current %s) '
|
|
||||||
'within the required time (%s s).' %
|
|
||||||
(snapshot_id, status, snapshot_status,
|
|
||||||
client.build_timeout))
|
|
||||||
raise lib_exc.TimeoutException(message)
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for_backup_status(client, backup_id, status):
|
|
||||||
"""Waits for a Backup to reach a given status."""
|
|
||||||
body = client.show_backup(backup_id)['backup']
|
|
||||||
backup_status = body['status']
|
|
||||||
start = int(time.time())
|
|
||||||
|
|
||||||
while backup_status != status:
|
|
||||||
time.sleep(client.build_interval)
|
|
||||||
body = client.show_backup(backup_id)['backup']
|
|
||||||
backup_status = body['status']
|
|
||||||
if backup_status == 'error' and backup_status != status:
|
|
||||||
raise lib_exc.VolumeBackupException(backup_id=backup_id)
|
|
||||||
|
|
||||||
if int(time.time()) - start >= client.build_timeout:
|
|
||||||
message = ('Volume backup %s failed to reach %s status '
|
|
||||||
'(current %s) within the required time (%s s).' %
|
|
||||||
(backup_id, status, backup_status,
|
|
||||||
client.build_timeout))
|
|
||||||
raise lib_exc.TimeoutException(message)
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for_qos_operations(client, qos_id, operation, args=None):
|
def wait_for_qos_operations(client, qos_id, operation, args=None):
|
||||||
"""Waits for a qos operations to be completed.
|
"""Waits for a qos operations to be completed.
|
||||||
|
|
||||||
|
@ -37,18 +37,15 @@ class AddImageException(exceptions.TempestException):
|
|||||||
message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
|
message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
|
||||||
|
|
||||||
|
|
||||||
class VolumeBuildErrorException(exceptions.TempestException):
|
class VolumeResourceBuildErrorException(exceptions.TempestException):
|
||||||
message = "Volume %(volume_id)s failed to build and is in ERROR status"
|
message = ("%(resource_name)s %(resource_id)s failed to build and is in "
|
||||||
|
"ERROR status")
|
||||||
|
|
||||||
|
|
||||||
class VolumeRestoreErrorException(exceptions.TempestException):
|
class VolumeRestoreErrorException(exceptions.TempestException):
|
||||||
message = "Volume %(volume_id)s failed to restore and is in ERROR status"
|
message = "Volume %(volume_id)s failed to restore and is in ERROR status"
|
||||||
|
|
||||||
|
|
||||||
class SnapshotBuildErrorException(exceptions.TempestException):
|
|
||||||
message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
|
|
||||||
|
|
||||||
|
|
||||||
class StackBuildErrorException(exceptions.TempestException):
|
class StackBuildErrorException(exceptions.TempestException):
|
||||||
message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
|
message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
|
||||||
"due to '%(stack_status_reason)s'")
|
"due to '%(stack_status_reason)s'")
|
||||||
|
@ -241,8 +241,8 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
|||||||
self.assertEqual(name, volume['display_name'])
|
self.assertEqual(name, volume['display_name'])
|
||||||
else:
|
else:
|
||||||
self.assertEqual(name, volume['name'])
|
self.assertEqual(name, volume['name'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
# The volume retrieved on creation has a non-up-to-date status.
|
# The volume retrieved on creation has a non-up-to-date status.
|
||||||
# Retrieval after it becomes active ensures correct details.
|
# Retrieval after it becomes active ensures correct details.
|
||||||
volume = self.volumes_client.show_volume(volume['id'])['volume']
|
volume = self.volumes_client.show_volume(volume['id'])['volume']
|
||||||
@ -481,8 +481,9 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
|||||||
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
|
||||||
self.snapshots_client.delete_snapshot,
|
self.snapshots_client.delete_snapshot,
|
||||||
snapshot_id)
|
snapshot_id)
|
||||||
waiters.wait_for_snapshot_status(self.snapshots_client,
|
waiters.wait_for_volume_resource_status(self.snapshots_client,
|
||||||
snapshot_id, 'available')
|
snapshot_id,
|
||||||
|
'available')
|
||||||
image_name = snapshot_image['name']
|
image_name = snapshot_image['name']
|
||||||
self.assertEqual(name, image_name)
|
self.assertEqual(name, image_name)
|
||||||
LOG.debug("Created snapshot image %s for server %s",
|
LOG.debug("Created snapshot image %s for server %s",
|
||||||
@ -494,16 +495,16 @@ class ScenarioTest(tempest.test.BaseTestCase):
|
|||||||
server['id'], volumeId=volume_to_attach['id'], device='/dev/%s'
|
server['id'], volumeId=volume_to_attach['id'], device='/dev/%s'
|
||||||
% CONF.compute.volume_device_name)['volumeAttachment']
|
% CONF.compute.volume_device_name)['volumeAttachment']
|
||||||
self.assertEqual(volume_to_attach['id'], volume['id'])
|
self.assertEqual(volume_to_attach['id'], volume['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'in-use')
|
volume['id'], 'in-use')
|
||||||
|
|
||||||
# Return the updated volume after the attachment
|
# Return the updated volume after the attachment
|
||||||
return self.volumes_client.show_volume(volume['id'])['volume']
|
return self.volumes_client.show_volume(volume['id'])['volume']
|
||||||
|
|
||||||
def nova_volume_detach(self, server, volume):
|
def nova_volume_detach(self, server, volume):
|
||||||
self.servers_client.detach_volume(server['id'], volume['id'])
|
self.servers_client.detach_volume(server['id'], volume['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
|
|
||||||
volume = self.volumes_client.show_volume(volume['id'])['volume']
|
volume = self.volumes_client.show_volume(volume['id'])['volume']
|
||||||
self.assertEqual('available', volume['status'])
|
self.assertEqual('available', volume['status'])
|
||||||
|
@ -64,10 +64,10 @@ class TestStampPattern(manager.ScenarioTest):
|
|||||||
self.addCleanup(self.snapshots_client.wait_for_resource_deletion,
|
self.addCleanup(self.snapshots_client.wait_for_resource_deletion,
|
||||||
snapshot['id'])
|
snapshot['id'])
|
||||||
self.addCleanup(self.snapshots_client.delete_snapshot, snapshot['id'])
|
self.addCleanup(self.snapshots_client.delete_snapshot, snapshot['id'])
|
||||||
waiters.wait_for_volume_status(self.volumes_client,
|
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||||
volume['id'], 'available')
|
volume['id'], 'available')
|
||||||
waiters.wait_for_snapshot_status(self.snapshots_client,
|
waiters.wait_for_volume_resource_status(self.snapshots_client,
|
||||||
snapshot['id'], 'available')
|
snapshot['id'], 'available')
|
||||||
if 'display_name' in snapshot:
|
if 'display_name' in snapshot:
|
||||||
self.assertEqual(snapshot_name, snapshot['display_name'])
|
self.assertEqual(snapshot_name, snapshot['display_name'])
|
||||||
else:
|
else:
|
||||||
|
@ -82,8 +82,8 @@ class TestVolumeBootPattern(manager.ScenarioTest):
|
|||||||
self.addCleanup(
|
self.addCleanup(
|
||||||
self.snapshots_client.wait_for_resource_deletion, snap['id'])
|
self.snapshots_client.wait_for_resource_deletion, snap['id'])
|
||||||
self.addCleanup(self.snapshots_client.delete_snapshot, snap['id'])
|
self.addCleanup(self.snapshots_client.delete_snapshot, snap['id'])
|
||||||
waiters.wait_for_snapshot_status(self.snapshots_client,
|
waiters.wait_for_volume_resource_status(self.snapshots_client,
|
||||||
snap['id'], 'available')
|
snap['id'], 'available')
|
||||||
|
|
||||||
# NOTE(e0ne): Cinder API v2 uses name instead of display_name
|
# NOTE(e0ne): Cinder API v2 uses name instead of display_name
|
||||||
if 'display_name' in snap:
|
if 'display_name' in snap:
|
||||||
|
@ -66,7 +66,7 @@ class TestImageWaiters(base.TestCase):
|
|||||||
client.show_volume = mock_show
|
client.show_volume = mock_show
|
||||||
volume_id = '7532b91e-aa0a-4e06-b3e5-20c0c5ee1caa'
|
volume_id = '7532b91e-aa0a-4e06-b3e5-20c0c5ee1caa'
|
||||||
self.assertRaises(exceptions.VolumeRestoreErrorException,
|
self.assertRaises(exceptions.VolumeRestoreErrorException,
|
||||||
waiters.wait_for_volume_status,
|
waiters.wait_for_volume_resource_status,
|
||||||
client, volume_id, 'available')
|
client, volume_id, 'available')
|
||||||
mock_show.assert_has_calls([mock.call(volume_id),
|
mock_show.assert_has_calls([mock.call(volume_id),
|
||||||
mock.call(volume_id)])
|
mock.call(volume_id)])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user