Fix test_volume_migrate_attached to retype as admin

By default, Cinder policy will allow a non-admin owner
of a volume to retype a volume. That triggers a call from
Cinder to Nova to swap the volume in the guest. The Nova
swap volume API, however, is admin-only by default. So this
test fails with default policy because Cinder gets a 403
response from Nova when trying to swap the volume on the
Nova side.

This fixes the problem by using the admin client for initiating
the retype.

Change-Id: I17e6603c588e3efddcf44ca4e7af6e352490e689
Closes-Bug: #1698224
This commit is contained in:
Matt Riedemann 2017-06-15 17:49:06 -04:00
parent 64b07b7ee1
commit 1df940ebdb
1 changed files with 2 additions and 1 deletions

View File

@ -41,6 +41,7 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
def setup_clients(cls):
super(TestVolumeMigrateRetypeAttached, cls).setup_clients()
cls.admin_volume_types_client = cls.os_admin.volume_types_v2_client
cls.admin_volumes_client = cls.os_admin.volumes_v2_client
@classmethod
def skip_checks(cls):
@ -82,7 +83,7 @@ class TestVolumeMigrateRetypeAttached(manager.ScenarioTest):
def _volume_retype_with_migration(self, volume_id, new_volume_type):
migration_policy = 'on-demand'
self.volumes_client.retype_volume(
self.admin_volumes_client.retype_volume(
volume_id, new_type=new_volume_type,
migration_policy=migration_policy)
waiters.wait_for_volume_retype(self.volumes_client,