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: - project:
name: x/ranger-tempest-plugin
check: check:
jobs: jobs:
- openstack-tox-py36
- openstack-tox-pep8
- ranger-tempest-sanity - ranger-tempest-sanity
- ranger-tox-py27 - ranger-pylint
- ranger-tox-pep8
- ranger-tox-pylint
gate: gate:
jobs: jobs:
- openstack-tox-py36
- openstack-tox-pep8
- ranger-tempest-sanity - ranger-tempest-sanity
- ranger-tox-py27 - ranger-pylint
- ranger-tox-pep8
- ranger-tox-pylint
- job: - job:
name: ranger-tempest-sanity name: ranger-tempest-sanity
parent: openstack-tox parent: openstack-tox
@ -20,21 +19,7 @@
vars: vars:
tox_envlist: 'tempest-sanity' tox_envlist: 'tempest-sanity'
- job: - job:
name: ranger-tox-py27 name: ranger-pylint
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
parent: openstack-tox parent: openstack-tox
voting: true voting: true
timeout: 900 timeout: 900

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@
from oslo_log import log as logging from oslo_log import log as logging
from ranger_tempest_plugin import clients from ranger_tempest_plugin import clients
from ranger_tempest_plugin.services import base_client
from tempest import config from tempest import config
from tempest import test from tempest import test
@ -25,17 +25,31 @@ LOG = logging.getLogger(__name__)
class BaseOrmTest(test.BaseTestCase): class BaseOrmTest(test.BaseTestCase):
credentials = ['admin', 'primary', 'alt']
client_manager = clients.OrmClientManager client_manager = clients.OrmClientManager
credentials = ['admin', 'primary', 'alt']
build_timeout = 120 build_timeout = 120
build_interval = 10 build_interval = 10
@classmethod
def setup_credentials(cls):
cls.set_network_resources(network=False, subnet=False, router=False)
super(BaseOrmTest, cls).setup_credentials()
@classmethod @classmethod
def setup_clients(cls): def setup_clients(cls):
super(BaseOrmTest, cls).setup_clients() super(BaseOrmTest, cls).setup_clients()
cls.identity_client = cls.os_admin.projects_client 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 @classmethod
def skip_checks(cls): def skip_checks(cls):

View File

@ -92,7 +92,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
region["users"] = [user] if region_users else [] region["users"] = [user] if region_users else []
regions = [region] regions = [region]
metadata['my_server_name'] = cust_name 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["description"] = cust_name
payload["enabled"] = True if enabled else False payload["enabled"] = True if enabled else False
payload["name"] = cust_name payload["name"] = cust_name
@ -254,7 +254,6 @@ class CmsBaseOrmTest(base.BaseOrmTest):
_, region = cls.os_admin.rms_client.get_region(rname) _, region = cls.os_admin.rms_client.get_region(rname)
region_id = region["id"] region_id = region["id"]
cls.client.delete_region_from_customer(customer_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") cls._wait_for_status(customer_id, "no regions")
_, body = cls.client.get_customer(customer_id) _, body = cls.client.get_customer(customer_id)
regions_on_customer = [rgn for rgn in body["regions"]] 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.data_utils import data_utils
from ranger_tempest_plugin.tests.api import cms_base from ranger_tempest_plugin.tests.api import cms_base
from tempest import config from tempest import config
from tempest import test
from tempest.lib import decorators from tempest.lib import decorators
from tempest.lib import exceptions from tempest.lib import exceptions
@ -60,7 +62,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
'status': status, '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 return region
@decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89') @decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89')
@ -120,8 +124,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
post_body = self._get_customer_params(enabled=False) post_body = self._get_customer_params(enabled=False)
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
# update enabled status from 'False' to 'True' and validate update OK # update enabled status from 'False' to 'True' and validate update OK
_, body = self.client.get_customer(test_customer_id) _, body = self.client.get_customer(test_customer_id)
@ -139,8 +144,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
region_users=False) region_users=False)
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id) _, body = self.client.get_customer(test_customer_id)
self.assertFalse(body['users']) self.assertFalse(body['users'])
self.assertFalse(body["regions"][0]['users']) self.assertFalse(body["regions"][0]['users'])
@ -164,8 +170,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
default_user_id = post_body["users"][0]["id"] default_user_id = post_body["users"][0]["id"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id) _, body = self.client.get_customer(test_customer_id)
self.assertEqual(default_user_id, body['users'][0]['id']) self.assertEqual(default_user_id, body['users'][0]['id'])
self.assertIn(default_user_id, self.assertIn(default_user_id,
@ -189,8 +196,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
default_user_id = post_body["users"][0]["id"] default_user_id = post_body["users"][0]["id"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id) _, body = self.client.get_customer(test_customer_id)
self.assertIn(default_user_id, [x['id'] for x in body['users']]) self.assertIn(default_user_id, [x['id'] for x in body['users']])
self.assertEqual(body['users'], body['regions'][0]['users']) self.assertEqual(body['users'], body['regions'][0]['users'])
@ -218,8 +226,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
default_users=False) default_users=False)
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id) _, body = self.client.get_customer(test_customer_id)
# confirm that the region users body is empty after data creation # confirm that the region users body is empty after data creation
self.assertFalse(body["regions"][0]["users"]) self.assertFalse(body["regions"][0]["users"])
@ -243,8 +252,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
region_user_id = post_body["regions"][0]["users"][0]["id"] region_user_id = post_body["regions"][0]["users"][0]["id"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, body = self.client.get_customer(test_customer_id) _, body = self.client.get_customer(test_customer_id)
self.assertTrue(body["regions"][0]["users"]) self.assertTrue(body["regions"][0]["users"])
@ -262,8 +272,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
post_body = self._get_customer_params() post_body = self._get_customer_params()
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
# update region user then confirm that update is successful # update region user then confirm that update is successful
put_region_user = self._get_user_params(alt=True) put_region_user = self._get_user_params(alt=True)
@ -314,8 +325,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
region_name = post_body["regions"][0]["name"] region_name = post_body["regions"][0]["name"]
test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp( test_customer_id = self._create_cust_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
_, customer = self.client.get_customer(test_customer_id) _, customer = self.client.get_customer(test_customer_id)
self.assertTrue(customer["regions"]) self.assertTrue(customer["regions"])
_, body = self.client.delete_region_from_customer(test_customer_id, _, body = self.client.delete_region_from_customer(test_customer_id,
@ -330,8 +342,9 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
test_cust_name = post_body['name'] test_cust_name = post_body['name']
_, body = self.client.create_customer(**post_body) _, body = self.client.create_customer(**post_body)
test_customer_id = body['customer']['id'] test_customer_id = body['customer']['id']
self.addCleanup(self._del_cust_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_customer_id) self._del_cust_validate_deletion_on_dcp_and_lcp,
test_customer_id)
self._wait_for_status(test_customer_id, 'Success') self._wait_for_status(test_customer_id, 'Success')
_, body = self.client.get_customer(test_cust_name) _, body = self.client.get_customer(test_cust_name)
self.assertIn(test_customer_id, body['uuid']) self.assertIn(test_customer_id, body['uuid'])
@ -383,7 +396,10 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
resp, body = self.client.create_customer(**cust_body) resp, body = self.client.create_customer(**cust_body)
self.assertIn('id', body['customer']) self.assertIn('id', body['customer'])
test_customer_id = body['customer']['id'] 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) _, body = self.client.get_customer(test_customer_id)
# since region is building it will give error # since region is building it will give error
# Notification to ORD failed # Notification to ORD failed
@ -400,7 +416,10 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
resp, body = self.client.create_customer(**cust_body) resp, body = self.client.create_customer(**cust_body)
self.assertIn('id', body['customer']) self.assertIn('id', body['customer'])
test_customer_id = body['customer']['id'] 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 # since region is maintenance it will give error
# Notification to ORD failed # Notification to ORD failed
self.assertEqual(body['status'], 'Error') 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 import data_utils as orm_data_utils
from ranger_tempest_plugin.tests.api import fms_base from ranger_tempest_plugin.tests.api import fms_base
from tempest import config from tempest import config
from tempest import test
from tempest.lib import decorators from tempest.lib import decorators
from tempest.lib import exceptions from tempest.lib import exceptions
@ -75,14 +76,17 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
**orm_data_utils.rand_region_group([CONF.identity.region]) **orm_data_utils.rand_region_group([CONF.identity.region])
) )
group_id = body['group']['id'] 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 return group_id
def _data_setup(self, post_body): def _data_setup(self, post_body):
flavor = self._create_flv_and_validate_creation_on_dcp_and_lcp( flavor = self._create_flv_and_validate_creation_on_dcp_and_lcp(
**post_body) **post_body)
self.addCleanup(self._del_flv_and_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
flavor["id"]) self._del_flv_and_validate_deletion_on_dcp_and_lcp,
flavor["id"])
return flavor return flavor
def _exec_tags_function(self, flavor_id, req_json, action, para): def _exec_tags_function(self, flavor_id, req_json, action, para):
@ -135,9 +139,10 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
test_flvr_id = body["flavor"]['id'] test_flvr_id = body["flavor"]['id']
self._wait_for_flavor_status_on_dcp(test_flvr_id, 'Success') self._wait_for_flavor_status_on_dcp(test_flvr_id, 'Success')
# do not forget to add this account to addCleanUp # add flavor to tempest cleanup
self.addCleanup(self._del_flv_and_validate_deletion_on_dcp_and_lcp, test.addClassResourceCleanup(
test_flvr_id) self._del_flv_and_validate_deletion_on_dcp_and_lcp,
test_flvr_id)
# verify flavor record created successfully # verify flavor record created successfully
flavor = self._get_flavor_details(test_flvr_id) flavor = self._get_flavor_details(test_flvr_id)
@ -147,9 +152,10 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
@classmethod @classmethod
def resource_cleanup(cls): def resource_cleanup(cls):
# cls.delete_role_to_admin()
flavor_id = cls.flavor['id'] 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() super(TestTempestFms, cls).resource_cleanup()
def _create_region(self, status='functional'): def _create_region(self, status='functional'):
@ -160,7 +166,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
'status': status, '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 return region
def _delete_flavor(self, flvr_id): def _delete_flavor(self, flvr_id):
@ -236,7 +244,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
replace_tag_body = {"tags": {"ee": "ff", "gg": "hh"}} replace_tag_body = {"tags": {"ee": "ff", "gg": "hh"}}
self._exec_tags_function(self.flavor_id, replace_tag_body, self._exec_tags_function(self.flavor_id, replace_tag_body,
'update', None) '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) _, tag_body = self.client.get_tags(self.flavor_id)
self.assertDictEqual(replace_tag_body.get("tags"), self.assertDictEqual(replace_tag_body.get("tags"),
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 # test delete_all_tags command - run get_tag again and confirm
# that the tag dict is now empty # that the tag dict is now empty
self._exec_tags_function(self.flavor_id, None, 'delete', None) 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) _, tag_body = self.client.get_tags(self.flavor_id)
# assert that tag_body contains nothing # assert that tag_body contains nothing
self.assertFalse(tag_body["tags"]) self.assertFalse(tag_body["tags"])
@ -310,9 +322,14 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
def test_update_flvr_extra_specs(self): def test_update_flvr_extra_specs(self):
# add custom extra spec using update_extra_spec # add custom extra spec using update_extra_spec
replace_es_body = {"os_extra_specs": {"z": "zebra", "x": "xray"}} 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(
None) self.flavor_id,
self.addCleanup(self._restore_custom_es, self.flavor_id) replace_es_body,
'update',
None)
test.addClassResourceCleanup(
self._restore_custom_es,
self.flavor_id)
# assert extra specs update results match expected # assert extra specs update results match expected
_, flvr_ex_specs = self.client.get_extra_specs(self.flavor_id) _, 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 # run delete ALL extra specs - note that this will only
# delete custom extra specs, NOT the default extra specs # delete custom extra specs, NOT the default extra specs
self._exec_ex_spec_function(self.flavor_id, None, 'delete', None) 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) _, flvr_ex_specs = self.client.get_extra_specs(self.flavor_id)
# assert that flavor extra specs now contains only # assert that flavor extra specs now contains only
# the default extra specs # the default extra specs
@ -390,7 +409,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
test_flvr_id = flavor['id'] test_flvr_id = flavor['id']
# delete the data and do get_flavor to ensure 404-NotFound response # 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, self.assertRaises(exceptions.NotFound, self.client.get_flavor,
test_flvr_id) test_flvr_id)
@ -455,7 +476,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
**orm_data_utils.rand_region_group([CONF.identity.region]) **orm_data_utils.rand_region_group([CONF.identity.region])
) )
group_id = body['group']['id'] 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() post_body = self._get_flavor_params()
region_group = {'name': group_id, 'type': 'group'} region_group = {'name': group_id, 'type': 'group'}
@ -541,7 +564,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
self.assertIn('id', body['flavor']) self.assertIn('id', body['flavor'])
test_flvr_id = body['flavor']['id'] 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) flavor = self._get_flavor_details(test_flvr_id)
self.assertEqual(flavor['id'], 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) _, body = self.client.create_flavor(**post_body)
self.assertIn('id', body['flavor']) self.assertIn('id', body['flavor'])
test_flvr_id = body['flavor']['id'] 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) flavor = self._get_flavor_details(test_flvr_id)
self.assertEqual(flavor['id'], test_flvr_id) self.assertEqual(flavor['id'], test_flvr_id)

View File

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