Merge "Add assertions to attached volume retype test"
This commit is contained in:
commit
2e11ca3856
|
@ -50,7 +50,8 @@ create_get_volume = {
|
||||||
# If it would come as empty array "[]" then,
|
# If it would come as empty array "[]" then,
|
||||||
# those elements can be defined as 'required'.
|
# those elements can be defined as 'required'.
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
'os-vol-host-attr:host': {'type': 'string'},
|
||||||
},
|
},
|
||||||
'additionalProperties': False,
|
'additionalProperties': False,
|
||||||
'required': ['id', 'status', 'displayName', 'availabilityZone',
|
'required': ['id', 'status', 'displayName', 'availabilityZone',
|
||||||
|
|
|
@ -33,6 +33,9 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
|
||||||
* Write to the volume
|
* Write to the volume
|
||||||
* Perform a cinder retype --on-demand of the volume to type of backend #2
|
* Perform a cinder retype --on-demand of the volume to type of backend #2
|
||||||
* Check written content of migrated volume
|
* Check written content of migrated volume
|
||||||
|
* Check the type of the volume has been updated.
|
||||||
|
* Check the volume is still in-use and the migration was successful.
|
||||||
|
* Check that the same volume is attached to the instance.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
credentials = ['primary', 'admin']
|
credentials = ['primary', 'admin']
|
||||||
|
@ -78,7 +81,8 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
|
||||||
'src_backend': backend_source,
|
'src_backend': backend_source,
|
||||||
'dst': dest_body['name'],
|
'dst': dest_body['name'],
|
||||||
'dst_backend': backend_dest})
|
'dst_backend': backend_dest})
|
||||||
return source_body['name'], dest_body['name']
|
return ({'name': source_body['name'], 'host': backend_source},
|
||||||
|
{'name': dest_body['name'], 'host': backend_dest})
|
||||||
|
|
||||||
def _volume_retype_with_migration(self, volume_id, new_volume_type):
|
def _volume_retype_with_migration(self, volume_id, new_volume_type):
|
||||||
# NOTE: The 'on-demand' migration requires admin operation, so
|
# NOTE: The 'on-demand' migration requires admin operation, so
|
||||||
|
@ -104,11 +108,11 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
|
||||||
|
|
||||||
# create an instance from volume
|
# create an instance from volume
|
||||||
LOG.info("Booting instance from volume")
|
LOG.info("Booting instance from volume")
|
||||||
volume_origin = self.create_volume(imageRef=CONF.compute.image_ref,
|
volume_id = self.create_volume(imageRef=CONF.compute.image_ref,
|
||||||
volume_type=source_type)
|
volume_type=source_type['name'])['id']
|
||||||
|
|
||||||
instance = self._boot_instance_from_volume(volume_origin['id'],
|
instance = self._boot_instance_from_volume(volume_id, keypair,
|
||||||
keypair, security_group)
|
security_group)
|
||||||
|
|
||||||
# write content to volume on instance
|
# write content to volume on instance
|
||||||
LOG.info("Setting timestamp in instance %s", instance['id'])
|
LOG.info("Setting timestamp in instance %s", instance['id'])
|
||||||
|
@ -118,9 +122,11 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
|
||||||
server=instance)
|
server=instance)
|
||||||
|
|
||||||
# retype volume with migration from backend #1 to backend #2
|
# retype volume with migration from backend #1 to backend #2
|
||||||
LOG.info("Retyping Volume %s to new type %s", volume_origin['id'],
|
LOG.info("Retyping Volume %s to new type %s", volume_id,
|
||||||
dest_type)
|
dest_type['name'])
|
||||||
self._volume_retype_with_migration(volume_origin['id'], dest_type)
|
# This method calls for the retype of the volume before calling a
|
||||||
|
# waiter that asserts that the volume type has changed successfully.
|
||||||
|
self._volume_retype_with_migration(volume_id, dest_type['name'])
|
||||||
|
|
||||||
# check the content of written file
|
# check the content of written file
|
||||||
LOG.info("Getting timestamp in postmigrated instance %s",
|
LOG.info("Getting timestamp in postmigrated instance %s",
|
||||||
|
@ -129,3 +135,17 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
|
||||||
private_key=keypair['private_key'],
|
private_key=keypair['private_key'],
|
||||||
server=instance)
|
server=instance)
|
||||||
self.assertEqual(timestamp, timestamp2)
|
self.assertEqual(timestamp, timestamp2)
|
||||||
|
|
||||||
|
# Assert that the volume is on the new host, is still in-use and has a
|
||||||
|
# migration_status of success
|
||||||
|
volume = self.admin_volumes_client.show_volume(volume_id)['volume']
|
||||||
|
# dest_type is host@backend, os-vol-host-attr:host is host@backend#type
|
||||||
|
self.assertIn(dest_type['host'], volume['os-vol-host-attr:host'])
|
||||||
|
self.assertEqual('in-use', volume['status'])
|
||||||
|
self.assertEqual('success', volume['migration_status'])
|
||||||
|
|
||||||
|
# Assert that the same volume id is attached to the instance, ensuring
|
||||||
|
# the os-migrate_volume_completion Cinder API has been called.
|
||||||
|
attached_volumes = self.servers_client.list_volume_attachments(
|
||||||
|
instance['id'])['volumeAttachments']
|
||||||
|
self.assertEqual(volume_id, attached_volumes[0]['id'])
|
||||||
|
|
Loading…
Reference in New Issue