Merge "Improve testing of list_extensions for compute"
diff --git a/tempest/api/compute/test_extensions.py b/tempest/api/compute/test_extensions.py
index f9b44d8..56929a3 100644
--- a/tempest/api/compute/test_extensions.py
+++ b/tempest/api/compute/test_extensions.py
@@ -19,7 +19,6 @@
 from tempest.api.compute import base
 from tempest.openstack.common import log as logging
 from tempest import test
-import testtools
 
 
 LOG = logging.getLogger(__name__)
@@ -28,21 +27,25 @@
 class ExtensionsTestJSON(base.BaseV2ComputeTest):
     _interface = 'json'
 
-    @testtools.skipIf(not test.is_extension_enabled('os-consoles', 'compute'),
-                      'os-consoles extension not enabled.')
     @test.attr(type='gate')
     def test_list_extensions(self):
         # List of all extensions
+        if len(self.config.compute_feature_enabled.api_extensions) == 0:
+            raise self.skipException('There are not any extensions configured')
         resp, extensions = self.extensions_client.list_extensions()
-        self.assertIn("extensions", extensions)
-        extension_list = [extension.get('alias')
-                          for extension in extensions.get('extensions', {})]
-        LOG.debug("Nova extensions: %s" % ','.join(extension_list))
         self.assertEqual(200, resp.status)
-        self.assertTrue(self.extensions_client.is_enabled("Consoles"))
+        ext = self.config.compute_feature_enabled.api_extensions[0]
+        if ext == 'all':
+            self.assertIn('Hosts', map(lambda x: x['name'], extensions))
+        elif ext:
+            self.assertIn(ext, map(lambda x: x['name'], extensions))
+        else:
+            raise self.skipException('There are not any extensions configured')
+        # Log extensions list
+        extension_list = map(lambda x: x['name'], extensions)
+        LOG.debug("Nova extensions: %s" % ','.join(extension_list))
 
-    @testtools.skipIf(not test.is_extension_enabled('os-consoles', 'compute'),
-                      'os-consoles extension not enabled.')
+    @test.requires_ext(extension='os-consoles', service='compute')
     @test.attr(type='gate')
     def test_get_extension(self):
         # get the specified extensions
diff --git a/tempest/api/compute/v3/test_extensions.py b/tempest/api/compute/v3/test_extensions.py
index 72dfe14..f37ebcf 100644
--- a/tempest/api/compute/v3/test_extensions.py
+++ b/tempest/api/compute/v3/test_extensions.py
@@ -30,13 +30,20 @@
     @test.attr(type='gate')
     def test_list_extensions(self):
         # List of all extensions
+        if len(self.config.compute_feature_enabled.api_v3_extensions) == 0:
+            raise self.skipException('There are not any extensions configured')
         resp, extensions = self.extensions_client.list_extensions()
-        self.assertIn("extensions", extensions)
-        extension_list = [extension.get('alias')
-                          for extension in extensions.get('extensions', {})]
-        LOG.debug("Nova extensions: %s" % ','.join(extension_list))
         self.assertEqual(200, resp.status)
-        self.assertTrue(self.extensions_client.is_enabled("Consoles"))
+        ext = self.config.compute_feature_enabled.api_v3_extensions[0]
+        if ext == 'all':
+            self.assertIn('Hosts', map(lambda x: x['name'], extensions))
+        elif ext:
+            self.assertIn(ext, map(lambda x: x['name'], extensions))
+        else:
+            raise self.skipException('There are not any extensions configured')
+        # Log extensions list
+        extension_list = map(lambda x: x['name'], extensions)
+        LOG.debug("Nova extensions: %s" % ','.join(extension_list))
 
     @test.attr(type='gate')
     def test_get_extension(self):
diff --git a/tempest/services/compute/json/extensions_client.py b/tempest/services/compute/json/extensions_client.py
index ad5354c..c293f80 100644
--- a/tempest/services/compute/json/extensions_client.py
+++ b/tempest/services/compute/json/extensions_client.py
@@ -31,7 +31,7 @@
         url = 'extensions'
         resp, body = self.get(url)
         body = json.loads(body)
-        return resp, body
+        return resp, body['extensions']
 
     def is_enabled(self, extension):
         _, extensions = self.list_extensions()
diff --git a/tempest/services/compute/v3/json/extensions_client.py b/tempest/services/compute/v3/json/extensions_client.py
index 6e0dc9d..bd8287e 100644
--- a/tempest/services/compute/v3/json/extensions_client.py
+++ b/tempest/services/compute/v3/json/extensions_client.py
@@ -32,7 +32,7 @@
         url = 'extensions'
         resp, body = self.get(url)
         body = json.loads(body)
-        return resp, body
+        return resp, body['extensions']
 
     def is_enabled(self, extension):
         _, extensions = self.list_extensions()
diff --git a/tempest/services/compute/v3/xml/extensions_client.py b/tempest/services/compute/v3/xml/extensions_client.py
index 8f97692..926770e 100644
--- a/tempest/services/compute/v3/xml/extensions_client.py
+++ b/tempest/services/compute/v3/xml/extensions_client.py
@@ -37,7 +37,7 @@
         url = 'extensions'
         resp, body = self.get(url, self.headers)
         body = self._parse_array(etree.fromstring(body))
-        return resp, {'extensions': body}
+        return resp, body
 
     def is_enabled(self, extension):
         _, extensions = self.list_extensions()
diff --git a/tempest/services/compute/xml/extensions_client.py b/tempest/services/compute/xml/extensions_client.py
index b17fc4f..8b7b90a 100644
--- a/tempest/services/compute/xml/extensions_client.py
+++ b/tempest/services/compute/xml/extensions_client.py
@@ -37,7 +37,7 @@
         url = 'extensions'
         resp, body = self.get(url, self.headers)
         body = self._parse_array(etree.fromstring(body))
-        return resp, {'extensions': body}
+        return resp, body
 
     def is_enabled(self, extension):
         _, extensions = self.list_extensions()