blob: 55146e5f2e7a821a3f2183a8ff23be6db49d2384 [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
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000018from tempest import config
Christian Schwede1acc63a2013-12-27 15:21:32 +000019from tempest.openstack.common import log as logging
ivan-zhu40253442013-11-18 16:31:01 +080020from tempest import test
Jay Pipes13b479b2012-06-11 14:52:27 -040021
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000022CONF = config.CONF
23
Jay Pipes13b479b2012-06-11 14:52:27 -040024
Christian Schwede1acc63a2013-12-27 15:21:32 +000025LOG = logging.getLogger(__name__)
26
27
ivan-zhuf2b00502013-10-18 10:06:52 +080028class ExtensionsTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010029 _interface = 'json'
Jay Pipes13b479b2012-06-11 14:52:27 -040030
ivan-zhu40253442013-11-18 16:31:01 +080031 @test.attr(type='gate')
Jay Pipes13b479b2012-06-11 14:52:27 -040032 def test_list_extensions(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050033 # List of all extensions
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000034 if len(CONF.compute_feature_enabled.api_extensions) == 0:
Matthew Treinish78e28bd2013-11-27 15:58:58 +000035 raise self.skipException('There are not any extensions configured')
Attila Fazekas19044d52013-02-16 07:35:06 +010036 resp, extensions = self.extensions_client.list_extensions()
Jay Pipes13b479b2012-06-11 14:52:27 -040037 self.assertEqual(200, resp.status)
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000038 ext = CONF.compute_feature_enabled.api_extensions[0]
Matthew Treinish78e28bd2013-11-27 15:58:58 +000039 if ext == 'all':
40 self.assertIn('Hosts', map(lambda x: x['name'], extensions))
41 elif ext:
42 self.assertIn(ext, map(lambda x: x['name'], extensions))
43 else:
44 raise self.skipException('There are not any extensions configured')
45 # Log extensions list
46 extension_list = map(lambda x: x['name'], extensions)
47 LOG.debug("Nova extensions: %s" % ','.join(extension_list))
ivan-zhu40253442013-11-18 16:31:01 +080048
Matthew Treinish78e28bd2013-11-27 15:58:58 +000049 @test.requires_ext(extension='os-consoles', service='compute')
ivan-zhu40253442013-11-18 16:31:01 +080050 @test.attr(type='gate')
51 def test_get_extension(self):
52 # get the specified extensions
53 resp, extension = self.extensions_client.get_extension('os-consoles')
54 self.assertEqual(200, resp.status)
55 self.assertEqual('os-consoles', extension['alias'])
Tiago Mello89126c32012-08-27 11:14:03 -030056
57
Attila Fazekas19044d52013-02-16 07:35:06 +010058class ExtensionsTestXML(ExtensionsTestJSON):
59 _interface = 'xml'