Merge "Add CinderVolumeTypes.create_volume_type_add_and_list_type_access"
This commit is contained in:
commit
e93845e390
@ -1209,3 +1209,19 @@
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
||||
CinderVolumeTypes.create_volume_type_add_and_list_type_access:
|
||||
-
|
||||
args:
|
||||
description: "rally tests creating types"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
||||
|
@ -366,3 +366,30 @@ class CreateAndUpdateEncryptionType(cinder_utils.CinderBasic):
|
||||
specs=create_specs)
|
||||
self.admin_cinder.update_encryption_type(volume_type["id"],
|
||||
specs=update_specs)
|
||||
|
||||
|
||||
@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": ["cinder"]},
|
||||
name="CinderVolumeTypes.create_volume_type_"
|
||||
"add_and_list_type_access")
|
||||
class CreateVolumeTypeAddAndListTypeAccess(scenario.OpenStackScenario):
|
||||
|
||||
def run(self, description=None, is_public=False):
|
||||
"""Add and list volume type access for the given project.
|
||||
|
||||
This scenario first creates a private volume type, then add project
|
||||
access and list project access to it.
|
||||
|
||||
:param description: Description of the volume type
|
||||
:param is_public: Volume type visibility
|
||||
"""
|
||||
service = cinder_v2.CinderV2Service(self._admin_clients,
|
||||
self.generate_random_name,
|
||||
atomic_inst=self.atomic_actions())
|
||||
volume_type = service.create_volume_type(description=description,
|
||||
is_public=is_public)
|
||||
service.add_type_access(volume_type,
|
||||
project=self.context["tenant"]["id"])
|
||||
service.list_type_access(volume_type)
|
||||
|
@ -194,6 +194,27 @@ class CinderV2Service(service.Service, cinder_common.CinderMixin):
|
||||
return self._get_client().volume_types.update(volume_type, name,
|
||||
description, is_public)
|
||||
|
||||
@atomic.action_timer("cinder_v2.add_type_access")
|
||||
def add_type_access(self, volume_type, project):
|
||||
"""Add a project to the given volume type access list.
|
||||
|
||||
:param volume_type: Volume type name or ID to add access for the given
|
||||
project
|
||||
:project: Project ID to add volume type access for
|
||||
:return: An instance of cinderclient.apiclient.base.TupleWithMeta
|
||||
"""
|
||||
return self._get_client().volume_type_access.add_project_access(
|
||||
volume_type, project)
|
||||
|
||||
@atomic.action_timer("cinder_v2.list_type_access")
|
||||
def list_type_access(self, volume_type):
|
||||
"""Print access information about the given volume type
|
||||
|
||||
:param volume_type: Filter results by volume type name or ID
|
||||
:return: VolumeTypeAcces of specific project
|
||||
"""
|
||||
return self._get_client().volume_type_access.list(volume_type)
|
||||
|
||||
|
||||
@service.compat_layer(CinderV2Service)
|
||||
class UnifiedCinderV2Service(cinder_common.UnifiedCinderMixin,
|
||||
|
@ -0,0 +1,25 @@
|
||||
{
|
||||
"CinderVolumeTypes.create_volume_type_add_and_list_type_access": [
|
||||
{
|
||||
"args": {
|
||||
"description": "rally tests creating types"
|
||||
},
|
||||
"runner": {
|
||||
"type": "constant",
|
||||
"times": 4,
|
||||
"concurrency": 2
|
||||
},
|
||||
"context": {
|
||||
"users": {
|
||||
"tenants": 2,
|
||||
"users_per_tenant": 2
|
||||
}
|
||||
},
|
||||
"sla": {
|
||||
"failure_rate": {
|
||||
"max": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
CinderVolumeTypes.create_volume_type_add_and_list_type_access:
|
||||
-
|
||||
args:
|
||||
description: "rally tests creating types"
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 4
|
||||
concurrency: 2
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
sla:
|
||||
failure_rate:
|
||||
max: 0
|
@ -290,3 +290,20 @@ class CinderVolumeTypesTestCase(test.ScenarioTestCase):
|
||||
"fake_id", specs=create_specs)
|
||||
mock_service.update_encryption_type.assert_called_once_with(
|
||||
"fake_id", specs=update_specs)
|
||||
|
||||
@mock.patch("%s.list_type_access" % CINDER_V2_PATH)
|
||||
@mock.patch("%s.add_type_access" % CINDER_V2_PATH)
|
||||
@mock.patch("%s.create_volume_type" % CINDER_V2_PATH)
|
||||
def test_create_volume_type_add_and_list_type_access(
|
||||
self, mock_create_volume_type, mock_add_type_access,
|
||||
mock_list_type_access):
|
||||
scenario = volume_types.CreateVolumeTypeAddAndListTypeAccess(
|
||||
self._get_context())
|
||||
fake_type = mock.Mock()
|
||||
mock_create_volume_type.return_value = fake_type
|
||||
|
||||
scenario.run(description=None, is_public=False)
|
||||
mock_create_volume_type.assert_called_once_with(
|
||||
description=None, is_public=False)
|
||||
mock_add_type_access.assert_called_once_with(fake_type, project="fake")
|
||||
mock_list_type_access.assert_called_once_with(fake_type)
|
||||
|
@ -239,6 +239,29 @@ class CinderV2ServiceTestCase(test.ScenarioTestCase):
|
||||
self._test_atomic_action_timer(self.atomic_actions(),
|
||||
"cinder_v2.update_volume_type")
|
||||
|
||||
def test_add_type_access(self):
|
||||
volume_type = mock.Mock()
|
||||
project = mock.Mock()
|
||||
type_access = self.service.add_type_access(volume_type,
|
||||
project=project)
|
||||
add_project_access = self.cinder.volume_type_access.add_project_access
|
||||
add_project_access.assert_called_once_with(
|
||||
volume_type, project)
|
||||
self.assertEqual(add_project_access.return_value,
|
||||
type_access)
|
||||
self._test_atomic_action_timer(self.atomic_actions(),
|
||||
"cinder_v2.add_type_access")
|
||||
|
||||
def test_list_type_access(self):
|
||||
volume_type = mock.Mock()
|
||||
type_access = self.service.list_type_access(volume_type)
|
||||
self.cinder.volume_type_access.list.assert_called_once_with(
|
||||
volume_type)
|
||||
self.assertEqual(self.cinder.volume_type_access.list.return_value,
|
||||
type_access)
|
||||
self._test_atomic_action_timer(self.atomic_actions(),
|
||||
"cinder_v2.list_type_access")
|
||||
|
||||
|
||||
class UnifiedCinderV2ServiceTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
|
Loading…
Reference in New Issue
Block a user