Cleanup access rule test skip conditions
There are some generic access rules test cases under: - tests.api.test_rules.ShareRulesTest - tests.api.test_access_rules_metadata.AccessRulesMetadataTest - tests.api.test_access_rules_metadata_negative.AccessesMetadataNegativeTest These test cases don't care about what protocol is being tested and what access rule is being applied. However, they were doing the wrong thing of requesting a share of an unsupported protocol if a wrong configuration is presented via the configuration options enable_*_rules_for_protocols. There's also an infructuous test skip for cephfs tests added with the shares v1 client even when there are no shares created within the tests.api.test_rules_negative.ShareRulesNegativeTest class that we can get rid of. Change-Id: I8b94d0dcf2e4ab1d82d9d1ec4d4934c65d095e32 Closes-Bug: #1879486 Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This commit is contained in:
parent
0e78026163
commit
1727f7a18b
|
@ -799,14 +799,15 @@ class BaseSharesTest(test.BaseTestCase):
|
|||
status_attr="replica_state")
|
||||
return replica
|
||||
|
||||
def _get_access_rule_data_from_config(self):
|
||||
@classmethod
|
||||
def _get_access_rule_data_from_config(cls):
|
||||
"""Get the first available access type/to combination from config.
|
||||
|
||||
This method opportunistically picks the first configured protocol
|
||||
to create the share. Do not use this method in tests where you need
|
||||
to test depth and breadth in the access types and access recipients.
|
||||
"""
|
||||
protocol = self.shares_v2_client.share_protocol
|
||||
protocol = cls.shares_v2_client.share_protocol
|
||||
|
||||
if protocol in CONF.share.enable_ip_rules_for_protocols:
|
||||
access_type = "ip"
|
||||
|
@ -822,7 +823,7 @@ class BaseSharesTest(test.BaseTestCase):
|
|||
access_to = "eve"
|
||||
else:
|
||||
message = "Unrecognized protocol and access rules configuration."
|
||||
raise self.skipException(message)
|
||||
raise cls.skipException(message)
|
||||
|
||||
return access_type, access_to
|
||||
|
||||
|
|
|
@ -26,6 +26,12 @@ CONF = config.CONF
|
|||
|
||||
@ddt.ddt
|
||||
class AccessRulesMetadataTest(base.BaseSharesMixedTest):
|
||||
"""A Test class to test access rule metadata generically.
|
||||
|
||||
Tests in this class don't care about the type of access rule or the
|
||||
protocol of the share created. They are meant to test the API semantics
|
||||
of the access rule metadata APIs.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
|
@ -47,22 +53,8 @@ class AccessRulesMetadataTest(base.BaseSharesMixedTest):
|
|||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(AccessRulesMetadataTest, cls).resource_setup()
|
||||
# The share access rule metadata doesn't care about the value of
|
||||
# access type, access protocol, access_to, so we only get one of
|
||||
# the value that the driver support.
|
||||
if CONF.share.enable_ip_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_ip_rules_for_protocols[0]
|
||||
cls.access_type = "ip"
|
||||
elif CONF.share.enable_user_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_user_rules_for_protocols[0]
|
||||
cls.access_type = "user"
|
||||
elif CONF.share.enable_cert_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_cert_rules_for_protocols[0]
|
||||
cls.access_type = "cert"
|
||||
elif CONF.share.enable_cephx_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_cephx_rules_for_protocols[0]
|
||||
cls.access_type = "cephx"
|
||||
cls.shares_v2_client.share_protocol = cls.protocol
|
||||
cls.protocol = cls.shares_v2_client.share_protocol
|
||||
cls.access_type, __ = cls._get_access_rule_data_from_config()
|
||||
int_range = range(20, 50)
|
||||
cls.access_to = {
|
||||
# list of unique values is required for ability to create lots
|
||||
|
|
|
@ -27,6 +27,12 @@ CONF = config.CONF
|
|||
|
||||
@ddt.ddt
|
||||
class AccessesMetadataNegativeTest(base.BaseSharesMixedTest):
|
||||
"""A Test class with generic negative access rule metadata tests.
|
||||
|
||||
Tests in this class don't care about the type of access rule or the
|
||||
protocol of the share created. They are meant to test the API semantics
|
||||
of the access rule metadata APIs.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
|
@ -48,23 +54,10 @@ class AccessesMetadataNegativeTest(base.BaseSharesMixedTest):
|
|||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(AccessesMetadataNegativeTest, cls).resource_setup()
|
||||
if CONF.share.enable_ip_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_ip_rules_for_protocols[0]
|
||||
cls.access_type = "ip"
|
||||
cls.access_to = utils.rand_ip()
|
||||
elif CONF.share.enable_user_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_user_rules_for_protocols[0]
|
||||
cls.access_type = "user"
|
||||
cls.access_to = CONF.share.username_for_user_rules
|
||||
elif CONF.share.enable_cert_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_cert_rules_for_protocols[0]
|
||||
cls.access_type = "cert"
|
||||
cls.access_to = "client3.com"
|
||||
elif CONF.share.enable_cephx_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_cephx_rules_for_protocols[0]
|
||||
cls.access_type = "cephx"
|
||||
cls.access_to = "eve"
|
||||
cls.shares_v2_client.share_protocol = cls.protocol
|
||||
cls.protocol = cls.shares_v2_client.share_protocol
|
||||
cls.access_type, cls.access_to = (
|
||||
cls._get_access_rule_data_from_config()
|
||||
)
|
||||
# create share type
|
||||
cls.share_type = cls._create_share_type()
|
||||
cls.share_type_id = cls.share_type['id']
|
||||
|
|
|
@ -498,6 +498,12 @@ class ShareCephxRulesForCephFSTest(base.BaseSharesMixedTest):
|
|||
|
||||
@ddt.ddt
|
||||
class ShareRulesTest(base.BaseSharesMixedTest):
|
||||
"""A Test class to test access rules generically.
|
||||
|
||||
Tests in this class don't care about the type of access rule or the
|
||||
protocol of the share created. They are meant to test the API semantics
|
||||
of the access rules APIs.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
|
@ -516,23 +522,10 @@ class ShareRulesTest(base.BaseSharesMixedTest):
|
|||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(ShareRulesTest, cls).resource_setup()
|
||||
if CONF.share.enable_ip_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_ip_rules_for_protocols[0]
|
||||
cls.access_type = "ip"
|
||||
cls.access_to = "8.8.8.8"
|
||||
elif CONF.share.enable_user_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_user_rules_for_protocols[0]
|
||||
cls.access_type = "user"
|
||||
cls.access_to = CONF.share.username_for_user_rules
|
||||
elif CONF.share.enable_cert_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_cert_rules_for_protocols[0]
|
||||
cls.access_type = "cert"
|
||||
cls.access_to = "client3.com"
|
||||
elif CONF.share.enable_cephx_rules_for_protocols:
|
||||
cls.protocol = CONF.share.enable_cephx_rules_for_protocols[0]
|
||||
cls.access_type = "cephx"
|
||||
cls.access_to = "eve"
|
||||
cls.shares_v2_client.share_protocol = cls.protocol
|
||||
cls.protocol = cls.shares_v2_client.share_protocol
|
||||
cls.access_type, cls.access_to = (
|
||||
cls._get_access_rule_data_from_config()
|
||||
)
|
||||
cls.share_type = cls._create_share_type()
|
||||
cls.share_type_id = cls.share_type['id']
|
||||
cls.share = cls.create_share(share_type_id=cls.share_type_id)
|
||||
|
|
|
@ -386,18 +386,6 @@ class ShareCephxRulesForCephFSNegativeTest(base.BaseSharesMixedTest):
|
|||
access_level="su")
|
||||
|
||||
|
||||
def skip_if_cephx_access_type_not_supported_by_client(self, client):
|
||||
if client == 'shares_client':
|
||||
version = '1.0'
|
||||
else:
|
||||
version = LATEST_MICROVERSION
|
||||
if (CONF.share.enable_cephx_rules_for_protocols and
|
||||
utils.is_microversion_lt(version, '2.13')):
|
||||
msg = ("API version %s does not support cephx access type, need "
|
||||
"version >= 2.13." % version)
|
||||
raise self.skipException(msg)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class ShareRulesNegativeTest(base.BaseSharesMixedTest):
|
||||
# Tests independent from rule type and share protocol
|
||||
|
@ -427,7 +415,6 @@ class ShareRulesNegativeTest(base.BaseSharesMixedTest):
|
|||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
|
||||
@ddt.data('shares_client', 'shares_v2_client')
|
||||
def test_delete_access_rule_with_wrong_id(self, client_name):
|
||||
skip_if_cephx_access_type_not_supported_by_client(self, client_name)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
getattr(self, client_name).delete_access_rule,
|
||||
self.share["id"], "wrong_rule_id")
|
||||
|
@ -435,7 +422,6 @@ class ShareRulesNegativeTest(base.BaseSharesMixedTest):
|
|||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND)
|
||||
@ddt.data('shares_client', 'shares_v2_client')
|
||||
def test_create_access_rule_ip_with_wrong_type(self, client_name):
|
||||
skip_if_cephx_access_type_not_supported_by_client(self, client_name)
|
||||
self.assertRaises(lib_exc.BadRequest,
|
||||
getattr(self, client_name).create_access_rule,
|
||||
self.share["id"], "wrong_type", "1.2.3.4")
|
||||
|
@ -445,7 +431,6 @@ class ShareRulesNegativeTest(base.BaseSharesMixedTest):
|
|||
@testtools.skipUnless(CONF.share.run_snapshot_tests,
|
||||
"Snapshot tests are disabled.")
|
||||
def test_create_access_rule_ip_to_snapshot(self, client_name):
|
||||
skip_if_cephx_access_type_not_supported_by_client(self, client_name)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
getattr(self, client_name).create_access_rule,
|
||||
self.snap["id"])
|
||||
|
@ -457,7 +442,6 @@ class ShareRulesAPIOnlyNegativeTest(base.BaseSharesTest):
|
|||
@tc.attr(base.TAG_NEGATIVE, base.TAG_API)
|
||||
@ddt.data('shares_client', 'shares_v2_client')
|
||||
def test_create_access_rule_ip_with_wrong_share_id(self, client_name):
|
||||
skip_if_cephx_access_type_not_supported_by_client(self, client_name)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
getattr(self, client_name).create_access_rule,
|
||||
"wrong_share_id")
|
||||
|
|
Loading…
Reference in New Issue