From c2b57d6a631dae32af4cd44cd9f97d3308ad638b Mon Sep 17 00:00:00 2001 From: Boris Pavlovic Date: Sun, 31 Dec 2017 15:46:07 -0800 Subject: [PATCH] [CI] Fix Cinder update volume type scenario & service Now it's required to provide name (non backward compatible change from Cinder team) this patch address the problem and unblocks our gate Change-Id: I71874c7789c55d655262f131ace4c8eacc835bd8 --- .../scenarios/cinder/volume_types.py | 42 +++++++++---------- .../openstack/services/storage/cinder_v2.py | 10 ++--- .../scenarios/cinder/test_volume_types.py | 5 ++- .../services/storage/test_cinder_v2.py | 2 +- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/rally/plugins/openstack/scenarios/cinder/volume_types.py b/rally/plugins/openstack/scenarios/cinder/volume_types.py index a1996a60..5d5c62a9 100644 --- a/rally/plugins/openstack/scenarios/cinder/volume_types.py +++ b/rally/plugins/openstack/scenarios/cinder/volume_types.py @@ -93,7 +93,7 @@ class CreateAndUpdateVolumeType(scenario.OpenStackScenario): service.update_volume_type( volume_type, - update_name=update_name, + name=volume_type.name if not update_name else False, description=update_description, is_public=update_is_public) @@ -127,10 +127,10 @@ class CreateAndListVolumeTypes(cinder_utils.CinderBasic): @validation.add("required_params", params=[("create_specs", "provider")]) @validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_platform", platform="openstack", admin=True) -@scenario.configure(context={"admin_cleanup@openstack": ["cinder"]}, - name="CinderVolumeTypes.create_volume_type" - "_and_encryption_type", - platform="openstack") +@scenario.configure( + context={"admin_cleanup@openstack": ["cinder"]}, + name="CinderVolumeTypes.create_volume_type_and_encryption_type", + platform="openstack") class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic): def run(self, create_specs=None, provider=None, cipher=None, @@ -175,10 +175,10 @@ class CreateVolumeTypeAndEncryptionType(cinder_utils.CinderBasic): @validation.add("required_params", params=[("create_specs", "provider")]) @validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_platform", platform="openstack", admin=True) -@scenario.configure(context={"admin_cleanup@openstack": ["cinder"]}, - name="CinderVolumeTypes.create_and_list_" - "encryption_type", - platform="openstack") +@scenario.configure( + context={"admin_cleanup@openstack": ["cinder"]}, + name="CinderVolumeTypes.create_and_list_encryption_type", + platform="openstack") class CreateAndListEncryptionType(cinder_utils.CinderBasic): def run(self, create_specs=None, provider=None, cipher=None, @@ -243,10 +243,10 @@ class CreateAndSetVolumeTypeKeys(cinder_utils.CinderBasic): @validation.add("required_services", services=[consts.Service.CINDER]) @validation.add("required_contexts", contexts="volume_types") @validation.add("required_platform", platform="openstack", admin=True) -@scenario.configure(context={"admin_cleanup@openstack": ["cinder"]}, - name="CinderVolumeTypes.create_get_and_delete_" - "encryption_type", - platform="openstack") +@scenario.configure( + context={"admin_cleanup@openstack": ["cinder"]}, + name="CinderVolumeTypes.create_get_and_delete_encryption_type", + platform="openstack") class CreateGetAndDeleteEncryptionType(cinder_utils.CinderBasic): def run(self, provider=None, cipher=None, @@ -284,10 +284,10 @@ class CreateGetAndDeleteEncryptionType(cinder_utils.CinderBasic): @validation.add("required_contexts", contexts="volume_types") @validation.add("required_params", params=[("create_specs", "provider")]) @validation.add("required_platform", platform="openstack", admin=True) -@scenario.configure(context={"admin_cleanup@openstack": ["cinder"]}, - name="CinderVolumeTypes.create_and_delete_" - "encryption_type", - platform="openstack") +@scenario.configure( + context={"admin_cleanup@openstack": ["cinder"]}, + name="CinderVolumeTypes.create_and_delete_encryption_type", + platform="openstack") class CreateAndDeleteEncryptionType(cinder_utils.CinderBasic): def run(self, create_specs=None, provider=None, cipher=None, @@ -381,10 +381,10 @@ class CreateAndUpdateEncryptionType(cinder_utils.CinderBasic): @validation.add("required_platform", platform="openstack", admin=True) @validation.add("required_api_versions", component="cinder", versions=["2"]) @validation.add("required_services", services=consts.Service.CINDER) -@scenario.configure(context={"admin_cleanup@openstack": ["cinder"]}, - name="CinderVolumeTypes.create_volume_type_" - "add_and_list_type_access", - platform="openstack") +@scenario.configure( + context={"admin_cleanup@openstack": ["cinder"]}, + name="CinderVolumeTypes.create_volume_type_add_and_list_type_access", + platform="openstack") class CreateVolumeTypeAddAndListTypeAccess(scenario.OpenStackScenario): def run(self, description=None, is_public=False): diff --git a/rally/plugins/openstack/services/storage/cinder_v2.py b/rally/plugins/openstack/services/storage/cinder_v2.py index 44ddf613..34e58b96 100644 --- a/rally/plugins/openstack/services/storage/cinder_v2.py +++ b/rally/plugins/openstack/services/storage/cinder_v2.py @@ -176,20 +176,18 @@ class CinderV2Service(service.Service, cinder_common.CinderMixin): return self._get_client().volume_types.create(**kwargs) @atomic.action_timer("cinder_v2.update_volume_type") - def update_volume_type(self, volume_type, update_name=False, + def update_volume_type(self, volume_type, name=None, description=None, is_public=None): """Update the name and/or description for a volume type. :param volume_type: The ID or a instance of the :class:`VolumeType` to update. - :param update_name: if True, can update name by generating random name. - if False, don't update name. + :param name: if None, updates name by generating random name. + else updates name with provided name :param description: Description of the the volume type. :rtype: :class:`VolumeType` """ - name = None - if update_name: - name = self.generate_random_name() + name = name or self.generate_random_name() return self._get_client().volume_types.update(volume_type, name, description, is_public) diff --git a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py index bd82aca9..f881ce88 100644 --- a/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py +++ b/tests/unit/plugins/openstack/scenarios/cinder/test_volume_types.py @@ -162,7 +162,8 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase): def test_create_and_update_volume_type(self, mock_update_volume_type, mock_create_volume_type): scenario = volume_types.CreateAndUpdateVolumeType(self._get_context()) - fake_type = mock.Mock() + fake_type = mock.MagicMock() + fake_type.name = "any" create_description = "test create" update_description = "test update" mock_create_volume_type.return_value = fake_type @@ -173,7 +174,7 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase): description=create_description, is_public=True) mock_update_volume_type.assert_called_once_with( - fake_type, update_name=False, + fake_type, name="any", description=update_description, is_public=None) diff --git a/tests/unit/plugins/openstack/services/storage/test_cinder_v2.py b/tests/unit/plugins/openstack/services/storage/test_cinder_v2.py index 079eddd5..c34c962c 100644 --- a/tests/unit/plugins/openstack/services/storage/test_cinder_v2.py +++ b/tests/unit/plugins/openstack/services/storage/test_cinder_v2.py @@ -231,7 +231,7 @@ class CinderV2ServiceTestCase(test.ScenarioTestCase): result = self.service.update_volume_type(volume_type, description=description, - update_name=True, + name=None, is_public=None) self.assertEqual( self.cinder.volume_types.update.return_value,