Add rw functional tests for share type extra specs
Add base client methods for share type extra specs operations and use them in rw functional tests. Partially implements bp rw-functional-tests Change-Id: Ida6810caf4420d888494fec1b904a7f3fd4af105
This commit is contained in:
parent
0a4ccec3f5
commit
c6eace1d34
@ -22,6 +22,7 @@ from tempest_lib.common.utils import data_utils
|
||||
from tempest_lib import exceptions as tempest_lib_exc
|
||||
|
||||
from manilaclient.tests.functional import exceptions
|
||||
from manilaclient.tests.functional import utils
|
||||
|
||||
SHARE_TYPE = 'share_type'
|
||||
|
||||
@ -173,3 +174,38 @@ class ManilaCLIClient(base.CLIClient):
|
||||
projects = output_parser.listing(projects_raw)
|
||||
project_ids = [pr['Project_ID'] for pr in projects]
|
||||
return project_ids
|
||||
|
||||
def set_share_type_extra_specs(self, share_type_name_or_id, extra_specs):
|
||||
"""Set key-value pair for share type."""
|
||||
if not (isinstance(extra_specs, dict) and extra_specs):
|
||||
raise exceptions.InvalidData(
|
||||
message='Provided invalid extra specs - %s' % extra_specs)
|
||||
cmd = 'type-key %s set ' % share_type_name_or_id
|
||||
for key, value in extra_specs.items():
|
||||
cmd += '%(key)s=%(value)s ' % {'key': key, 'value': value}
|
||||
return self.manila(cmd)
|
||||
|
||||
def unset_share_type_extra_specs(self, share_type_name_or_id,
|
||||
extra_specs_keys):
|
||||
"""Unset key-value pair for share type."""
|
||||
if not (isinstance(extra_specs_keys, list) and extra_specs_keys):
|
||||
raise exceptions.InvalidData(
|
||||
message='Provided invalid extra specs - %s' % extra_specs_keys)
|
||||
cmd = 'type-key %s unset ' % share_type_name_or_id
|
||||
for key in extra_specs_keys:
|
||||
cmd += '%s ' % key
|
||||
return self.manila(cmd)
|
||||
|
||||
def list_all_share_type_extra_specs(self):
|
||||
"""List extra specs for all share types."""
|
||||
extra_specs_raw = self.manila('extra-specs-list')
|
||||
extra_specs = utils.listing(extra_specs_raw)
|
||||
return extra_specs
|
||||
|
||||
def list_share_type_extra_specs(self, share_type_name_or_id):
|
||||
"""List extra specs for specific share type by its Name or ID."""
|
||||
all_share_types = self.list_all_share_type_extra_specs()
|
||||
for share_type in all_share_types:
|
||||
if share_type_name_or_id in (share_type['ID'], share_type['Name']):
|
||||
return share_type['all_extra_specs']
|
||||
raise exceptions.ShareTypeNotFound(share_type=share_type_name_or_id)
|
||||
|
@ -26,3 +26,11 @@ class ResourceReleaseFailed(exceptions.TempestException):
|
||||
|
||||
class InvalidResource(exceptions.TempestException):
|
||||
message = "Provided invalid resource: %(message)s"
|
||||
|
||||
|
||||
class InvalidData(exceptions.TempestException):
|
||||
message = "Provided invalid data: %(message)s"
|
||||
|
||||
|
||||
class ShareTypeNotFound(exceptions.TempestException):
|
||||
message = "Share type '%(share_type)s' was not found"
|
||||
|
@ -147,3 +147,39 @@ class ShareTypesReadWriteTest(base.BaseTestCase):
|
||||
# Project ID is in access list - false
|
||||
st_access_list = self.admin_client.list_share_type_access(st_id)
|
||||
self.assertNotIn(user_project_id, st_access_list)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ShareTypeExtraSpecsReadWriteTest(base.BaseTestCase):
|
||||
|
||||
@ddt.data(
|
||||
{'is_public': True, 'dhss': False},
|
||||
{'is_public': True, 'dhss': True},
|
||||
{'is_public': False, 'dhss': True},
|
||||
{'is_public': False, 'dhss': False},
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_share_type_extra_specs_life_cycle(self, is_public, dhss):
|
||||
|
||||
# Create share type
|
||||
st = self.create_share_type(
|
||||
driver_handles_share_servers=dhss, is_public=is_public)
|
||||
|
||||
# Add extra specs to share type
|
||||
st_extra_specs = dict(foo_key='foo_value', bar_key='bar_value')
|
||||
self.admin_client.set_share_type_extra_specs(
|
||||
st['ID'], st_extra_specs)
|
||||
|
||||
# View list of extra specs
|
||||
extra_specs = self.admin_client.list_share_type_extra_specs(st['ID'])
|
||||
for k, v in st_extra_specs.items():
|
||||
self.assertIn('%s : %s' % (k, v), extra_specs)
|
||||
|
||||
# Remove one extra spec
|
||||
self.admin_client.unset_share_type_extra_specs(st['ID'], ['foo_key'])
|
||||
|
||||
# Verify that removed extra spec is absent
|
||||
extra_specs = self.admin_client.list_share_type_extra_specs(st['ID'])
|
||||
self.assertNotIn('foo_key : foo_value', extra_specs)
|
||||
self.assertIn('bar_key : bar_value', extra_specs)
|
||||
self.assertIn('driver_handles_share_servers : %s' % dhss, extra_specs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user