Merge "Remove HTTP_SUCCESS from tempest.test module"
diff --git a/tempest/api/compute/keypairs/test_keypairs.py b/tempest/api/compute/keypairs/test_keypairs.py
index ce10fbe..d7884ab 100644
--- a/tempest/api/compute/keypairs/test_keypairs.py
+++ b/tempest/api/compute/keypairs/test_keypairs.py
@@ -28,12 +28,12 @@
         cls.client = cls.keypairs_client
 
     def _delete_keypair(self, keypair_name):
-        resp, _ = self.client.delete_keypair(keypair_name)
+        self.client.delete_keypair(keypair_name)
 
     def _create_keypair(self, keypair_name, pub_key=None):
-        resp, body = self.client.create_keypair(keypair_name, pub_key)
+        body = self.client.create_keypair(keypair_name, pub_key)
         self.addCleanup(self._delete_keypair, keypair_name)
-        return resp, body
+        return body
 
     @test.attr(type='gate')
     def test_keypairs_create_list_delete(self):
@@ -42,7 +42,7 @@
         key_list = list()
         for i in range(3):
             k_name = data_utils.rand_name('keypair-')
-            resp, keypair = self._create_keypair(k_name)
+            keypair = self._create_keypair(k_name)
             # Need to pop these keys so that our compare doesn't fail later,
             # as the keypair dicts from list API doesn't have them.
             keypair.pop('private_key')
@@ -50,8 +50,7 @@
             key_list.append(keypair)
         # Fetch all keypairs and verify the list
         # has all created keypairs
-        resp, fetched_list = self.client.list_keypairs()
-        self.assertEqual(200, resp.status)
+        fetched_list = self.client.list_keypairs()
         # We need to remove the extra 'keypair' element in the
         # returned dict. See comment in keypairs_client.list_keypairs()
         new_list = list()
@@ -68,7 +67,7 @@
     def test_keypair_create_delete(self):
         # Keypair should be created, verified and deleted
         k_name = data_utils.rand_name('keypair-')
-        resp, keypair = self._create_keypair(k_name)
+        keypair = self._create_keypair(k_name)
         private_key = keypair['private_key']
         key_name = keypair['name']
         self.assertEqual(key_name, k_name,
@@ -81,9 +80,8 @@
     def test_get_keypair_detail(self):
         # Keypair should be created, Got details by name and deleted
         k_name = data_utils.rand_name('keypair-')
-        resp, keypair = self._create_keypair(k_name)
-        resp, keypair_detail = self.client.get_keypair(k_name)
-        self.assertEqual(200, resp.status)
+        self._create_keypair(k_name)
+        keypair_detail = self.client.get_keypair(k_name)
         self.assertIn('name', keypair_detail)
         self.assertIn('public_key', keypair_detail)
         self.assertEqual(keypair_detail['name'], k_name,
@@ -106,7 +104,7 @@
                    "LOeB1kYMOBaiUPLQTWXR3JpckqFIQwhIH0zoHlJvZE8hh90"
                    "XcPojYN56tI0OlrGqojbediJYD0rUsJu4weZpbn8vilb3JuDY+jws"
                    "snSA8wzBx3A/8y9Pp1B nova@ubuntu")
-        resp, keypair = self._create_keypair(k_name, pub_key)
+        keypair = self._create_keypair(k_name, pub_key)
         self.assertFalse('private_key' in keypair,
                          "Field private_key is not empty!")
         key_name = keypair['name']
diff --git a/tempest/api/compute/keypairs/test_keypairs_negative.py b/tempest/api/compute/keypairs/test_keypairs_negative.py
index 2cc6f00..4e06d6c 100644
--- a/tempest/api/compute/keypairs/test_keypairs_negative.py
+++ b/tempest/api/compute/keypairs/test_keypairs_negative.py
@@ -66,13 +66,11 @@
     def test_create_keypair_with_duplicate_name(self):
         # Keypairs with duplicate names should not be created
         k_name = data_utils.rand_name('keypair-')
-        resp, _ = self.client.create_keypair(k_name)
-        self.assertEqual(200, resp.status)
+        self.client.create_keypair(k_name)
         # Now try the same keyname to create another key
         self.assertRaises(exceptions.Conflict, self._create_keypair,
                           k_name)
-        resp, _ = self.client.delete_keypair(k_name)
-        self.assertEqual(202, resp.status)
+        self.client.delete_keypair(k_name)
 
     @test.attr(type=['negative', 'gate'])
     def test_create_keypair_with_empty_name_string(self):
diff --git a/tempest/api/compute/servers/test_servers.py b/tempest/api/compute/servers/test_servers.py
index aba6dff..d31b320 100644
--- a/tempest/api/compute/servers/test_servers.py
+++ b/tempest/api/compute/servers/test_servers.py
@@ -62,8 +62,8 @@
         # Specify a keypair while creating a server
 
         key_name = data_utils.rand_name('key')
-        resp, keypair = self.keypairs_client.create_keypair(key_name)
-        resp, body = self.keypairs_client.list_keypairs()
+        self.keypairs_client.create_keypair(key_name)
+        self.keypairs_client.list_keypairs()
         resp, server = self.create_test_server(key_name=key_name)
         self.assertEqual('202', resp['status'])
         self.client.wait_for_server_status(server['id'], 'ACTIVE')
diff --git a/tempest/api/compute/test_authorization.py b/tempest/api/compute/test_authorization.py
index fda4107..cdbaee8 100644
--- a/tempest/api/compute/test_authorization.py
+++ b/tempest/api/compute/test_authorization.py
@@ -68,8 +68,7 @@
         cls.image = cls.images_client.get_image(image_id)
 
         cls.keypairname = data_utils.rand_name('keypair')
-        resp, keypair = \
-            cls.keypairs_client.create_keypair(cls.keypairname)
+        cls.keypairs_client.create_keypair(cls.keypairname)
 
         name = data_utils.rand_name('security')
         description = data_utils.rand_name('description')
@@ -202,7 +201,7 @@
         finally:
             # Next request the base_url is back to normal
             if (resp['status'] is not None):
-                resp, _ = self.alt_keypairs_client.delete_keypair(k_name)
+                self.alt_keypairs_client.delete_keypair(k_name)
                 LOG.error("Create keypair request should not happen "
                           "if the tenant id does not match the current user")
 
diff --git a/tempest/api/orchestration/base.py b/tempest/api/orchestration/base.py
index d3dffbf..97777db 100644
--- a/tempest/api/orchestration/base.py
+++ b/tempest/api/orchestration/base.py
@@ -97,7 +97,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
 
diff --git a/tempest/api/telemetry/base.py b/tempest/api/telemetry/base.py
index e840e3b..8885187 100644
--- a/tempest/api/telemetry/base.py
+++ b/tempest/api/telemetry/base.py
@@ -52,11 +52,11 @@
 
     @classmethod
     def create_alarm(cls, **kwargs):
-        resp, body = cls.telemetry_client.create_alarm(
+        body = cls.telemetry_client.create_alarm(
             name=data_utils.rand_name('telemetry_alarm'),
             type='threshold', **kwargs)
         cls.alarm_ids.append(body['alarm_id'])
-        return resp, body
+        return body
 
     @classmethod
     def create_server(cls):
@@ -100,10 +100,9 @@
         timeout = CONF.compute.build_timeout
         start = timeutils.utcnow()
         while timeutils.delta_seconds(start, timeutils.utcnow()) < timeout:
-            resp, body = self.telemetry_client.list_samples(metric, query)
-            self.assertEqual(resp.status, 200)
+            body = self.telemetry_client.list_samples(metric, query)
             if body:
-                return resp, body
+                return body
             time.sleep(CONF.compute.build_interval)
 
         raise exceptions.TimeoutException(
diff --git a/tempest/api/telemetry/test_telemetry_alarming_api.py b/tempest/api/telemetry/test_telemetry_alarming_api.py
index b45d545..97eb4eb 100644
--- a/tempest/api/telemetry/test_telemetry_alarming_api.py
+++ b/tempest/api/telemetry/test_telemetry_alarming_api.py
@@ -32,8 +32,7 @@
     @test.attr(type="gate")
     def test_alarm_list(self):
         # List alarms
-        resp, alarm_list = self.telemetry_client.list_alarms()
-        self.assertEqual(200, resp.status)
+        alarm_list = self.telemetry_client.list_alarms()
 
         # Verify created alarm in the list
         fetched_ids = [a['alarm_id'] for a in alarm_list]
@@ -47,9 +46,8 @@
     def test_create_update_get_delete_alarm(self):
         # Create an alarm
         alarm_name = data_utils.rand_name('telemetry_alarm')
-        resp, body = self.telemetry_client.create_alarm(
+        body = self.telemetry_client.create_alarm(
             name=alarm_name, type='threshold', threshold_rule=self.rule)
-        self.assertEqual(201, resp.status)
         self.assertEqual(alarm_name, body['name'])
         alarm_id = body['alarm_id']
         self.assertDictContainsSubset(self.rule, body['threshold_rule'])
@@ -59,39 +57,34 @@
                     'threshold': 70.0,
                     'period': 60}
         alarm_name = data_utils.rand_name('telemetry-alarm-update')
-        resp, body = self.telemetry_client.update_alarm(
+        body = self.telemetry_client.update_alarm(
             alarm_id,
             threshold_rule=new_rule,
             name=alarm_name,
             type='threshold')
-        self.assertEqual(200, resp.status)
         self.assertEqual(alarm_name, body['name'])
         self.assertDictContainsSubset(new_rule, body['threshold_rule'])
         # Get and verify details of an alarm after update
-        resp, body = self.telemetry_client.get_alarm(alarm_id)
-        self.assertEqual(200, resp.status)
+        body = self.telemetry_client.get_alarm(alarm_id)
         self.assertEqual(alarm_name, body['name'])
         self.assertDictContainsSubset(new_rule, body['threshold_rule'])
         # Delete alarm and verify if deleted
-        resp, _ = self.telemetry_client.delete_alarm(alarm_id)
-        self.assertEqual(204, resp.status)
+        self.telemetry_client.delete_alarm(alarm_id)
         self.assertRaises(exceptions.NotFound,
                           self.telemetry_client.get_alarm, alarm_id)
 
     @test.attr(type="gate")
     def test_set_get_alarm_state(self):
         alarm_states = ['ok', 'alarm', 'insufficient data']
-        _, alarm = self.create_alarm(threshold_rule=self.rule)
+        alarm = self.create_alarm(threshold_rule=self.rule)
         # Set alarm state and verify
         new_state =\
             [elem for elem in alarm_states if elem != alarm['state']][0]
-        resp, state = self.telemetry_client.alarm_set_state(alarm['alarm_id'],
-                                                            new_state)
-        self.assertEqual(200, resp.status)
+        _, state = self.telemetry_client.alarm_set_state(alarm['alarm_id'],
+                                                         new_state)
         self.assertEqual(new_state, state)
         # Get alarm state and verify
-        resp, state = self.telemetry_client.alarm_get_state(alarm['alarm_id'])
-        self.assertEqual(200, resp.status)
+        _, state = self.telemetry_client.alarm_get_state(alarm['alarm_id'])
         self.assertEqual(new_state, state)
 
     @test.attr(type="gate")
@@ -100,15 +93,13 @@
                 "operator": "or"}
         # Verifies alarm create
         alarm_name = data_utils.rand_name('combination_alarm')
-        resp, body = self.telemetry_client.create_alarm(name=alarm_name,
-                                                        combination_rule=rule,
-                                                        type='combination')
-        self.assertEqual(201, resp.status)
+        body = self.telemetry_client.create_alarm(name=alarm_name,
+                                                  combination_rule=rule,
+                                                  type='combination')
         self.assertEqual(alarm_name, body['name'])
         alarm_id = body['alarm_id']
         self.assertDictContainsSubset(rule, body['combination_rule'])
         # Verify alarm delete
-        resp, _ = self.telemetry_client.delete_alarm(alarm_id)
-        self.assertEqual(204, resp.status)
+        self.telemetry_client.delete_alarm(alarm_id)
         self.assertRaises(exceptions.NotFound,
                           self.telemetry_client.get_alarm, alarm_id)
diff --git a/tempest/cmd/cleanup_service.py b/tempest/cmd/cleanup_service.py
index b6e1663..9c4a5dc 100644
--- a/tempest/cmd/cleanup_service.py
+++ b/tempest/cmd/cleanup_service.py
@@ -244,7 +244,7 @@
 
     def list(self):
         client = self.client
-        _, keypairs = client.list_keypairs()
+        keypairs = client.list_keypairs()
         LOG.debug("List count, %s Keypairs" % len(keypairs))
         return keypairs
 
@@ -778,7 +778,7 @@
 
     def list(self):
         client = self.client
-        _, alarms = client.list_alarms()
+        alarms = client.list_alarms()
         LOG.debug("List count, %s Alarms" % len(alarms))
         return alarms
 
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 504a9f1..889b2dd 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -474,11 +474,10 @@
         LOG.info("checking telemetry")
         for server in self.res['servers']:
             client = client_for_user(server['owner'])
-            response, body = client.telemetry.list_samples(
+            body = client.telemetry.list_samples(
                 'instance',
                 query=('metadata.display_name', 'eq', server['name'])
             )
-            self.assertEqual(response.status, 200)
             self.assertTrue(len(body) >= 1, 'expecting at least one sample')
             self._confirm_telemetry_sample(server, body[-1])
 
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 0fcc75b..b1f5cce 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -160,7 +160,7 @@
             client = self.keypairs_client
         name = data_utils.rand_name(self.__class__.__name__)
         # We don't need to create a keypair by pubkey in scenario
-        resp, body = client.create_keypair(name)
+        body = client.create_keypair(name)
         self.addCleanup(client.delete_keypair, name)
         return body
 
diff --git a/tempest/scenario/test_swift_telemetry_middleware.py b/tempest/scenario/test_swift_telemetry_middleware.py
index e8eb45c..dce6023 100644
--- a/tempest/scenario/test_swift_telemetry_middleware.py
+++ b/tempest/scenario/test_swift_telemetry_middleware.py
@@ -71,7 +71,7 @@
             Otherwise returning False will case _check_samples to be
             called again.
             """
-            _, results = self.telemetry_client.list_samples(
+            results = self.telemetry_client.list_samples(
                 'storage.api.request')
             LOG.debug('got samples %s', results)
 
diff --git a/tempest/services/compute/json/keypairs_client.py b/tempest/services/compute/json/keypairs_client.py
index 69dd9ae..18729c3 100644
--- a/tempest/services/compute/json/keypairs_client.py
+++ b/tempest/services/compute/json/keypairs_client.py
@@ -31,13 +31,13 @@
         # For now we shall adhere to the spec, but the spec for keypairs
         # is yet to be found
         self.validate_response(common_schema.list_keypairs, resp, body)
-        return resp, body['keypairs']
+        return service_client.ResponseBodyList(resp, body['keypairs'])
 
     def get_keypair(self, key_name):
         resp, body = self.get("os-keypairs/%s" % str(key_name))
         body = json.loads(body)
         self.validate_response(schema.get_keypair, resp, body)
-        return resp, body['keypair']
+        return service_client.ResponseBody(resp, body['keypair'])
 
     def create_keypair(self, name, pub_key=None):
         post_body = {'keypair': {'name': name}}
@@ -47,9 +47,9 @@
         resp, body = self.post("os-keypairs", body=post_body)
         body = json.loads(body)
         self.validate_response(schema.create_keypair, resp, body)
-        return resp, body['keypair']
+        return service_client.ResponseBody(resp, body['keypair'])
 
     def delete_keypair(self, key_name):
         resp, body = self.delete("os-keypairs/%s" % str(key_name))
         self.validate_response(schema.delete_keypair, resp, body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
diff --git a/tempest/services/telemetry/json/telemetry_client.py b/tempest/services/telemetry/json/telemetry_client.py
index 2967cfa..dd899e4 100644
--- a/tempest/services/telemetry/json/telemetry_client.py
+++ b/tempest/services/telemetry/json/telemetry_client.py
@@ -45,8 +45,9 @@
         uri = "%s/meters/%s" % (self.uri_prefix, meter_name)
         body = self.serialize(sample_list)
         resp, body = self.post(uri, body)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def helper_list(self, uri, query=None, period=None):
         uri_dict = {}
@@ -59,8 +60,9 @@
         if uri_dict:
             uri += "?%s" % urllib.urlencode(uri_dict)
         resp, body = self.get(uri)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBodyList(resp, body)
 
     def list_resources(self, query=None):
         uri = '%s/resources' % self.uri_prefix
@@ -85,39 +87,45 @@
     def get_resource(self, resource_id):
         uri = '%s/resources/%s' % (self.uri_prefix, resource_id)
         resp, body = self.get(uri)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def get_alarm(self, alarm_id):
         uri = '%s/alarms/%s' % (self.uri_prefix, alarm_id)
         resp, body = self.get(uri)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def delete_alarm(self, alarm_id):
         uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
         resp, body = self.delete(uri)
+        self.expected_success(204, resp.status)
         if body:
             body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def create_alarm(self, **kwargs):
         uri = "%s/alarms" % self.uri_prefix
         body = self.serialize(kwargs)
         resp, body = self.post(uri, body)
+        self.expected_success(201, resp.status)
         body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def update_alarm(self, alarm_id, **kwargs):
         uri = "%s/alarms/%s" % (self.uri_prefix, alarm_id)
         body = self.serialize(kwargs)
         resp, body = self.put(uri, body)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
-        return resp, body
+        return service_client.ResponseBody(resp, body)
 
     def alarm_get_state(self, alarm_id):
         uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
         resp, body = self.get(uri)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
         return resp, body
 
@@ -125,5 +133,6 @@
         uri = "%s/alarms/%s/state" % (self.uri_prefix, alarm_id)
         body = self.serialize(state)
         resp, body = self.put(uri, body)
+        self.expected_success(200, resp.status)
         body = self.deserialize(body)
         return resp, body
diff --git a/tempest/stress/actions/volume_attach_verify.py b/tempest/stress/actions/volume_attach_verify.py
index aa3cad0..3c052ac 100644
--- a/tempest/stress/actions/volume_attach_verify.py
+++ b/tempest/stress/actions/volume_attach_verify.py
@@ -24,7 +24,7 @@
 
     def _create_keypair(self):
         keyname = data_utils.rand_name("key")
-        _, self.key = self.manager.keypairs_client.create_keypair(keyname)
+        self.key = self.manager.keypairs_client.create_keypair(keyname)
 
     def _delete_keypair(self):
         self.manager.keypairs_client.delete_keypair(self.key['name'])
diff --git a/tempest/stress/cleanup.py b/tempest/stress/cleanup.py
index 94d4b30..b52eca9 100644
--- a/tempest/stress/cleanup.py
+++ b/tempest/stress/cleanup.py
@@ -37,7 +37,7 @@
         except Exception:
             pass
 
-    _, keypairs = admin_manager.keypairs_client.list_keypairs()
+    keypairs = admin_manager.keypairs_client.list_keypairs()
     LOG.info("Cleanup::remove %s keypairs" % len(keypairs))
     for k in keypairs:
         try: