blob: f87bf6d304601e9f5413eec0d5723a5bcda5a737 [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
Doug Hellmann583ce2c2015-03-11 14:55:46 +000016from oslo_log import log as logging
Jay Pipes13b479b2012-06-11 14:52:27 -040017
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000019from tempest import config
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080020from tempest.lib import decorators
ivan-zhu40253442013-11-18 16:31:01 +080021from tempest import test
Jay Pipes13b479b2012-06-11 14:52:27 -040022
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000023CONF = config.CONF
24
Jay Pipes13b479b2012-06-11 14:52:27 -040025
Christian Schwede1acc63a2013-12-27 15:21:32 +000026LOG = logging.getLogger(__name__)
27
28
ivan-zhuf2b00502013-10-18 10:06:52 +080029class ExtensionsTestJSON(base.BaseV2ComputeTest):
Jay Pipes13b479b2012-06-11 14:52:27 -040030
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080031 @decorators.idempotent_id('3bb27738-b759-4e0d-a5fa-37d7a6df07d1')
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')
ghanshyamf1f0e192015-08-04 15:56:29 +090036 extensions = self.extensions_client.list_extensions()['extensions']
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000037 ext = CONF.compute_feature_enabled.api_extensions[0]
Matthew Treinish78e28bd2013-11-27 15:58:58 +000038 if ext == 'all':
39 self.assertIn('Hosts', map(lambda x: x['name'], extensions))
40 elif ext:
Matthew Treinish54176ce2014-12-08 21:28:05 +000041 self.assertIn(ext, map(lambda x: x['alias'], extensions))
Matthew Treinish78e28bd2013-11-27 15:58:58 +000042 else:
43 raise self.skipException('There are not any extensions configured')
44 # Log extensions list
Matthew Treinish54176ce2014-12-08 21:28:05 +000045 extension_list = map(lambda x: x['alias'], extensions)
Jordan Pittier525ec712016-12-07 17:51:26 +010046 LOG.debug("Nova extensions: %s", ','.join(extension_list))
ivan-zhu40253442013-11-18 16:31:01 +080047
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080048 @decorators.idempotent_id('05762f39-bdfa-4cdb-9b46-b78f8e78e2fd')
Matthew Treinish78e28bd2013-11-27 15:58:58 +000049 @test.requires_ext(extension='os-consoles', service='compute')
ivan-zhu40253442013-11-18 16:31:01 +080050 def test_get_extension(self):
51 # get the specified extensions
Ken'ichi Ohmichi3de6d982015-04-13 00:20:41 +000052 extension = self.extensions_client.show_extension('os-consoles')
ghanshyamf1f0e192015-08-04 15:56:29 +090053 self.assertEqual('os-consoles', extension['extension']['alias'])