Extend RDS Api tests for CMS Added TC

- test_customer_while_region_down CMS Calls Region Status = down
 - test_customer_while_region_building CMS Calls Region Status = building
 - test_customer_while_region_maintenance CMS Calls Region Status = maintenance

Change-Id: Icddf107572f9a7e4363aefb98c218dde0dbc7070
This commit is contained in:
AbhishekJ 2019-09-06 09:49:31 +00:00
parent 1637826d1e
commit 81eab3597d

View File

@ -15,6 +15,7 @@
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.lib import decorators
@ -45,6 +46,23 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
cls._del_cust_validate_deletion_on_dcp_and_lcp(cls.bare_customer_id)
super(TestTempestCms, cls).resource_cleanup()
def _delete_customer(self, id_, region):
"""Try to delete customer from dcp only"""
self.client.delete_region_from_customer(id_, region)
self._wait_for_status(id_, 'no regions')
self.client.delete_customer(id_)
def _create_region(self, status='functional'):
region_name = data_utils.rand_name()
_, region = self.os_admin.rms_client.create_region(
**{
'region_id': region_name,
'status': status,
}
)
self.addCleanup(self.os_admin.rms_client.delete_region, region_name)
return region
@decorators.idempotent_id('6072c438-1e45-4c0b-97a6-e5127bd33d89')
def test_get_customer(self):
"""Execute 'get_customer' using the following options
@ -342,3 +360,48 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
self._del_cust_validate_deletion_on_dcp_and_lcp(test_customer_id)
self.assertRaises(exceptions.NotFound, self.client.get_customer,
test_customer_id)
@decorators.idempotent_id('b8493b3f-e64d-448e-a965-b0eeff415981')
def test_customer_while_region_down(self):
# create region with status down
region = self._create_region(status='down')
# create customer within that newly created region
cust_body = self._get_customer_params()
cust_body['regions'][0]['name'] = region['name']
self.assertRaises(exceptions.BadRequest,
self.client.create_customer, **cust_body)
@decorators.idempotent_id('1aa52c36-4b1e-459e-9633-12b6cbd53ae7')
def test_customer_while_region_building(self):
# create region with status building
region = self._create_region(status='building')
region_name = region['name']
cust_body = self._get_customer_params()
cust_body['regions'][0]['name'] = region['name']
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)
_, body = self.client.get_customer(test_customer_id)
# since region is building it will give error
# Notification to ORD failed
self.assertEqual(body['status'], 'Error')
self.assertEqual(body['custId'], test_customer_id)
@decorators.idempotent_id('d3cd949e-7895-421c-aeee-2c3d862c391f')
def test_customer_while_region_maintenance(self):
# create region with status maintenance
region = self._create_region(status='maintenance')
region_name = region['name']
cust_body = self._get_customer_params()
cust_body['regions'][0]['name'] = region['name']
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)
# since region is maintenance it will give error
# Notification to ORD failed
self.assertEqual(body['status'], 'Error')
self.assertEqual(body['custId'], test_customer_id)