Create Auth Skipcheck

Ranger currently has issue authing with certain
credentials against some keystone environments.
This patchset introduces a skipcheck if it is
found that credentials provided do not allow
the user to execute tests against the site.

Change-Id: I5e3daff3b6ed6b5c4731320f82bb929d3caa6e07
This commit is contained in:
jh629g 2019-09-12 15:02:15 -05:00
parent c01b840ac6
commit aadf73a575
10 changed files with 169 additions and 92 deletions

View File

@ -1,17 +1,16 @@
- project:
name: x/ranger-tempest-plugin
check:
jobs:
- openstack-tox-py36
- openstack-tox-pep8
- ranger-tempest-sanity
- ranger-tox-py27
- ranger-tox-pep8
- ranger-tox-pylint
- ranger-pylint
gate:
jobs:
- openstack-tox-py36
- openstack-tox-pep8
- ranger-tempest-sanity
- ranger-tox-py27
- ranger-tox-pep8
- ranger-tox-pylint
- ranger-pylint
- job:
name: ranger-tempest-sanity
parent: openstack-tox
@ -20,21 +19,7 @@
vars:
tox_envlist: 'tempest-sanity'
- job:
name: ranger-tox-py27
parent: openstack-tox
voting: true
timeout: 900
vars:
tox_envlist: 'py27'
- job:
name: ranger-tox-pep8
parent: openstack-tox
voting: true
timeout: 900
vars:
tox_envlist: 'pep8'
- job:
name: ranger-tox-pylint
name: ranger-pylint
parent: openstack-tox
voting: true
timeout: 900

View File

@ -1,5 +1,5 @@
[flake8]
ignore = E125,E123,E129
ignore = E125,E123,E129,H903
show-source = False
exclude =
.git,

View File

@ -57,6 +57,9 @@ ORM_GROUP_OPTIONS = [
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"),
cfg.StrOpt("region_alt",
default='',
help="Provide alternate region for creating"

View File

@ -39,7 +39,6 @@ class RangerClientBase(rest_client.RestClient):
timeout = 10
# def get_keystone_ep(rms_url, region_name):
def get_keystone_ep(self):
"""Get the Keystone EP from tempest conf."""
identity_url = CONF.identity.uri_v3 or ""

View File

@ -113,7 +113,7 @@ class RmsClient(base_client.RangerClientBase):
def list_regions(self, filter=None):
uri = '%s/%s/orm/regions' % (self.rms_url, self.version)
if filter is not None:
uri += '?' + urllib.urlencode(filter)
uri += '?' + urllib.parse.urlencode(filter)
return self.get_request(uri, schema.list_region)
def delete_region(self, region_id):

View File

@ -15,7 +15,7 @@
from oslo_log import log as logging
from ranger_tempest_plugin import clients
from ranger_tempest_plugin.services import base_client
from tempest import config
from tempest import test
@ -25,17 +25,31 @@ LOG = logging.getLogger(__name__)
class BaseOrmTest(test.BaseTestCase):
credentials = ['admin', 'primary', 'alt']
client_manager = clients.OrmClientManager
credentials = ['admin', 'primary', 'alt']
build_timeout = 120
build_interval = 10
@classmethod
def setup_credentials(cls):
cls.set_network_resources(network=False, subnet=False, router=False)
super(BaseOrmTest, cls).setup_credentials()
@classmethod
def setup_clients(cls):
super(BaseOrmTest, cls).setup_clients()
cls.identity_client = cls.os_admin.projects_client
try:
auth_agent = \
base_client.RangerAuthProvider(cls.os_primary.credentials)
auth_agent.auth_request("GET",
CONF.ranger.ranger_rms_base_url,
headers=[])
except Exception as auth_exception:
skip_msg = ("Ranger was unable to authenticate against keystone."
"due to exception: %s" % str(auth_exception))
raise cls.skipException(skip_msg)
@classmethod
def skip_checks(cls):

View File

@ -92,7 +92,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
region["users"] = [user] if region_users else []
regions = [region]
metadata['my_server_name'] = cust_name
metadata['ocx_cust'] = random.randint(0, 999999999)
metadata['ocx_cust'] = str(random.randint(0, 999999999))
payload["description"] = cust_name
payload["enabled"] = True if enabled else False
payload["name"] = cust_name
@ -254,7 +254,6 @@ class CmsBaseOrmTest(base.BaseOrmTest):
_, region = cls.os_admin.rms_client.get_region(rname)
region_id = region["id"]
cls.client.delete_region_from_customer(customer_id, region_id)
# cls._wait_for_cust_status_on_dcp(customer_id, "no regions")
cls._wait_for_status(customer_id, "no regions")
_, body = cls.client.get_customer(customer_id)
regions_on_customer = [rgn for rgn in body["regions"]]

View File

@ -18,6 +18,8 @@ import random
from ranger_tempest_plugin.data_utils import data_utils
from ranger_tempest_plugin.tests.api import cms_base
from tempest import config
from tempest import test
from tempest.lib import decorators
from tempest.lib import exceptions
@ -60,7 +62,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
'status': status,
}
)
self.addCleanup(self.os_admin.rms_client.delete_region, region_name)
test.addClassResourceCleanup(
self.os_admin.rms_client.delete_region,
region_name)
return region
@decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89')
@ -120,7 +124,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
post_body = self._get_customer_params(enabled=False)
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
# update enabled status from 'False' to 'True' and validate update OK
@ -139,7 +144,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
region_users=False)
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id)
self.assertFalse(body['users'])
@ -164,7 +170,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
default_user_id = post_body["users"][0]["id"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id)
self.assertEqual(default_user_id, body['users'][0]['id'])
@ -189,7 +196,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
default_user_id = post_body["users"][0]["id"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id)
self.assertIn(default_user_id, [x['id'] for x in body['users']])
@ -218,7 +226,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
default_users=False)
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id)
# confirm that the region users body is empty after data creation
@ -243,7 +252,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
region_user_id = post_body["regions"][0]["users"][0]["id"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id)
self.assertTrue(body["regions"][0]["users"])
@ -262,7 +272,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
post_body = self._get_customer_params()
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
# update region user then confirm that update is successful
@ -314,7 +325,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
region_name = post_body["regions"][0]["name"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, customer = self.client.get_customer(test_customer_id)
self.assertTrue(customer["regions"])
@ -330,7 +342,8 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
test_cust_name = post_body['name']
_, body = self.client.create_customer(**post_body)
test_customer_id = body['customer']['id']
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
self._wait_for_status(test_customer_id, 'Success')
_, body = self.client.get_customer(test_cust_name)
@ -383,7 +396,10 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
resp, body = self.client.create_customer(**cust_body)
self.assertIn('id', body['customer'])
test_customer_id = body['customer']['id']
self.addCleanup(self._delete_customer, test_customer_id, region_name)
test.addClassResourceCleanup(
self._delete_customer,
test_customer_id,
region_name)
_, body = self.client.get_customer(test_customer_id)
# since region is building it will give error
# Notification to ORD failed
@ -400,7 +416,10 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
resp, body = self.client.create_customer(**cust_body)
self.assertIn('id', body['customer'])
test_customer_id = body['customer']['id']
self.addCleanup(self._delete_customer, test_customer_id, region_name)
test.addClassResourceCleanup(
self._delete_customer,
test_customer_id,
region_name)
# since region is maintenance it will give error
# Notification to ORD failed
self.assertEqual(body['status'], 'Error')

View File

@ -19,6 +19,7 @@ import uuid
from ranger_tempest_plugin import data_utils as orm_data_utils
from ranger_tempest_plugin.tests.api import fms_base
from tempest import config
from tempest import test
from tempest.lib import decorators
from tempest.lib import exceptions
@ -75,13 +76,16 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
**orm_data_utils.rand_region_group([CONF.identity.region])
)
group_id = body['group']['id']
self.addCleanup(self.rms_client.delete_region_group, group_id)
test.addClassResourceCleanup(
self.rms_client.delete_region_group,
group_id)
return group_id
def _data_setup(self, post_body):
flavor = self._create_flv_and_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_flv_and_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_flv_and_validate_deletion_on_dcp_and_lcp,
flavor["id"])
return flavor
@ -135,8 +139,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
test_flvr_id = body["flavor"]['id']
self._wait_for_flavor_status_on_dcp(test_flvr_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_flv_and_validate_deletion_on_dcp_and_lcp,
# add flavor to tempest cleanup
test.addClassResourceCleanup(
self._del_flv_and_validate_deletion_on_dcp_and_lcp,
test_flvr_id)
# verify flavor record created successfully
@ -147,9 +152,10 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
@classmethod
def resource_cleanup(cls):
# cls.delete_role_to_admin()
flavor_id = cls.flavor['id']
cls._del_flv_and_validate_deletion_on_dcp_and_lcp(flavor_id)
test.addClassResourceCleanup(
cls._del_flv_and_validate_deletion_on_dcp_and_lcp,
flavor_id)
super(TestTempestFms, cls).resource_cleanup()
def _create_region(self, status='functional'):
@ -160,7 +166,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
'status': status,
}
)
self.addCleanup(self.os_admin.rms_client.delete_region, region_name)
test.addClassResourceCleanup(
self.os_admin.rms_client.delete_region,
region_name)
return region
def _delete_flavor(self, flvr_id):
@ -236,7 +244,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
replace_tag_body = {"tags": {"ee": "ff", "gg": "hh"}}
self._exec_tags_function(self.flavor_id, replace_tag_body,
'update', None)
self.addCleanup(self._restore_default_tags, self.flavor_id)
test.addClassResourceCleanup(
self._restore_default_tags,
self.flavor_id)
_, tag_body = self.client.get_tags(self.flavor_id)
self.assertDictEqual(replace_tag_body.get("tags"),
tag_body.get("tags"))
@ -261,7 +271,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
# test delete_all_tags command - run get_tag again and confirm
# that the tag dict is now empty
self._exec_tags_function(self.flavor_id, None, 'delete', None)
self.addCleanup(self._restore_default_tags, self.flavor_id)
test.addClassResourceCleanup(
self._restore_default_tags,
self.flavor_id)
_, tag_body = self.client.get_tags(self.flavor_id)
# assert that tag_body contains nothing
self.assertFalse(tag_body["tags"])
@ -310,9 +322,14 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
def test_update_flvr_extra_specs(self):
# add custom extra spec using update_extra_spec
replace_es_body = {"os_extra_specs": {"z": "zebra", "x": "xray"}}
self._exec_ex_spec_function(self.flavor_id, replace_es_body, 'update',
self._exec_ex_spec_function(
self.flavor_id,
replace_es_body,
'update',
None)
self.addCleanup(self._restore_custom_es, self.flavor_id)
test.addClassResourceCleanup(
self._restore_custom_es,
self.flavor_id)
# assert extra specs update results match expected
_, flvr_ex_specs = self.client.get_extra_specs(self.flavor_id)
@ -342,7 +359,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
# run delete ALL extra specs - note that this will only
# delete custom extra specs, NOT the default extra specs
self._exec_ex_spec_function(self.flavor_id, None, 'delete', None)
self.addCleanup(self._restore_custom_es, self.flavor_id)
test.addClassResourceCleanup(
self._restore_custom_es,
self.flavor_id)
_, flvr_ex_specs = self.client.get_extra_specs(self.flavor_id)
# assert that flavor extra specs now contains only
# the default extra specs
@ -390,7 +409,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
test_flvr_id = flavor['id']
# delete the data and do get_flavor to ensure 404-NotFound response
self._del_flv_and_validate_deletion_on_dcp_and_lcp(test_flvr_id)
test.addResourceCleanup(
self._del_flv_and_validate_deletion_on_dcp_and_lcp,
test_flvr_id)
self.assertRaises(exceptions.NotFound, self.client.get_flavor,
test_flvr_id)
@ -455,7 +476,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
**orm_data_utils.rand_region_group([CONF.identity.region])
)
group_id = body['group']['id']
self.addCleanup(self.rms_client.delete_region_group, group_id)
test.addClassResourceCleanup(
self.rms_client.delete_region_group,
group_id)
post_body = self._get_flavor_params()
region_group = {'name': group_id, 'type': 'group'}
@ -541,7 +564,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
self.assertIn('id', body['flavor'])
test_flvr_id = body['flavor']['id']
self.addCleanup(self._delete_flavor, test_flvr_id)
test.addClassResourceCleanup(
self._delete_flavor,
test_flvr_id)
flavor = self._get_flavor_details(test_flvr_id)
self.assertEqual(flavor['id'], test_flvr_id)
@ -557,7 +582,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
_, body = self.client.create_flavor(**post_body)
self.assertIn('id', body['flavor'])
test_flvr_id = body['flavor']['id']
self.addCleanup(self._delete_flavor, test_flvr_id)
test.addClassResourceCleanup(
self._delete_flavor,
test_flvr_id)
flavor = self._get_flavor_details(test_flvr_id)
self.assertEqual(flavor['id'], test_flvr_id)

View File

@ -1,5 +1,5 @@
# Copyright 2016 AT&T Corp
# All Rights Reserved.
# 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
@ -18,6 +18,8 @@ import uuid
from ranger_tempest_plugin.data_utils import data_utils
from ranger_tempest_plugin.tests.api import ims_base
from tempest import config
from tempest import test
from tempest.lib import decorators
from tempest.lib import exceptions
@ -60,7 +62,8 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
def _data_setup(self, post_body):
image = self._create_img_and_validate_creation_on_dcp_and_lcp(
**post_body)
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
image["id"])
# only check for Success image status if "regions" is not empty
if image["regions"]:
@ -82,7 +85,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
'status': status,
}
)
self.addCleanup(self.os_admin.rms_client.delete_region, region_name)
test.addClassResourceCleanup(
self.os_admin.rms_client.delete_region,
region_name)
return region
@decorators.idempotent_id('2b1bb28b-4151-4e75-ae1b-d21089c3418c')
@ -228,8 +233,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
# do not forget to add this account to tempest cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
@ -242,6 +248,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
post_body = self._get_image_params(set_region=False)
image = self._data_setup(post_body)
test_image_id = image['id']
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# setup region and change 'enabled', 'customers' properties
region["name"] = self.region_id
@ -284,9 +293,12 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
# create region with status down
region = self._create_region(status='down')
# create flavor within that newly created region
# create image within that newly created region
post_body = self._get_image_params()
post_body['regions'][0]['name'] = region['name']
# TODO(JH629G): Determine if flavor resource deletion is necessary here
self.assertRaises(exceptions.BadRequest,
self.client.create_image, **post_body)
@ -301,7 +313,19 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
_, body = self.client.create_image(**post_body)
self.assertIn('id', body['image'])
test_image_id = body['image']['id']
self.addCleanup(self._delete_image, test_image_id)
# add image to tempest cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# jh629g: changed out below code for above,
# on first glance seems to be stronger
# validation of deletion, which should be good
# for stopping resource leaks
# do not forget to add this account to tempest cleanup
# test.addClassResourceCleanup(self._delete_image, test_image_id)
_, body = self.client.get_image(test_image_id)
# since region is building it will give error
@ -321,8 +345,11 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
_, body = self.client.create_image(**post_body)
self.assertIn('id', body['image'])
test_image_id = body['image']['id']
self.addCleanup(self._delete_image, test_image_id)
# add image to tempest cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
_, body = self.client.get_image(test_image_id)
# since region is maintenance it will give error
# Notification to ORD failed
@ -372,8 +399,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
# add image to temepst cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
@ -407,8 +435,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
# add image to tempest cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
@ -428,8 +457,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
# add image to tempest cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)
@ -449,8 +479,9 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
test_image_id = image["id"]
self._wait_for_image_status_on_dcp(test_image_id, 'Success')
# do not forget to add this account to addCleanUp
self.addCleanup(self._del_img_validate_deletion_on_dcp_and_lcp,
# add image to tempest cleanup
test.addClassResourceCleanup(
self._del_img_validate_deletion_on_dcp_and_lcp,
test_image_id)
# verify image record created successfully
_, body = self.client.get_image(test_image_id)