Client response checking for orchestration service
Updated all orchestration tests to remove the response checks
and move those to respective clients.
Partially Implements blueprint: client-checks-success
Change-Id: If74df1644c6f61b03388e47768f1cffa91fad99c
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index a091ce1..d0fb825 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -51,7 +51,7 @@
@classmethod
def _get_default_network(cls):
- __, networks = cls.network_client.list_networks()
+ _, networks = cls.network_client.list_networks()
for net in networks['networks']:
if net['name'] == CONF.compute.fixed_network_name:
return net
@@ -95,7 +95,7 @@
@classmethod
def _create_keypair(cls, name_start='keypair-heat-'):
kp_name = data_utils.rand_name(name_start)
- __, body = cls.keypairs_client.create_keypair(kp_name)
+ _, body = cls.keypairs_client.create_keypair(kp_name)
cls.keypairs.append(kp_name)
return body
@@ -111,9 +111,9 @@
def _create_image(cls, name_start='image-heat-', container_format='bare',
disk_format='iso'):
image_name = data_utils.rand_name(name_start)
- __, body = cls.images_v2_client.create_image(image_name,
- container_format,
- disk_format)
+ _, body = cls.images_v2_client.create_image(image_name,
+ container_format,
+ disk_format)
image_id = body['id']
cls.images.append(image_id)
return body
@@ -162,8 +162,7 @@
def list_resources(self, stack_identifier):
"""Get a dict mapping of resource names to types."""
- resp, resources = self.client.list_resources(stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, resources = self.client.list_resources(stack_identifier)
self.assertIsInstance(resources, list)
for res in resources:
self.assert_fields_in_dict(res, 'logical_resource_id',
@@ -174,6 +173,5 @@
for r in resources)
def get_stack_output(self, stack_identifier, output_key):
- resp, body = self.client.get_stack(stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, body = self.client.get_stack(stack_identifier)
return self.stack_output(body, output_key)
diff --git a/tempest/api/orchestration/stacks/test_neutron_resources.py b/tempest/api/orchestration/stacks/test_neutron_resources.py
index 26e3ac6..9b9dfec 100644
--- a/tempest/api/orchestration/stacks/test_neutron_resources.py
+++ b/tempest/api/orchestration/stacks/test_neutron_resources.py
@@ -71,11 +71,11 @@
# attempt to log the server console to help with debugging
# the cause of the server not signalling the waitcondition
# to heat.
- resp, body = cls.client.get_resource(cls.stack_identifier,
- 'Server')
+ _, body = cls.client.get_resource(cls.stack_identifier,
+ 'Server')
server_id = body['physical_resource_id']
LOG.debug('Console output for %s', server_id)
- resp, output = cls.servers_client.get_console_output(
+ _, output = cls.servers_client.get_console_output(
server_id, None)
LOG.debug(output)
raise e
@@ -102,8 +102,7 @@
def test_created_network(self):
"""Verifies created network."""
network_id = self.test_resources.get('Network')['physical_resource_id']
- resp, body = self.network_client.show_network(network_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.show_network(network_id)
network = body['network']
self.assertIsInstance(network, dict)
self.assertEqual(network_id, network['id'])
@@ -113,8 +112,7 @@
def test_created_subnet(self):
"""Verifies created subnet."""
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
- resp, body = self.network_client.show_subnet(subnet_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.show_subnet(subnet_id)
subnet = body['subnet']
network_id = self.test_resources.get('Network')['physical_resource_id']
self.assertEqual(subnet_id, subnet['id'])
@@ -129,8 +127,7 @@
def test_created_router(self):
"""Verifies created router."""
router_id = self.test_resources.get('Router')['physical_resource_id']
- resp, body = self.network_client.show_router(router_id)
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.show_router(router_id)
router = body['router']
self.assertEqual('NewRouter', router['name'])
self.assertEqual(self.external_network_id,
@@ -143,8 +140,7 @@
router_id = self.test_resources.get('Router')['physical_resource_id']
network_id = self.test_resources.get('Network')['physical_resource_id']
subnet_id = self.test_resources.get('Subnet')['physical_resource_id']
- resp, body = self.network_client.list_ports()
- self.assertEqual('200', resp['status'])
+ _, body = self.network_client.list_ports()
ports = body['ports']
router_ports = filter(lambda port: port['device_id'] ==
router_id, ports)
@@ -164,8 +160,7 @@
def test_created_server(self):
"""Verifies created sever."""
server_id = self.test_resources.get('Server')['physical_resource_id']
- resp, server = self.servers_client.get_server(server_id)
- self.assertEqual('200', resp['status'])
+ _, server = self.servers_client.get_server(server_id)
self.assertEqual(self.keypair_name, server['key_name'])
self.assertEqual('ACTIVE', server['status'])
network = server['addresses']['NewNetwork'][0]
diff --git a/tempest/api/orchestration/stacks/test_non_empty_stack.py b/tempest/api/orchestration/stacks/test_non_empty_stack.py
index a97c561..72ad5f5 100644
--- a/tempest/api/orchestration/stacks/test_non_empty_stack.py
+++ b/tempest/api/orchestration/stacks/test_non_empty_stack.py
@@ -45,8 +45,7 @@
cls.client.wait_for_stack_status(cls.stack_id, 'CREATE_COMPLETE')
def _list_stacks(self, expected_num=None, **filter_kwargs):
- resp, stacks = self.client.list_stacks(params=filter_kwargs)
- self.assertEqual('200', resp['status'])
+ _, stacks = self.client.list_stacks(params=filter_kwargs)
self.assertIsInstance(stacks, list)
if expected_num is not None:
self.assertEqual(expected_num, len(stacks))
@@ -62,8 +61,7 @@
@test.attr(type='gate')
def test_stack_show(self):
"""Getting details about created stack should be possible."""
- resp, stack = self.client.get_stack(self.stack_name)
- self.assertEqual('200', resp['status'])
+ _, stack = self.client.get_stack(self.stack_name)
self.assertIsInstance(stack, dict)
self.assert_fields_in_dict(stack, 'stack_name', 'id', 'links',
'parameters', 'outputs', 'disable_rollback',
@@ -82,12 +80,10 @@
@test.attr(type='gate')
def test_suspend_resume_stack(self):
"""Suspend and resume a stack."""
- resp, suspend_stack = self.client.suspend_stack(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, suspend_stack = self.client.suspend_stack(self.stack_identifier)
self.client.wait_for_stack_status(self.stack_identifier,
'SUSPEND_COMPLETE')
- resp, resume_stack = self.client.resume_stack(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, resume_stack = self.client.resume_stack(self.stack_identifier)
self.client.wait_for_stack_status(self.stack_identifier,
'RESUME_COMPLETE')
@@ -101,8 +97,8 @@
@test.attr(type='gate')
def test_show_resource(self):
"""Getting details about created resource should be possible."""
- resp, resource = self.client.get_resource(self.stack_identifier,
- self.resource_name)
+ _, resource = self.client.get_resource(self.stack_identifier,
+ self.resource_name)
self.assertIsInstance(resource, dict)
self.assert_fields_in_dict(resource, 'resource_name', 'description',
'links', 'logical_resource_id',
@@ -115,18 +111,16 @@
@test.attr(type='gate')
def test_resource_metadata(self):
"""Getting metadata for created resources should be possible."""
- resp, metadata = self.client.show_resource_metadata(
+ _, metadata = self.client.show_resource_metadata(
self.stack_identifier,
self.resource_name)
- self.assertEqual('200', resp['status'])
self.assertIsInstance(metadata, dict)
self.assertEqual(['Tom', 'Stinky'], metadata.get('kittens', None))
@test.attr(type='gate')
def test_list_events(self):
"""Getting list of created events for the stack should be possible."""
- resp, events = self.client.list_events(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, events = self.client.list_events(self.stack_identifier)
self.assertIsInstance(events, list)
for event in events:
@@ -141,14 +135,13 @@
@test.attr(type='gate')
def test_show_event(self):
"""Getting details about an event should be possible."""
- resp, events = self.client.list_resource_events(self.stack_identifier,
- self.resource_name)
+ _, events = self.client.list_resource_events(self.stack_identifier,
+ self.resource_name)
self.assertNotEqual([], events)
events.sort(key=lambda event: event['event_time'])
event_id = events[0]['id']
- resp, event = self.client.show_event(self.stack_identifier,
- self.resource_name, event_id)
- self.assertEqual('200', resp['status'])
+ _, event = self.client.show_event(self.stack_identifier,
+ self.resource_name, event_id)
self.assertIsInstance(event, dict)
self.assert_fields_in_dict(event, 'resource_name', 'event_time',
'links', 'logical_resource_id',
diff --git a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
index c6f880b..2f58611 100644
--- a/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
+++ b/tempest/api/orchestration/stacks/test_nova_keypair_resources.py
@@ -70,8 +70,7 @@
@test.attr(type='gate')
def test_stack_keypairs_output(self):
- resp, stack = self.client.get_stack(self.stack_name)
- self.assertEqual('200', resp['status'])
+ _, stack = self.client.get_stack(self.stack_name)
self.assertIsInstance(stack, dict)
output_map = {}
diff --git a/tempest/api/orchestration/stacks/test_stacks.py b/tempest/api/orchestration/stacks/test_stacks.py
index d5e66e8..8023f2c 100644
--- a/tempest/api/orchestration/stacks/test_stacks.py
+++ b/tempest/api/orchestration/stacks/test_stacks.py
@@ -28,8 +28,7 @@
@test.attr(type='smoke')
def test_stack_list_responds(self):
- resp, stacks = self.client.list_stacks()
- self.assertEqual('200', resp['status'])
+ _, stacks = self.client.list_stacks()
self.assertIsInstance(stacks, list)
@test.attr(type='smoke')
@@ -45,23 +44,22 @@
self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
# check for stack in list
- resp, stacks = self.client.list_stacks()
+ _, stacks = self.client.list_stacks()
list_ids = list([stack['id'] for stack in stacks])
self.assertIn(stack_id, list_ids)
# fetch the stack
- resp, stack = self.client.get_stack(stack_identifier)
+ _, stack = self.client.get_stack(stack_identifier)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by name
- resp, stack = self.client.get_stack(stack_name)
+ _, stack = self.client.get_stack(stack_name)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# fetch the stack by id
- resp, stack = self.client.get_stack(stack_id)
+ _, stack = self.client.get_stack(stack_id)
self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
# delete the stack
- resp = self.client.delete_stack(stack_identifier)
- self.assertEqual('204', resp[0]['status'])
+ self.client.delete_stack(stack_identifier)
self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE')
diff --git a/tempest/api/orchestration/stacks/test_swift_resources.py b/tempest/api/orchestration/stacks/test_swift_resources.py
index adab8c3..b307be5 100644
--- a/tempest/api/orchestration/stacks/test_swift_resources.py
+++ b/tempest/api/orchestration/stacks/test_swift_resources.py
@@ -63,9 +63,8 @@
def test_created_containers(self):
params = {'format': 'json'}
- resp, container_list = \
+ _, container_list = \
self.account_client.list_account_containers(params=params)
- self.assertEqual('200', resp['status'])
self.assertEqual(2, len(container_list))
for cont in container_list:
self.assertTrue(cont['name'].startswith(self.stack_name))
diff --git a/tempest/api/orchestration/stacks/test_templates.py b/tempest/api/orchestration/stacks/test_templates.py
index 74950a9..0d6060d 100644
--- a/tempest/api/orchestration/stacks/test_templates.py
+++ b/tempest/api/orchestration/stacks/test_templates.py
@@ -39,15 +39,13 @@
@test.attr(type='gate')
def test_show_template(self):
"""Getting template used to create the stack."""
- resp, template = self.client.show_template(self.stack_identifier)
- self.assertEqual('200', resp['status'])
+ _, template = self.client.show_template(self.stack_identifier)
@test.attr(type='gate')
def test_validate_template(self):
"""Validating template passing it content."""
- resp, parameters = self.client.validate_template(self.template,
- self.parameters)
- self.assertEqual('200', resp['status'])
+ _, parameters = self.client.validate_template(self.template,
+ self.parameters)
class TemplateAWSTestJSON(TemplateYAMLTestJSON):
diff --git a/tempest/api/orchestration/stacks/test_update.py b/tempest/api/orchestration/stacks/test_update.py
index a9a43b6..791a19b 100644
--- a/tempest/api/orchestration/stacks/test_update.py
+++ b/tempest/api/orchestration/stacks/test_update.py
@@ -40,11 +40,10 @@
def update_stack(self, stack_identifier, template):
stack_name = stack_identifier.split('/')[0]
- resp = self.client.update_stack(
+ self.client.update_stack(
stack_identifier=stack_identifier,
name=stack_name,
template=template)
- self.assertEqual('202', resp[0]['status'])
self.client.wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
@test.attr(type='gate')
diff --git a/tempest/api/orchestration/stacks/test_volumes.py b/tempest/api/orchestration/stacks/test_volumes.py
index f11ac2a..ff1cfac 100644
--- a/tempest/api/orchestration/stacks/test_volumes.py
+++ b/tempest/api/orchestration/stacks/test_volumes.py
@@ -33,8 +33,7 @@
def _cinder_verify(self, volume_id, template):
self.assertIsNotNone(volume_id)
- resp, volume = self.volumes_client.get_volume(volume_id)
- self.assertEqual(200, resp.status)
+ _, volume = self.volumes_client.get_volume(volume_id)
self.assertEqual('available', volume.get('status'))
self.assertEqual(template['resources']['volume']['properties'][
'size'], volume.get('size'))
diff --git a/tempest/services/orchestration/json/orchestration_client.py b/tempest/services/orchestration/json/orchestration_client.py
index 46b0ec4..dd166dd 100644
--- a/tempest/services/orchestration/json/orchestration_client.py
+++ b/tempest/services/orchestration/json/orchestration_client.py
@@ -41,6 +41,7 @@
uri += '?%s' % urllib.urlencode(params)
resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['stacks']
@@ -58,6 +59,7 @@
files)
uri = 'stacks'
resp, body = self.post(uri, headers=headers, body=body)
+ self.expected_success(201, resp.status)
return resp, body
def update_stack(self, stack_identifier, name, disable_rollback=True,
@@ -74,6 +76,7 @@
uri = "stacks/%s" % stack_identifier
resp, body = self.put(uri, headers=headers, body=body)
+ self.expected_success(202, resp.status)
return resp, body
def _prepare_update_create(self, name, disable_rollback=True,
@@ -106,6 +109,7 @@
"""Returns the details of a single stack."""
url = "stacks/%s" % stack_identifier
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['stack']
@@ -114,6 +118,7 @@
url = 'stacks/%s/actions' % stack_identifier
body = {'suspend': None}
resp, body = self.post(url, json.dumps(body))
+ self.expected_success(200, resp.status)
return resp, body
def resume_stack(self, stack_identifier):
@@ -121,12 +126,14 @@
url = 'stacks/%s/actions' % stack_identifier
body = {'resume': None}
resp, body = self.post(url, json.dumps(body))
+ self.expected_success(200, resp.status)
return resp, body
def list_resources(self, stack_identifier):
"""Returns the details of a single resource."""
url = "stacks/%s/resources" % stack_identifier
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['resources']
@@ -134,12 +141,15 @@
"""Returns the details of a single resource."""
url = "stacks/%s/resources/%s" % (stack_identifier, resource_name)
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['resource']
def delete_stack(self, stack_identifier):
"""Deletes the specified Stack."""
- return self.delete("stacks/%s" % str(stack_identifier))
+ resp, _ = self.delete("stacks/%s" % str(stack_identifier))
+ self.expected_success(204, resp.status)
+ return resp
def wait_for_resource_status(self, stack_identifier, resource_name,
status, failure_pattern='^.*_FAILED$'):
@@ -208,6 +218,7 @@
url = ('stacks/{stack_identifier}/resources/{resource_name}'
'/metadata'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['metadata']
@@ -215,6 +226,7 @@
"""Returns list of all events for a stack."""
url = 'stacks/{stack_identifier}/events'.format(**locals())
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['events']
@@ -223,6 +235,7 @@
url = ('stacks/{stack_identifier}/resources/{resource_name}'
'/events'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['events']
@@ -231,6 +244,7 @@
url = ('stacks/{stack_identifier}/resources/{resource_name}/events'
'/{event_id}'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body['event']
@@ -238,6 +252,7 @@
"""Returns the template for the stack."""
url = ('stacks/{stack_identifier}/template'.format(**locals()))
resp, body = self.get(url)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -245,6 +260,7 @@
"""Returns the validation request result."""
post_body = json.dumps(post_body)
resp, body = self.post('validate', post_body)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return resp, body
@@ -271,7 +287,7 @@
url = 'software_configs'
resp, body = self.post(url, headers=headers, body=body)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -279,7 +295,7 @@
"""Returns a software configuration resource."""
url = 'software_configs/%s' % str(conf_id)
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -287,7 +303,7 @@
"""Deletes a specific software configuration."""
url = 'software_configs/%s' % str(conf_id)
resp, _ = self.delete(url)
- self.expected_success(204, resp)
+ self.expected_success(204, resp.status)
def create_software_deploy(self, server_id=None, config_id=None,
action=None, status=None,
@@ -300,7 +316,7 @@
url = 'software_deployments'
resp, body = self.post(url, headers=headers, body=body)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -315,7 +331,7 @@
url = 'software_deployments/%s' % str(deploy_id)
resp, body = self.put(url, headers=headers, body=body)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -323,7 +339,7 @@
"""Returns a list of all deployments."""
url = 'software_deployments'
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -331,7 +347,7 @@
"""Returns a specific software deployment."""
url = 'software_deployments/%s' % str(deploy_id)
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -339,7 +355,7 @@
"""Return a config metadata for a specific server."""
url = 'software_deployments/metadata/%s' % server_id
resp, body = self.get(url)
- self.expected_success(200, resp)
+ self.expected_success(200, resp.status)
body = json.loads(body)
return body
@@ -347,7 +363,7 @@
"""Deletes a specific software deployment."""
url = 'software_deployments/%s' % str(deploy_id)
resp, _ = self.delete(url)
- self.expected_success(204, resp)
+ self.expected_success(204, resp.status)
def _prep_software_config_create(self, name=None, conf=None, group=None,
inputs=None, outputs=None, options=None):