Add tempest id for api tests

This patch add tempest id for each api tests.

Change-Id: I05a9fd2d3274411cd0a372d722e801fff19939ac
Needed-By: https://review.openstack.org/#/c/529836
Co-Authored-By: Zane Bitter <zbitter@redhat.com>
diff --git a/heat_tempest_plugin/tests/api/gabbits/environments.yaml b/heat_tempest_plugin/tests/api/gabbits/environments.yaml
index 7fe1f5b..fe1dc04 100644
--- a/heat_tempest_plugin/tests/api/gabbits/environments.yaml
+++ b/heat_tempest_plugin/tests/api/gabbits/environments.yaml
@@ -4,6 +4,7 @@
 
 tests:
 - name: environment with parameter
+  desc: 8281d088-0c80-4071-a13d-333b309be6ca
   POST: /stacks
   request_headers:
     content-type: application/json
@@ -34,6 +35,7 @@
     location: //stacks/$ENVIRON['PREFIX']-envstack/[a-f0-9-]+/
 
 - name: poll for envstack CREATE_COMPLETE
+  desc: 29899c70-9c94-4e24-8988-df76f7eaaa70
   GET: $LOCATION
   redirects: True
   poll:
@@ -43,6 +45,7 @@
     $.stack.stack_status: CREATE_COMPLETE
 
 - name: get stack output
+  desc: f60dd8df-82d1-4228-8926-54d65ebd12e1
   GET: $LAST_URL/outputs/output_value
   redirects: True
   status: 200
@@ -50,6 +53,7 @@
     $.output.output_value: test
 
 - name: delete envstack
+  desc: 0efde180-cc0e-4f2c-bb18-fa345e8d21ad
   DELETE: /stacks/$ENVIRON['PREFIX']-envstack
   redirects: True
   status: 204
diff --git a/heat_tempest_plugin/tests/api/gabbits/resources.yaml b/heat_tempest_plugin/tests/api/gabbits/resources.yaml
index 6a16240..c20333b 100644
--- a/heat_tempest_plugin/tests/api/gabbits/resources.yaml
+++ b/heat_tempest_plugin/tests/api/gabbits/resources.yaml
@@ -4,6 +4,7 @@
 
 tests:
 - name: create stack with resources
+  desc: 947be7b2-503d-41f5-9843-61be50954f13
   POST: /stacks
   request_headers:
     content-type: application/json
@@ -29,6 +30,7 @@
     location: //stacks/$ENVIRON['PREFIX']-rsrcstack/[a-f0-9-]+/
 
 - name: poll for rsrcstack CREATE_COMPLETE
+  desc: e9eac22f-c3e7-450f-a087-08a8655a6e8e
   GET: $LOCATION
   redirects: True
   poll:
@@ -38,6 +40,7 @@
     $.stack.stack_status: CREATE_COMPLETE
 
 - name: list resources
+  desc: ec53f10d-a89a-4243-8706-629a01ea890f
   GET: $LAST_URL/resources
   request_headers:
     content-type: application/json
@@ -47,6 +50,7 @@
     $.resources[0].resource_status: CREATE_COMPLETE
 
 - name: list filtered resources
+  desc: da07d3d2-9ccc-4fa1-9b1b-9cb3074fe9b9
   GET: $LAST_URL
   request_headers:
     content-type: application/json
@@ -57,6 +61,7 @@
     $.resources: []
 
 - name: show resource
+  desc: 2cbcedc5-0aa7-454e-bf89-a3dd5d379dc1
   GET: $LAST_URL/test
   request_headers:
     content-type: application/json
@@ -65,6 +70,7 @@
     $.resource.attributes.output: test
 
 - name: mark resource unhealthy
+  desc: 6031516b-3a8f-4d1b-8990-81a571b5f956
   PATCH: $LAST_URL
   request_headers:
     content-type: application/json
@@ -74,6 +80,7 @@
   status: 200
 
 - name: show unhealthy resource
+  desc: 9e784490-2e88-49af-8ee7-c4c6aba2be64
   GET: $LAST_URL
   status: 200
   response_json_paths:
@@ -81,10 +88,12 @@
     $.resource.resource_status_reason: 'resource deleted'
 
 - name: signal resource
+  desc: c65a047c-8c7b-4b44-9f5f-bf1069751c5c
   POST: $LAST_URL/signal
   status: 400
 
 - name: delete stack with resources
+  desc: 0edc4fdc-811d-4d27-a0dd-6ec4db2bda6e
   DELETE: /stacks/$ENVIRON['PREFIX']-rsrcstack
   redirects: True
   status: 204
diff --git a/heat_tempest_plugin/tests/api/gabbits/resourcetypes.yaml b/heat_tempest_plugin/tests/api/gabbits/resourcetypes.yaml
index 0730cc8..a259214 100644
--- a/heat_tempest_plugin/tests/api/gabbits/resourcetypes.yaml
+++ b/heat_tempest_plugin/tests/api/gabbits/resourcetypes.yaml
@@ -4,10 +4,12 @@
 
 tests:
 - name: list resource types
+  desc: 5b4db88b-d171-4400-b7a7-a7dc8f597d31
   GET: /resource_types
   status: 200
 
 - name: show resource type
+  desc: cc05d1ef-17f1-430e-bea1-0f6766f7d0b4
   GET: /resource_types/OS::Heat::TestResource
   status: 200
   response_json_paths:
@@ -15,6 +17,7 @@
     $.properties.wait_secs.default: 0
 
 - name: resource type template
+  desc: 5a2164eb-645a-4245-acd7-b222a715fc09
   GET: /resource_types/OS::Heat::TestResource/template
   query_parameters:
     template_type: hot
diff --git a/heat_tempest_plugin/tests/api/gabbits/stacks.yaml b/heat_tempest_plugin/tests/api/gabbits/stacks.yaml
index a36e4ba..9d9328e 100644
--- a/heat_tempest_plugin/tests/api/gabbits/stacks.yaml
+++ b/heat_tempest_plugin/tests/api/gabbits/stacks.yaml
@@ -4,12 +4,14 @@
 
 tests:
 - name: stack list
+  desc: 39c0245e-6055-41cf-9f0e-15adfe55ded6
   GET: /stacks
   status: 200
   response_headers:
     content-type: application/json
 
 - name: create empty stack
+  desc: bde1b827-65fb-47ea-909f-82537e6260d3
   POST: /stacks
   request_headers:
     content-type: application/json
@@ -28,6 +30,7 @@
 
 
 - name: poll for empty CREATE_COMPLETE
+  desc: f575e5c4-2aed-4381-9f0d-2dfcb0640c4b
   GET: $LOCATION
   redirects: True
   poll:
@@ -37,16 +40,19 @@
     $.stack.stack_status: CREATE_COMPLETE
 
 - name: show empty stack
+  desc: 89b233fe-0d55-4959-9289-0b5dabe4e4c9
   GET: $LAST_URL
   redirects: True
   status: 200
 
 - name: delete empty stack
+  desc: 7eca55fe-8300-43b6-a6b8-fb2d99b51911
   DELETE: $LAST_URL
   redirects: True
   status: 204
 
 - name: create stack
+  desc: 56ac2173-97c5-4347-bd32-529a260cfac3
   POST: /stacks
   request_headers:
     content-type: application/json
@@ -74,6 +80,7 @@
     location: //stacks/$ENVIRON['PREFIX']-stack/[a-f0-9-]+/
 
 - name: poll for stack CREATE_COMPLETE
+  desc: 6a0fe2dc-2822-4af3-b606-321ff7ad3de9
   GET: $LOCATION
   redirects: True
   poll:
@@ -83,11 +90,13 @@
     $.stack.stack_status: CREATE_COMPLETE
 
 - name: show stack
+  desc: 9b268607-0335-4667-a613-bccf81e66f8f
   GET: $LAST_URL
   redirects: True
   status: 200
 
 - name: update stack
+  desc: 6bb1ec02-dd19-4b2c-9a6d-866ce666650f
   PUT: $LAST_URL
   request_headers:
     content-type: application/json
@@ -115,6 +124,7 @@
   status: 202
 
 - name: poll for stack UPDATE_COMPLETE
+  desc: 3e280fb3-02b6-44fb-84dd-e04921d47733
   GET: $LAST_URL
   redirects: True
   poll:
@@ -124,6 +134,7 @@
     $.stack.stack_status: UPDATE_COMPLETE
 
 - name: patch update stack
+  desc: 927cea42-a35b-4664-b209-ab2cb34e6ef4
   PATCH: $LAST_URL
   request_headers:
     content-type: application/json
@@ -133,6 +144,7 @@
   status: 202
 
 - name: poll for stack patch UPDATE_COMPLETE
+  desc: a1cfd3b4-2536-4c54-94f4-12093f2ccf3b
   GET: $LAST_URL
   redirects: True
   poll:
@@ -143,6 +155,7 @@
     $.stack.updated_time: /^(?!$HISTORY['poll for stack UPDATE_COMPLETE'].$RESPONSE['$.stack.updated_time'])/
 
 - name: list stack outputs
+  desc: bbd98b50-b75b-44a1-b7e8-0a68fd7c6d33
   GET: $LAST_URL/outputs
   redirects: True
   status: 200
@@ -150,6 +163,7 @@
     $.outputs[0].output_key: output_value
 
 - name: get stack output
+  desc: e761f5d7-70f6-4d95-a11b-e5fa0ecb43d2
   GET: $LAST_URL/output_value
   redirects: True
   status: 200
@@ -157,6 +171,7 @@
     $.output.output_value: new_patched_value
 
 - name: delete stack
+  desc: bcf4c359-0a64-4652-b465-df3f688a9d4d
   DELETE: /stacks/$ENVIRON['PREFIX']-stack
   redirects: True
   status: 204
diff --git a/heat_tempest_plugin/tests/api/gabbits/templates.yaml b/heat_tempest_plugin/tests/api/gabbits/templates.yaml
index 7b67054..0533f4a 100644
--- a/heat_tempest_plugin/tests/api/gabbits/templates.yaml
+++ b/heat_tempest_plugin/tests/api/gabbits/templates.yaml
@@ -4,12 +4,14 @@
 
 tests:
 - name: list template versions
+  desc: cbc28c20-e740-43ef-a01b-b1a39f4a0db3
   GET: /template_versions
   status: 200
   response_json_paths:
     $.template_versions[?(@.version='heat_template_version.2017-02-24')].type: hot
 
 - name: list template functions
+  desc: 721ff23c-8527-480f-a090-1c915b4f8430
   GET: /template_versions/heat_template_version.2016-10-14/functions
   status: 200
   response_json_paths:
@@ -17,6 +19,7 @@
       A function for including a file inline.
 
 - name: template validate
+  desc: f307139b-03d0-4006-92b7-81c86c949727
   POST: /validate
   request_headers:
     content-type: application/json
diff --git a/heat_tempest_plugin/tests/api/test_heat_api.py b/heat_tempest_plugin/tests/api/test_heat_api.py
index bf86839..0a44621 100644
--- a/heat_tempest_plugin/tests/api/test_heat_api.py
+++ b/heat_tempest_plugin/tests/api/test_heat_api.py
@@ -14,13 +14,14 @@
 """A test module to exercise the Heat API with gabbi.  """
 
 import os
+import unittest
 
 from gabbi import driver
 from six.moves.urllib import parse as urlparse
+from tempest import config
 
 from heat_tempest_plugin.common import test
 from heat_tempest_plugin.services import clients
-from tempest import config
 
 TESTS_DIR = 'gabbits'
 
@@ -40,5 +41,26 @@
     os.environ['OS_TOKEN'] = manager.identity_client.auth_token
     os.environ['PREFIX'] = test.rand_name('api')
 
-    return driver.build_tests(test_dir, loader, host=host,
-                              url=endpoint, test_loader_name=__name__)
+    def register_test_case_id(test_case):
+        tempest_id = test_case.test_data.get('desc')
+        test_name = test_case.id()
+        if not tempest_id:
+            raise AssertionError(
+                "No Tempest ID registered for API test %s" % test_name)
+
+        def test_id():
+            return test_name + '[id-%s]' % tempest_id
+
+        test_case.id = test_id
+
+    def register_test_suite_ids(test_suite):
+        for test_case in test_suite:
+            if isinstance(test_case, unittest.TestSuite):
+                register_test_suite_ids(test_case)
+            else:
+                register_test_case_id(test_case)
+
+    api_tests = driver.build_tests(test_dir, loader, host=host,
+                                   url=endpoint, test_loader_name=__name__)
+    register_test_suite_ids(api_tests)
+    return api_tests