blob: aac635c6e48eb0b0da485cc175d0657bb3ddd692 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Jay Pipes13b479b2012-06-11 14:52:27 -040016
Sean Dague1937d092013-05-17 16:36:38 -040017from tempest.api.compute import base
Christian Schwede1acc63a2013-12-27 15:21:32 +000018from tempest.openstack.common import log as logging
ivan-zhu40253442013-11-18 16:31:01 +080019from tempest import test
Jay Pipes13b479b2012-06-11 14:52:27 -040020
21
Christian Schwede1acc63a2013-12-27 15:21:32 +000022LOG = logging.getLogger(__name__)
23
24
ivan-zhuf2b00502013-10-18 10:06:52 +080025class ExtensionsTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010026 _interface = 'json'
Jay Pipes13b479b2012-06-11 14:52:27 -040027
ivan-zhu40253442013-11-18 16:31:01 +080028 @test.attr(type='gate')
Jay Pipes13b479b2012-06-11 14:52:27 -040029 def test_list_extensions(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050030 # List of all extensions
Matthew Treinish78e28bd2013-11-27 15:58:58 +000031 if len(self.config.compute_feature_enabled.api_extensions) == 0:
32 raise self.skipException('There are not any extensions configured')
Attila Fazekas19044d52013-02-16 07:35:06 +010033 resp, extensions = self.extensions_client.list_extensions()
Jay Pipes13b479b2012-06-11 14:52:27 -040034 self.assertEqual(200, resp.status)
Matthew Treinish78e28bd2013-11-27 15:58:58 +000035 ext = self.config.compute_feature_enabled.api_extensions[0]
36 if ext == 'all':
37 self.assertIn('Hosts', map(lambda x: x['name'], extensions))
38 elif ext:
39 self.assertIn(ext, map(lambda x: x['name'], extensions))
40 else:
41 raise self.skipException('There are not any extensions configured')
42 # Log extensions list
43 extension_list = map(lambda x: x['name'], extensions)
44 LOG.debug("Nova extensions: %s" % ','.join(extension_list))
ivan-zhu40253442013-11-18 16:31:01 +080045
Matthew Treinish78e28bd2013-11-27 15:58:58 +000046 @test.requires_ext(extension='os-consoles', service='compute')
ivan-zhu40253442013-11-18 16:31:01 +080047 @test.attr(type='gate')
48 def test_get_extension(self):
49 # get the specified extensions
50 resp, extension = self.extensions_client.get_extension('os-consoles')
51 self.assertEqual(200, resp.status)
52 self.assertEqual('os-consoles', extension['alias'])
Tiago Mello89126c32012-08-27 11:14:03 -030053
54
Attila Fazekas19044d52013-02-16 07:35:06 +010055class ExtensionsTestXML(ExtensionsTestJSON):
56 _interface = 'xml'