Test is_default for share type and share group type

The share type and share group type APIs in version 2.46
returns is_default key, this patch is to test this featue.

Depends-On: https://review.openstack.org/#/c/557206/
Change-Id: I68f7bea991fb39c4667031b0125470936a28dc9f
Partial-Bug: #1743941
This commit is contained in:
junboli 2018-07-24 12:25:22 +08:00 committed by Goutham Pacha Ravi
parent f0dd7a400b
commit 5dd4b582f4
3 changed files with 85 additions and 1 deletions

View File

@ -30,7 +30,7 @@ ShareGroup = [
help="The minimum api microversion is configured to be the "
"value of the minimum microversion supported by Manila."),
cfg.StrOpt("max_api_microversion",
default="2.45",
default="2.46",
help="The maximum api microversion is configured to be the "
"value of the latest microversion supported by Manila."),
cfg.StrOpt("region",

View File

@ -21,9 +21,12 @@ from testtools import testcase as tc
from manila_tempest_tests.common import constants
from manila_tempest_tests.tests.api import base
from manila_tempest_tests import utils
CONF = config.CONF
LATEST_MICROVERSION = CONF.share.max_api_microversion
@testtools.skipUnless(
CONF.share.run_share_group_tests, 'Share Group tests disabled.')
@ -243,3 +246,42 @@ class ShareGroupTypesTest(base.BaseSharesAdminTest):
# List projects that have access for share group type - none expected
access = self.shares_v2_client.list_access_to_share_group_type(sgt_id)
self.assertEmpty(access)
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@ddt.data(*set(('2.45', '2.46', LATEST_MICROVERSION)))
def test_share_group_type_create_show_list_with_is_default_key(self,
version):
self.skip_if_microversion_not_supported(version)
name = data_utils.rand_name("tempest-manila")
# Create share group type
sg_type_c = self.create_share_group_type(
name=name,
share_types=self.share_type['id'],
cleanup_in_class=False,
version=version)
if utils.is_microversion_ge(version, '2.46'):
self.assertIn('is_default', sg_type_c)
self.assertIs(False, sg_type_c['is_default'])
else:
self.assertNotIn('is_default', sg_type_c)
# List share group type
sg_type_list = self.shares_v2_client.list_share_group_types(
version=version)
for sg_type_get in sg_type_list:
if utils.is_microversion_ge(version, '2.46'):
self.assertIn('is_default', sg_type_get)
self.assertTrue(sg_type_get['is_default'] in (True, False))
else:
self.assertNotIn('is_default', sg_type_get)
# Show share group type
sg_type_id = sg_type_c['id']
sg_type_show = self.shares_v2_client.get_share_group_type(
sg_type_id, version=version)
if utils.is_microversion_ge(version, '2.46'):
self.assertIn('is_default', sg_type_show)
self.assertIs(False, sg_type_show['is_default'])
else:
self.assertNotIn('is_default', sg_type_show)

View File

@ -24,6 +24,8 @@ from manila_tempest_tests import utils
CONF = config.CONF
LATEST_MICROVERSION = CONF.share.max_api_microversion
@ddt.ddt
class ShareTypesAdminTest(base.BaseSharesAdminTest):
@ -205,3 +207,43 @@ class ShareTypesAdminTest(base.BaseSharesAdminTest):
# List projects that have access for share type - none expected
access = self.shares_v2_client.list_access_to_share_type(st_id)
self.assertEmpty(access)
@tc.attr(base.TAG_POSITIVE, base.TAG_API)
@ddt.data(*set(('2.45', '2.46', LATEST_MICROVERSION)))
def test_share_type_create_show_list_with_is_default_key(self, version):
self.skip_if_microversion_not_supported(version)
name = data_utils.rand_name("tempest-manila")
extra_specs = self.add_extra_specs_to_dict()
# Create share type
st_create = self.create_share_type(
name, extra_specs=extra_specs, version=version)['share_type']
if utils.is_microversion_ge(version, '2.46'):
self.assertIn('is_default', st_create)
self.assertIs(False, st_create['is_default'])
else:
self.assertNotIn('is_default', st_create)
# list share types
st_list = self.shares_v2_client.list_share_types(version=version)
for st_get in st_list['share_types']:
if utils.is_microversion_ge(version, '2.46'):
self.assertIn('is_default', st_get)
if st_create['id'] == st_get['id']:
self.assertIs(False, st_get['is_default'])
else:
self.assertTrue(st_get['is_default'] in (True, False))
else:
self.assertNotIn('is_default', st_get)
# show share types
st_id = st_create['id']
st_show = self.shares_v2_client.get_share_type(
st_id, version=version)['share_type']
if utils.is_microversion_ge(version, '2.46'):
self.assertIn('is_default', st_show)
self.assertIs(False, st_show['is_default'])
else:
self.assertNotIn('is_default', st_show)