
Several tests because non-functional after git removal and python 3.6 code update. This patchset will ensure that these tests function with current ranger codebase. Also removes erroneous use of rand_region functionality when testing flavors, flavor testing should always use real ranger regions, otherwise database will require manual purging of flavor after it goes into error status. Change-Id: I941b45b62ae1288e5594942d4567dc90fc968842
121 lines
4.9 KiB
Python
Executable File
121 lines
4.9 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.
|
|
|
|
from oslo_log import log as logging
|
|
from ranger_tempest_plugin import clients
|
|
from tempest import config
|
|
from tempest import test
|
|
|
|
CONF = config.CONF
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
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_clients(cls):
|
|
super(BaseOrmTest, cls).setup_clients()
|
|
cls.identity_client = cls.os_admin.projects_client
|
|
cls.region_client = cls.os_admin.rms_client
|
|
|
|
# Get regions in ranger deployment
|
|
_, regions_list = cls.region_client.list_regions()
|
|
region_names = [x['name'] for x in regions_list['regions']]
|
|
|
|
# Check if region and alt region exist. If not, create those regions.
|
|
if (CONF.identity.region not in region_names):
|
|
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': {'meta1': ['region']},
|
|
'designType': 'large',
|
|
'endpoints': [{
|
|
'publicURL':
|
|
'https://dashboard-ranger.%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'
|
|
}]})
|
|
|
|
# TODO(jh629g): configuration of alternate region for testing
|
|
# this plugin needs to be refactored to ensure all region
|
|
# creation in this plugin exists in only one place.
|
|
if (CONF.ranger.alt_region not in region_names) and \
|
|
CONF.ranger.alt_region_available is True:
|
|
cls.region_client.create_region(
|
|
CONF.ranger.alt_region,
|
|
**{'status': 'functional',
|
|
'rangerAgentVersion': '3.0',
|
|
'OSVersion': 'stein',
|
|
'CLLI': '123450',
|
|
'address': {'country': 'This', 'state': 'region',
|
|
'city': 'is for', 'street': 'test',
|
|
'zip': 'purposes'},
|
|
'metadata': {'meta1': ['alt_region']},
|
|
'designType': 'large',
|
|
'endpoints': [{
|
|
'publicURL':
|
|
'https://dashboard-ranger.%s.cci.att.com'
|
|
% CONF.ranger.alt_region,
|
|
'type': 'dashboard'
|
|
}, {
|
|
'publicURL': 'https://identity-nc.%s.cci.att.com'
|
|
% CONF.ranger.alt_region,
|
|
'type': 'identity'
|
|
}, {
|
|
'publicURL':
|
|
'https://ranger-agent-nc.%s.cci.att.com'
|
|
% CONF.ranger.alt_region,
|
|
'type': 'ord'
|
|
}]})
|
|
|
|
@classmethod
|
|
def skip_checks(cls):
|
|
super(BaseOrmTest, cls).skip_checks()
|
|
if not CONF.service_available.ranger:
|
|
skip_msg = ("%s skipped as ranger is not available" % cls.__name__)
|
|
raise cls.skipException(skip_msg)
|
|
# ranger service availability should not be in conf. It should be set
|
|
# by ranger pods during deployment to a site.
|
|
|
|
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)
|