Updated sync for alt_region tests, improved status loops
Updated synchronization after gaining better insights into how to utilize oslo_concurrency module. Updated region resource updates to be in resource_setup of base.py for ranger tempest test suite. Improved region status and removal loops to overall improve functionality. Change-Id: I17310dcc46697d4a4541d3ee8355f0669c268e8a
This commit is contained in:
parent
3ad54cf082
commit
0616e8e574
2
flake8rc
2
flake8rc
@ -1,5 +1,5 @@
|
||||
[flake8]
|
||||
ignore = E125,E123,E129,H903,H306
|
||||
ignore = E125,E123,E129,H903,H306,W503
|
||||
show-source = False
|
||||
exclude =
|
||||
.git,
|
||||
|
@ -13,6 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_log import log as logging
|
||||
from ranger_tempest_plugin import clients
|
||||
from tempest import config
|
||||
@ -21,6 +22,9 @@ from tempest import test
|
||||
CONF = config.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
PREFIX = 'alt_region'
|
||||
SYNC = lockutils.synchronized_with_prefix(PREFIX)
|
||||
|
||||
|
||||
class BaseOrmTest(test.BaseTestCase):
|
||||
|
||||
@ -41,21 +45,23 @@ class BaseOrmTest(test.BaseTestCase):
|
||||
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()
|
||||
# Get regions in ranger deployment
|
||||
_, regions_list = cls.region_client.list_regions()
|
||||
regions = [x for x in regions_list['regions']]
|
||||
for region in 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):
|
||||
cls.addClassResourceCleanup(cls.region_client.update_region,
|
||||
region['id'],
|
||||
**region)
|
||||
(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)
|
||||
|
||||
super(BaseOrmTest, cls).setup_clients()
|
||||
cls.addClassResourceCleanup(cls.region_client.update_region,
|
||||
region['id'],
|
||||
**region)
|
||||
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
|
@ -33,6 +33,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(CmsBaseOrmTest, cls).resource_setup()
|
||||
cls.setup_customer = cls._get_customer_params()
|
||||
cls.setup_customer_id = \
|
||||
cls._create_cust_validate_creation_on_dcp_and_lcp(
|
||||
@ -51,8 +52,6 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
cls._del_cust_validate_deletion_on_dcp_and_lcp,
|
||||
cls.bare_customer_id)
|
||||
|
||||
super(CmsBaseOrmTest, cls).resource_setup()
|
||||
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
super(CmsBaseOrmTest, cls).setup_clients()
|
||||
@ -65,7 +64,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
compute["instances"] = "10"
|
||||
compute["key-pairs"] = "10"
|
||||
compute["ram"] = "10"
|
||||
compute["vcpus"] = "51"
|
||||
compute["vcpus"] = "36"
|
||||
compute["metadata-items"] = "34"
|
||||
storage["gigabytes"] = "10"
|
||||
storage["snapshots"] = "10"
|
||||
@ -114,7 +113,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
metadata['my_server_name'] = cust_name
|
||||
metadata['ocx_cust'] = str(random.randint(0, 999999999))
|
||||
customer["description"] = cust_name
|
||||
customer["enabled"] = True if enabled else False
|
||||
customer["enabled"] = bool(enabled)
|
||||
customer["name"] = cust_name
|
||||
customer['metadata'] = metadata
|
||||
customer["regions"] = regions
|
||||
@ -213,8 +212,8 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
body = cls.nova_quotas_client.show_quota_set(cust_id)
|
||||
for param in quota["compute"][0]:
|
||||
if param in body["quota_set"]:
|
||||
if (quota["compute"][0][param] ==
|
||||
str(body["quota_set"][param])):
|
||||
if (quota["compute"][0][param]
|
||||
== str(body["quota_set"][param])):
|
||||
actual_quota_count += 1
|
||||
body = cls.volume_quotas_client.show_quota_set(cust_id)
|
||||
for param in quota["storage"][0]:
|
||||
@ -224,8 +223,8 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
body = cls.networks_quotas_client.show_quotas(cust_id)
|
||||
for param in quota["network"][0]:
|
||||
if param in body["quota_set"]:
|
||||
if (quota["compute"][0][param] ==
|
||||
str(body["quota_set"][param])):
|
||||
if (quota["compute"][0][param]
|
||||
== str(body["quota_set"][param])):
|
||||
actual_quota_count += 1
|
||||
return bool(expected_quota_count == actual_quota_count)
|
||||
|
||||
@ -279,6 +278,15 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
|
||||
time.sleep(cls.build_interval)
|
||||
_, body = cls.client.get_customer(customer_id)
|
||||
loopcount = 0
|
||||
|
||||
while loopcount < 10:
|
||||
for regions_on_customer in body['regions']:
|
||||
if regions_on_customer['name'] == rname:
|
||||
time.sleep(cls.build_interval)
|
||||
_, body = cls.client.get_customer(customer_id)
|
||||
break
|
||||
loopcount += 1
|
||||
|
||||
for regions_on_customer in body['regions']:
|
||||
if regions_on_customer['name'] == rname:
|
||||
|
@ -104,9 +104,8 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
cls._wait_for_flavor_status_on_dcp(flavor_id, flavor_status)
|
||||
cls._validate_flavor_creation_on_lcp(flavor_id)
|
||||
return flavor
|
||||
else:
|
||||
message = "flavor %s not created successfully" % flavor_id
|
||||
raise exceptions.TempestException(message)
|
||||
message = "flavor %s not created successfully" % flavor_id
|
||||
raise exceptions.TempestException(message)
|
||||
|
||||
@classmethod
|
||||
def _wait_for_flavor_status_on_dcp(cls, flavor_id, status):
|
||||
@ -159,8 +158,8 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
if expected_specs[spec] == actual_specs[spec]:
|
||||
actual_specs_count += 1
|
||||
return bool(expected_specs_count == actual_specs_count)
|
||||
return bool(_validate_extra_specs(flavor_orm) and
|
||||
_validate_extra_specs(flavor_lcp))
|
||||
return bool(_validate_extra_specs(flavor_orm)
|
||||
and _validate_extra_specs(flavor_lcp))
|
||||
|
||||
@classmethod
|
||||
def _del_flv_and_validate_deletion_on_dcp_and_lcp(cls, flavor_id):
|
||||
@ -179,21 +178,26 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
cls, flavor_id, rname):
|
||||
cls.client.delete_region_from_flavor(flavor_id, rname)
|
||||
|
||||
delete_loop_counter = 0
|
||||
time.sleep(cls.build_interval)
|
||||
_, body = cls.client.get_flavor(flavor_id)
|
||||
loopcount = 0
|
||||
|
||||
while delete_loop_counter <= 5:
|
||||
delete_loop_counter += 1
|
||||
while loopcount < 10:
|
||||
for regions_on_flavor in body['flavor']['regions']:
|
||||
if regions_on_flavor['name'] == rname:
|
||||
time.sleep(cls.build_interval)
|
||||
_, body = cls.client.get_flavor(flavor_id)
|
||||
continue
|
||||
loopcount += 1
|
||||
|
||||
if delete_loop_counter >= 5:
|
||||
message = \
|
||||
'Region {} failed to get deleted from flavor {}' \
|
||||
.format(rname, flavor_id)
|
||||
raise exceptions.TempestException(message)
|
||||
_, body = cls.client.get_flavor(flavor_id)
|
||||
|
||||
for regions_on_flavor in body['flavor']['regions']:
|
||||
if regions_on_flavor['name'] == rname:
|
||||
message = \
|
||||
'Region {} failed to get deleted from flavor {}' \
|
||||
.format(rname, flavor_id)
|
||||
raise exceptions.TempestException(message)
|
||||
|
||||
@classmethod
|
||||
def _wait_for_flavor_deletion_on_dcp(cls, flavor_id):
|
||||
@ -254,8 +258,8 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
@classmethod
|
||||
def _validate_flv_geometry_on_lcp(cls, flavor_id, post_body):
|
||||
flv = cls.flavors_client.show_flavor(flavor_id)["flavor"]
|
||||
return bool(flv["vcpus"] == int(post_body["vcpus"]) and
|
||||
flv["ram"] == post_body["ram"] and
|
||||
flv["swap"] == int(post_body["swap"]) and
|
||||
flv["disk"] == int(post_body["disk"]) and
|
||||
flv["ephemeral"] == post_body["ephemeral"])
|
||||
return bool(flv["vcpus"] == int(post_body["vcpus"])
|
||||
and flv["ram"] == post_body["ram"]
|
||||
and flv["swap"] == int(post_body["swap"])
|
||||
and flv["disk"] == int(post_body["disk"])
|
||||
and flv["ephemeral"] == post_body["ephemeral"])
|
||||
|
@ -17,7 +17,6 @@ import copy
|
||||
import random
|
||||
import uuid
|
||||
|
||||
from oslo_concurrency import lockutils
|
||||
from ranger_tempest_plugin import data_utils as orm_data_utils
|
||||
from ranger_tempest_plugin.tests.api import cms_base
|
||||
from tempest import config
|
||||
@ -27,8 +26,6 @@ from tempest.lib import exceptions
|
||||
import testtools
|
||||
|
||||
CONF = config.CONF
|
||||
PREFIX = 'ranger'
|
||||
SYNC = lockutils.synchronized_with_prefix(PREFIX)
|
||||
|
||||
|
||||
class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
@ -322,6 +319,7 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
_, body = self.client.get_customer(test_cust_name)
|
||||
self.assertIn(test_customer_id, body['uuid'])
|
||||
|
||||
@cms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('c2f4e842-c0c3-4747-9b10-e86c25fe8283')
|
||||
@ -344,6 +342,7 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
self.assertEqual(body['status'], 'Success')
|
||||
self.assertEqual(len(body['regions']), 2)
|
||||
|
||||
@cms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('5e6f1b6b-bff1-4d30-ba97-4ff66ad47ba9')
|
||||
@ -364,7 +363,7 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
self.assertEqual(body['status'], 'Success')
|
||||
self.assertEqual(len(body['regions']), 2)
|
||||
|
||||
@SYNC('customer')
|
||||
@cms_base.base.SYNC('customer')
|
||||
@decorators.idempotent_id('43785f87-27d5-408d-997f-de602caeb698')
|
||||
def test_replace_customer(self):
|
||||
customer = self._get_bare_customer_params()
|
||||
@ -399,14 +398,17 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
self.assertRaises(exceptions.NotFound, self.client.get_customer,
|
||||
test_customer_id)
|
||||
|
||||
@cms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('b8493b3f-e64d-448e-a965-b0eeff415981')
|
||||
def test_customer_while_region_down(self):
|
||||
# create region with status down
|
||||
self._update_region(CONF.identity.region, status={'status': 'down'})
|
||||
self._update_region(CONF.ranger.alt_region, status={'status': 'down'})
|
||||
|
||||
# create customer within that newly created region
|
||||
cust_body = self._get_customer_params()
|
||||
cust_body['regions'][0]['name'] = CONF.identity.region
|
||||
cust_body['regions'][0]['name'] = CONF.ranger.alt_region
|
||||
self.assertRaises(exceptions.BadRequest,
|
||||
self.client.create_customer, **cust_body)
|
||||
|
||||
@ -515,6 +517,7 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
self.assertDictEqual(self.setup_customer['defaultQuotas'][0],
|
||||
body['defaultQuotas'][0])
|
||||
|
||||
@cms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('4bd683c6-1e1c-4f5d-9f42-6af8ac0b2183')
|
||||
|
@ -27,7 +27,7 @@ import testtools
|
||||
|
||||
|
||||
CONF = config.CONF
|
||||
PREFIX = 'ranger'
|
||||
PREFIX = 'flavor'
|
||||
SYNC = lockutils.synchronized_with_prefix(PREFIX)
|
||||
|
||||
|
||||
@ -327,7 +327,7 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
# ensure there is at least a tag
|
||||
_, tag_body = self.client.get_tags(self.flavor['id'])
|
||||
restore_tags = tag_body
|
||||
self.assertTrue(True if tag_body.get("tags") else False)
|
||||
self.assertTrue(bool(tag_body.get("tags")))
|
||||
|
||||
# test delete_all_tags command - run get_tag again and confirm
|
||||
# that the tag dict is now empty
|
||||
@ -339,7 +339,7 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
# restore deleted tags
|
||||
self._exec_tags_function(self.flavor['id'], restore_tags, 'add', None)
|
||||
|
||||
@SYNC('alt_region')
|
||||
@fms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('ec74d68f-b42a-41a8-9685-ff5eca25ea0c')
|
||||
@ -539,7 +539,7 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
self.assertEqual(flavor_details["status"], "Success")
|
||||
self.assertEqual(flavor_details["disk"], disk)
|
||||
|
||||
@SYNC('alt_region')
|
||||
@fms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('997ca03c-4176-4632-a0c9-7e943b03306c')
|
||||
@ -559,7 +559,7 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
assert self.region or self.alt_region in \
|
||||
flavor['regions'][1]['name']
|
||||
|
||||
@SYNC('alt_region')
|
||||
@fms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('ea2a618e-bd53-460b-bde5-01ea20b417c9')
|
||||
@ -574,7 +574,7 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
self.assertEqual(flavor_details['status'], 'Success')
|
||||
self.assertEqual(len(flavor['regions']), 2)
|
||||
|
||||
@SYNC('alt_region')
|
||||
@fms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('06c81b29-85b6-4edf-ab89-3877c49e23bc')
|
||||
@ -601,7 +601,9 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
self.assertEqual(flavor_details['status'], 'Success')
|
||||
self.assertEqual(flavor['id'], post_body['id'])
|
||||
|
||||
@SYNC('alt_region')
|
||||
@fms_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('37f1909f-3ba2-403c-ba0c-0a11b869d6a1')
|
||||
def test_flavor_while_region_down(self):
|
||||
# update region to status down
|
||||
|
@ -25,7 +25,7 @@ import testtools
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
PREFIX = 'ranger'
|
||||
PREFIX = 'alt_region'
|
||||
SYNC = lockutils.synchronized_with_prefix(PREFIX)
|
||||
|
||||
|
||||
@ -296,7 +296,7 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
|
||||
self.assertRaises(exceptions.NotFound, self.client.get_image,
|
||||
image['id'])
|
||||
|
||||
@SYNC('alt_region')
|
||||
@ims_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('e642fa39-1b69-4d17-8bd1-aee90ea042a3')
|
||||
@ -472,7 +472,7 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
|
||||
image = body["image"]
|
||||
self.assertEqual(image['id'], post_body['id'])
|
||||
|
||||
@SYNC('alt_region')
|
||||
@ims_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('7ae78584-55af-45cb-a4a2-b28cc679699e')
|
||||
@ -502,7 +502,7 @@ class TestTempestIms(ims_base.ImsBaseOrmTest):
|
||||
self.assertEqual(image['status'], 'Success')
|
||||
self.assertEqual(len(image['regions']), 2)
|
||||
|
||||
@SYNC('alt_region')
|
||||
@ims_base.base.SYNC('alt_region', external=True)
|
||||
@testtools.skipUnless(CONF.ranger.alt_region_available,
|
||||
'Alt region not provided, skipping this test')
|
||||
@decorators.idempotent_id('73c97918-2081-4f42-9c1e-6fd7a9fb8735')
|
||||
|
@ -2,6 +2,7 @@
|
||||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
flake8>=3.8
|
||||
hacking>=0.12.0,<0.13 # Apache-2.0
|
||||
coverage>=4.0,!=4.4 # Apache-2.0
|
||||
oslo.config>=5.2.0 # Apache-2.0
|
||||
@ -10,6 +11,7 @@ oslo.log>=3.36.0 # Apache-2.0
|
||||
oslosphinx>=4.7.0 # Apache-2.0
|
||||
oslotest>=1.10.0 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
pylint >= 2.5.3
|
||||
python-subunit>=0.0.18 # Apache-2.0/BSD
|
||||
reno>=1.8.0 # Apache-2.0
|
||||
requests>=2.10.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user