integrate with tempest sanity check

currently this plugin will not work
with tempest sanity check. This will
fix that by ensuring tempest run -l
will run without being pointed at
tempest.conf and tempest.log

Change-Id: I2215c2cc0e6922b4935a6b44c2e415ff6fb2b610
This commit is contained in:
stewie925 2019-07-31 14:38:35 -05:00 committed by Jeremy Houser
parent ad8e669f22
commit a14ad5d3eb
6 changed files with 34 additions and 30 deletions

View File

@ -65,7 +65,8 @@ disable=protected-access,fixme,too-many-branches,
# Crashes, see #743.
redefined-variable-type,
# bug in 1.7.2 https://github.com/PyCQA/pylint/issues/1493
not-callable
not-callable,
C0411
[REPORTS]

View File

@ -21,12 +21,12 @@ from tempest.lib.common.utils import data_utils
LOG = logging.getLogger(__name__)
CONF = config.CONF
identity_url = CONF.identity.uri_v3.strip('/v3')
def rand_region_status(exclude=[]):
def rand_region_status(exclude=None):
exclusion = exclude or []
statuses = {'functional', 'maintenance', 'down', 'building'}.difference(
exclude)
exclusion)
return random.choice(list(statuses))
@ -37,13 +37,16 @@ def rand_region_metadata():
return metadata
def rand_region(id=None):
if id is None:
id = data_utils.rand_name()
def rand_region(data_id=None):
_id = data_id or data_utils.rand_name()
identity_url = CONF.identity.uri_v3 or ""
identity_url = identity_url.strip('/v3')
region_dict = {
'status': rand_region_status(),
'id': id,
'name': id,
'id': _id,
'name': _id,
'designType': data_utils.arbitrary_string(),
'locationType': data_utils.arbitrary_string(),
'vlcpName': data_utils.arbitrary_string(),
@ -76,12 +79,11 @@ def rand_region(id=None):
return region_dict
def rand_region_group(region_ids, id=None):
if id is None:
id = data_utils.rand_name()
def rand_region_group(region_ids, data_id=None):
_id = data_id or data_utils.rand_name()
group_dict = {
'name': id,
'id': id,
'name': _id,
'id': _id,
'description': data_utils.arbitrary_string(),
'regions': region_ids
}

View File

@ -36,13 +36,15 @@ class RangerClientBase(rest_client.RestClient):
rms_url = CONF.ranger.RANGER_RMS_BASE_URL
auth_region = CONF.identity.region
timeout = 10
# def get_keystone_ep(rms_url, region_name):
def get_keystone_ep(self):
"""Get the Keystone EP from tempest conf.
"""
return CONF.identity.uri_v3.strip('/v3')
"""Get the Keystone EP from tempest conf."""
identity_url = CONF.identity.uri_v3 or ""
identity_url = identity_url.strip('/v3')
return identity_url
def get_token(self, timeout, host):
headers = {
@ -87,12 +89,12 @@ class RangerClientBase(rest_client.RestClient):
'Failed in get_token, host: {}, region: {}'.format(host,
region))
url = url % (keystone_ep,)
url = url % (keystone_ep)
data = data % (CONF.auth.admin_domain_name,
CONF.auth.admin_username,
CONF.auth.admin_password,
CONF.auth.admin_project_name,
CONF.auth.admin_domain_name,)
CONF.auth.admin_domain_name)
try:
resp = requests.post(url,
@ -105,10 +107,10 @@ class RangerClientBase(rest_client.RestClient):
resp.status_code))
return resp.headers['x-subject-token']
except Exception as e:
raise ConnectionError(e.message)
except Exception as ex:
raise ConnectionError(ex.message)
def get_headers(self):
def get_headers(self, accept_type=None, send_type=None):
headers = {'X-Auth-Region': CONF.identity.region,
'X-Auth-Token': self.get_token(self.timeout, self.rms_url),
'X-RANGER-Tracking-Id': 'test',
@ -154,7 +156,8 @@ class RangerClientBase(rest_client.RestClient):
class RangerAuthProvider(auth.KeystoneV3AuthProvider):
def __init__(self, credentials, auth_url=CONF.identity.uri_v3):
super(RangerAuthProvider, self).__init__(credentials, auth_url)
_auth = auth_url or ""
super(RangerAuthProvider, self).__init__(credentials, _auth)
def auth_request(self, method, url, headers=None, body=None, filters=None):
filters = {'service': 'identity'}

View File

@ -28,7 +28,8 @@ CONF = config.CONF
class RmsClient(base_client.RangerClientBase):
rms_url = CONF.ranger.RANGER_RMS_BASE_URL
identity_url = CONF.identity.uri_v3.strip('/v3')
identity_url = CONF.identity.uri_v3 or ""
identity_url = identity_url.strip('/v3')
version = "v2"
def create_region(self, region_id, **kwargs):

View File

@ -1,7 +1,7 @@
[DEFAULT]
debug = true
log_file = tempest.log
log_dir =
log_dir = /var/log/
[auth]
test_accounts_file = /opt/stack/tempest/etc/accounts.yaml

View File

@ -44,13 +44,11 @@ whitelist_externals =
bash
# At this time we are only checking for C0103(invalid-name) which in the near
# future will be expanded upon
[testenv:pylint]
sitepackages = True
basepython = python
deps =
pylint==1.7.2
pylint==1.8.2
commands =
bash changed_python_files.sh {toxinidir} "pylint" {posargs}
whitelist_externals =
@ -76,6 +74,5 @@ sitepackages = True
basepython = python
deps = -r requirements.txt
commands =
touch tempest.log
stestr init
tempest run -l --config-file tempest_setup/tempest.conf --log-file tempest.log
tempest run -l