Merge "Add response assertions and remove unused variables in volume tests"

This commit is contained in:
Jenkins 2017-07-04 03:49:24 +00:00 committed by Gerrit Code Review
commit 479863dd47
5 changed files with 13 additions and 5 deletions

View File

@ -155,7 +155,7 @@ class BaseVolumeQuotasAdminTestJSON(base.BaseVolumeAdminTest):
# Accepts a volume transfer # Accepts a volume transfer
self.alt_transfer_client.accept_volume_transfer( self.alt_transfer_client.accept_volume_transfer(
transfer_id, auth_key=auth_key)['transfer'] transfer_id, auth_key=auth_key)
# Verify volume transferred is available # Verify volume transferred is available
waiters.wait_for_volume_resource_status( waiters.wait_for_volume_resource_status(

View File

@ -55,6 +55,7 @@ class SnapshotMetadataTestJSON(base.BaseVolumeTest):
# Create metadata # Create metadata
body = self.snapshots_client.create_snapshot_metadata( body = self.snapshots_client.create_snapshot_metadata(
self.snapshot['id'], metadata)['metadata'] self.snapshot['id'], metadata)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Get the metadata of the snapshot # Get the metadata of the snapshot
body = self.snapshots_client.show_snapshot_metadata( body = self.snapshots_client.show_snapshot_metadata(
@ -65,6 +66,7 @@ class SnapshotMetadataTestJSON(base.BaseVolumeTest):
# Update metadata # Update metadata
body = self.snapshots_client.update_snapshot_metadata( body = self.snapshots_client.update_snapshot_metadata(
self.snapshot['id'], metadata=update)['metadata'] self.snapshot['id'], metadata=update)['metadata']
self.assertEqual(update, body)
body = self.snapshots_client.show_snapshot_metadata( body = self.snapshots_client.show_snapshot_metadata(
self.snapshot['id'])['metadata'] self.snapshot['id'])['metadata']
self.assertEqual(update, body, 'Update snapshot metadata failed') self.assertEqual(update, body, 'Update snapshot metadata failed')
@ -89,8 +91,8 @@ class SnapshotMetadataTestJSON(base.BaseVolumeTest):
"key2": "value2", "key2": "value2",
"key3": "value3_update"} "key3": "value3_update"}
# Create metadata for the snapshot # Create metadata for the snapshot
body = self.snapshots_client.create_snapshot_metadata( self.snapshots_client.create_snapshot_metadata(
self.snapshot['id'], metadata)['metadata'] self.snapshot['id'], metadata)
# Get the metadata of the snapshot # Get the metadata of the snapshot
body = self.snapshots_client.show_snapshot_metadata( body = self.snapshots_client.show_snapshot_metadata(
self.snapshot['id'])['metadata'] self.snapshot['id'])['metadata']
@ -98,6 +100,7 @@ class SnapshotMetadataTestJSON(base.BaseVolumeTest):
# Update metadata item # Update metadata item
body = self.snapshots_client.update_snapshot_metadata_item( body = self.snapshots_client.update_snapshot_metadata_item(
self.snapshot['id'], "key3", meta=update_item)['meta'] self.snapshot['id'], "key3", meta=update_item)['meta']
self.assertEqual(update_item, body)
# Get the metadata of the snapshot # Get the metadata of the snapshot
body = self.snapshots_client.show_snapshot_metadata( body = self.snapshots_client.show_snapshot_metadata(
self.snapshot['id'])['metadata'] self.snapshot['id'])['metadata']

View File

@ -45,6 +45,7 @@ class VolumesMetadataTest(base.BaseVolumeTest):
body = self.volumes_client.create_volume_metadata(self.volume['id'], body = self.volumes_client.create_volume_metadata(self.volume['id'],
metadata)['metadata'] metadata)['metadata']
self.assertThat(body.items(), matchers.ContainsAll(metadata.items()))
# Get the metadata of the volume # Get the metadata of the volume
body = self.volumes_client.show_volume_metadata( body = self.volumes_client.show_volume_metadata(
self.volume['id'])['metadata'] self.volume['id'])['metadata']
@ -54,6 +55,7 @@ class VolumesMetadataTest(base.BaseVolumeTest):
# Update metadata # Update metadata
body = self.volumes_client.update_volume_metadata( body = self.volumes_client.update_volume_metadata(
self.volume['id'], update)['metadata'] self.volume['id'], update)['metadata']
self.assertEqual(update, body)
body = self.volumes_client.show_volume_metadata( body = self.volumes_client.show_volume_metadata(
self.volume['id'])['metadata'] self.volume['id'])['metadata']
self.assertEqual(update, body, 'Update metadata failed') self.assertEqual(update, body, 'Update metadata failed')
@ -85,6 +87,7 @@ class VolumesMetadataTest(base.BaseVolumeTest):
# Update metadata item # Update metadata item
body = self.volumes_client.update_volume_metadata_item( body = self.volumes_client.update_volume_metadata_item(
self.volume['id'], "key3", update_item)['meta'] self.volume['id'], "key3", update_item)['meta']
self.assertEqual(update_item, body)
# Get the metadata of the volume # Get the metadata of the volume
body = self.volumes_client.show_volume_metadata( body = self.volumes_client.show_volume_metadata(
self.volume['id'])['metadata'] self.volume['id'])['metadata']

View File

@ -59,6 +59,8 @@ class VolumesTransfersTest(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']
for key in ['id', 'name', 'links', 'volume_id']:
self.assertIn(key, body)
waiters.wait_for_volume_resource_status(self.alt_volumes_client, waiters.wait_for_volume_resource_status(self.alt_volumes_client,
volume['id'], 'available') volume['id'], 'available')
accepted_volume = self.alt_volumes_client.show_volume( accepted_volume = self.alt_volumes_client.show_volume(

View File

@ -115,12 +115,12 @@ class VolumesActionsTest(base.BaseVolumeTest):
@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):
# Mark volume as reserved. # Mark volume as reserved.
body = self.volumes_client.reserve_volume(self.volume['id']) self.volumes_client.reserve_volume(self.volume['id'])
# To get the volume info # To get the volume info
body = self.volumes_client.show_volume(self.volume['id'])['volume'] body = self.volumes_client.show_volume(self.volume['id'])['volume']
self.assertIn('attaching', body['status']) self.assertIn('attaching', body['status'])
# Unmark volume as reserved. # Unmark volume as reserved.
body = self.volumes_client.unreserve_volume(self.volume['id']) self.volumes_client.unreserve_volume(self.volume['id'])
# To get the volume info # To get the volume info
body = self.volumes_client.show_volume(self.volume['id'])['volume'] body = self.volumes_client.show_volume(self.volume['id'])['volume']
self.assertIn('available', body['status']) self.assertIn('available', body['status'])