blob: 5b14071958177e9bf2254fd250c2a82fa25cf87a [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
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):
Jay Pipes13b479b2012-06-11 14:52:27 -040029
ivan-zhu40253442013-11-18 16:31:01 +080030 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080031 @test.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')
David Kranz5cf4ba42015-02-10 14:00:50 -050036 extensions = self.extensions_client.list_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)
Matthew Treinish78e28bd2013-11-27 15:58:58 +000046 LOG.debug("Nova extensions: %s" % ','.join(extension_list))
ivan-zhu40253442013-11-18 16:31:01 +080047
Chris Hoge7579c1a2015-02-26 14:12:15 -080048 @test.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 @test.attr(type='gate')
51 def test_get_extension(self):
52 # get the specified extensions
David Kranz5cf4ba42015-02-10 14:00:50 -050053 extension = self.extensions_client.get_extension('os-consoles')
ivan-zhu40253442013-11-18 16:31:01 +080054 self.assertEqual('os-consoles', extension['alias'])