Allow for variable-domain testing

Ensures that ranger-tempest-plugin
has needed roles in the project
specified so that resource creation
works in domain specified within
ranger's region

Change-Id: I753fbb4ca33f2692fe337f4dd83f3feedfb9b2d6
This commit is contained in:
jh629g 2020-02-24 16:58:35 -06:00
parent 57323cb05d
commit 03f238e85e
17 changed files with 51 additions and 63 deletions

View File

@ -54,9 +54,6 @@ ORM_GROUP_OPTIONS = [
cfg.StrOpt("catalog_type",
default='ranger',
help="ranger catalog type"),
cfg.StrOpt("domain",
default='Default',
help="Domain used for Ranger tempest testing"),
cfg.StrOpt("alt_region_available",
default=False,
help="Alt region for ranger tempest testing"),
@ -64,4 +61,7 @@ ORM_GROUP_OPTIONS = [
default='',
help="Provide alternate region for creating"
"resources with multiple regions"),
cfg.StrOpt("test_rbac",
default=False,
help="Determines if rbac tests should be ran")
]

View File

@ -43,6 +43,7 @@ _region = {
'description': {'type': 'string'},
'designType': {'type': 'string'},
'locationType': {'type': 'string'},
'domainName': {'type': 'string'},
'vlcpName': {'type': 'string'},
'address': {
'type': 'object',
@ -150,7 +151,8 @@ list_region_v1 = {
'OS_version': {'type': 'string'},
'keystone_EP': {'type': 'string'},
'zone_name': {'type': 'string'},
'location_type': {'type': 'string'}
'location_type': {'type': 'string'},
'domain_name': {'type': 'string'}
}
}
}

View File

@ -103,6 +103,7 @@ class RangerClientBase(rest_client.RestClient):
if not CONF.ranger.auth_enabled:
return None
# Only used for ConnectionError message
region = self.auth_region
keystone_ep = self.get_keystone_ep()

View File

@ -31,10 +31,14 @@ class BaseOrmTest(test.BaseTestCase):
build_timeout = 120
build_interval = 10
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(BaseOrmTest, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(BaseOrmTest, cls).setup_clients()
cls.identity_client = cls.os_admin.projects_client
cls.project_client = cls.os_admin.projects_client
cls.region_client = cls.os_admin.rms_client
# Get regions in ranger deployment
@ -42,6 +46,8 @@ class BaseOrmTest(test.BaseTestCase):
region_names = [x['name'] for x in regions_list['regions']]
# Check if region and alt region exist. If not, create those regions.
# NOTE: These region creation statements will be removed when
# ranger-agent has been modified to create regions at deployment
if (CONF.identity.region not in region_names):
cls.region_client.create_region(
CONF.identity.region,
@ -57,9 +63,10 @@ class BaseOrmTest(test.BaseTestCase):
'zip': 'purposes'},
'metadata': {'meta1': ['region']},
'designType': 'large',
'domainName': CONF.auth.admin_domain_name,
'endpoints': [{
'publicURL':
'https://dashboard-ranger.%s.cci.att.com'
'https://dashboard-nc.%s.cci.att.com'
% CONF.identity.region,
'type': 'dashboard'
}, {
@ -88,9 +95,10 @@ class BaseOrmTest(test.BaseTestCase):
'zip': 'purposes'},
'metadata': {'meta1': ['alt_region']},
'designType': 'large',
'domainName': CONF.auth.admin_domain_name,
'endpoints': [{
'publicURL':
'https://dashboard-ranger.%s.cci.att.com'
'https://dashboard-nc.%s.cci.att.com'
% CONF.ranger.alt_region,
'type': 'dashboard'
}, {
@ -103,6 +111,7 @@ class BaseOrmTest(test.BaseTestCase):
% CONF.ranger.alt_region,
'type': 'ord'
}]})
super(BaseOrmTest, cls).setup_clients()
@classmethod
def skip_checks(cls):

View File

@ -239,7 +239,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
default_users_req.append(user["id"])
expected_users_count = len(region_users_req) + len(default_users_req)
actual_users_count = 0
lcp_body = cls.identity_client.list_tenant_users(cust_id)
lcp_body = cls.project_client.list_tenant_users(cust_id)
for user in lcp_body["users"]:
users_lcp.append(user["id"])
dcp_body = cls.client.get_customer(cust_id)
@ -313,7 +313,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
@classmethod
def _validate_customer_deletion_on_lcp(cls, customer_id):
body = cls.identity_client.list_projects()["projects"]
body = cls.project_client.list_projects()["projects"]
customer_ids = [customer["id"]
for customer in body
if customer["id"] == customer_id]

View File

@ -228,7 +228,7 @@ class FmsBaseOrmTest(base.BaseOrmTest):
@classmethod
def _get_project_id(cls, project_name):
body = cls.identity_client.list_projects()
body = cls.project_client.list_projects()
for project in body["projects"]:
if(project["name"] == project_name):
return project["id"]

View File

@ -86,7 +86,7 @@ class ImsBaseOrmTest(base.BaseOrmTest):
@classmethod
def _get_project_id(cls, project_name):
body = cls.identity_client.list_projects()
body = cls.project_client.list_projects()
for project in body["projects"]:
if(project["name"] == project_name):
return project["id"]

View File

@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base
class TestTempestCmsNegative(base.BaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestCmsNegative, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestCmsNegative, cls).setup_clients()

View File

@ -37,11 +37,6 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
region = CONF.identity.region
region_alt = CONF.ranger.alt_region
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestFms, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestFms, cls).setup_clients()

View File

@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base
class TestTempestFmsNegative(base.BaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestFmsNegative, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestFmsNegative, cls).setup_clients()

View File

@ -25,11 +25,6 @@ CONF = config.CONF
class TestTempestIms(ims_base.ImsBaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestIms, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestIms, cls).setup_clients()

View File

@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base
class TestTempestImsNegative(base.BaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestImsNegative, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestImsNegative, cls).setup_clients()

View File

@ -24,16 +24,6 @@ from tempest.lib.common.utils import data_utils
class TestTempestRegionGroup(base.BaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestRegionGroup, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestRegionGroup, cls).setup_clients()
cls.client = cls.os_primary.rms_client
@classmethod
def resource_setup(cls):
cls.setup_ids = []

View File

@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base
class TestTempestRegGroupNegative(base.BaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestRegGroupNegative, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestRegGroupNegative, cls).setup_clients()

View File

@ -18,11 +18,6 @@ from ranger_tempest_plugin.tests.api import base
class TestTempestRegionsNegative(base.BaseOrmTest):
@classmethod
def setup_credentials(cls):
cls.set_network_resources()
super(TestTempestRegionsNegative, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(TestTempestRegionsNegative, cls).setup_clients()

View File

@ -33,6 +33,14 @@ class TestCustomer(rbac_utils.RbacUtilsMixin, cms_base.CmsBaseOrmTest):
super(TestCustomer, cls).setup_clients()
cls.client = cls.os_primary.cms_rbac_client
@classmethod
def skip_checks(cls):
super(TestCustomer, cls).skip_checks()
if not CONF.ranger.test_rbac:
skip_msg = ("%s skipped as this is not an rbac test run"
% cls.__name__)
raise cls.skipException(skip_msg)
@rbac_rule_validation.action(service="ranger",
rules=['customers:get_one'],
expected_error_codes=[403])

View File

@ -15,12 +15,17 @@
from patrole_tempest_plugin import rbac_rule_validation
from patrole_tempest_plugin import rbac_utils
from tempest.lib import decorators
from tempest.lib.common.utils import data_utils
from ranger_tempest_plugin import data_utils as orm_data_utils
from ranger_tempest_plugin.tests.api import rms_base
from tempest import config
from tempest.lib import decorators
from tempest.lib.common.utils import data_utils
CONF = config.CONF
class TestRegion(rbac_utils.RbacUtilsMixin, rms_base.RmsBaseOrmTest):
@ -29,6 +34,14 @@ class TestRegion(rbac_utils.RbacUtilsMixin, rms_base.RmsBaseOrmTest):
super(TestRegion, cls).setup_clients()
cls.client = cls.os_primary.rms_rbac_client
@classmethod
def skip_checks(cls):
super(TestRegion, cls).skip_checks()
if not CONF.ranger.test_rbac:
skip_msg = ("%s skipped as this is not an rbac test run"
% cls.__name__)
raise cls.skipException(skip_msg)
@rbac_rule_validation.action(service='ranger',
rules=['region:get_all'],
expected_error_codes=[403])
@ -62,10 +75,10 @@ class TestRegion(rbac_utils.RbacUtilsMixin, rms_base.RmsBaseOrmTest):
expected_error_codes=[403])
@decorators.idempotent_id('cbb32c8f-f183-42c4-a9d9-61e93d066c5f')
def test_update_region(self):
id = self.setup_ids[-1]
region = orm_data_utils.rand_region(id)
region_id = self.setup_ids[-1]
region = orm_data_utils.rand_region(region_id)
with self.override_role():
self.client.update_region(id, **region)
self.client.update_region(region_id, **region)
@rbac_rule_validation.action(service='ranger',
rules=['region:delete'],