
This patch also: (1) changed the order base resource setup is called for RMS and IMS test modules (2) added extra skip check for the RMS and IMS test module Change-Id: I24332c053250f36f0998dae089f327f3bf1ec34f
126 lines
5.1 KiB
Python
Executable File
126 lines
5.1 KiB
Python
Executable File
# Copyright 2016 AT&T Corp
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import oslo_concurrency
|
|
|
|
from oslo_log import log as logging
|
|
from ranger_tempest_plugin import clients
|
|
from tempest import config
|
|
from tempest import test
|
|
from tempest.lib import exceptions
|
|
|
|
CONF = config.CONF
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
PREFIX = 'alt_region'
|
|
oslo_concurrency.lockutils.set_defaults(CONF.oslo_concurrency.lock_path)
|
|
SYNC = oslo_concurrency.lockutils.synchronized_with_prefix(PREFIX)
|
|
|
|
|
|
class BaseOrmTest(test.BaseTestCase):
|
|
|
|
client_manager = clients.OrmClientManager
|
|
credentials = ['admin', 'primary', 'alt']
|
|
identity_url = CONF.identity.uri_v3 or ""
|
|
identity_url = identity_url.strip('/v3')
|
|
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):
|
|
cls.project_client = cls.os_admin.projects_client
|
|
cls.region_client = cls.os_admin.rms_client
|
|
|
|
super(BaseOrmTest, cls).setup_clients()
|
|
|
|
@classmethod
|
|
def resource_setup(cls):
|
|
super(BaseOrmTest, cls).resource_setup()
|
|
try:
|
|
# check if ranger region exists
|
|
cls.region_client.get_region(CONF.identity.region)
|
|
except exceptions.Unauthorized:
|
|
# delete test region
|
|
cls.addClassResourceCleanup(cls.region_client.delete_region,
|
|
CONF.identity.region)
|
|
# create region for testing if it doesnt exist
|
|
cls.region_client.create_region(
|
|
CONF.identity.region,
|
|
**{'id': CONF.identity.region,
|
|
'name': CONF.identity.region,
|
|
'description': 'region for testing',
|
|
'status': 'functional',
|
|
'rangerAgentVersion': '3.0',
|
|
'OSVersion': 'stein',
|
|
'CLLI': '123450',
|
|
'address': {'country': 'This', 'state': 'region',
|
|
'city': 'is for', 'street': 'test',
|
|
'zip': 'purposes'},
|
|
'metadata': {},
|
|
'designType': 'large',
|
|
'domainName': CONF.auth.admin_domain_name,
|
|
'endpoints': [{
|
|
'publicURL':
|
|
'https://dashboard-nc.%s.cci.att.com'
|
|
% CONF.identity.region,
|
|
'type': 'dashboard'
|
|
}, {
|
|
'publicURL': cls.identity_url,
|
|
'type': 'identity'
|
|
}, {
|
|
'publicURL':
|
|
'https://ranger-agent-nc.%s.cci.att.com'
|
|
% CONF.identity.region,
|
|
'type': 'ord'
|
|
}]})
|
|
except (exceptions.UnexpectedResponseCode, exceptions.NotFound):
|
|
raise cls.skipException("Test skipped, Ranger site not available")
|
|
|
|
try:
|
|
# alt_region_available is True, skip tests and warn
|
|
# if alt_region doesn't exist
|
|
if CONF.ranger.alt_region_available is True:
|
|
cls.region_client.get_region(CONF.ranger.alt_region)
|
|
except exceptions.Unauthorized:
|
|
skip_msg = ("Tests skipped as Ranger alt region does not exist."
|
|
" Create alternate ranger region before running"
|
|
" these tests again or change alt_region_available"
|
|
" to False to run against one site.")
|
|
raise cls.skipException(skip_msg)
|
|
|
|
# Get regions in ranger deployment
|
|
_, regions_list = cls.region_client.list_regions()
|
|
for region in regions_list['regions']:
|
|
if region['id'] == CONF.identity.region or \
|
|
(region['id'] == CONF.ranger.alt_region
|
|
and CONF.ranger.alt_region_available is True):
|
|
region['domainName'] = CONF.auth.admin_domain_name
|
|
cls.region_client.update_region(region['id'],
|
|
**region)
|
|
cls.addClassResourceCleanup(cls.region_client.update_region,
|
|
region['id'],
|
|
**region)
|
|
|
|
def assert_expected(self, expected, actual, excluded_keys):
|
|
for key, value in list(expected.items()):
|
|
if key not in excluded_keys:
|
|
self.assertIn(key, actual)
|
|
self.assertEqual(value, actual[key], key)
|