ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 2 | # 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 Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 16 | from oslo_log import log as logging |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 17 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 19 | from tempest import config |
Ken'ichi Ohmichi | 6c92edf | 2017-01-27 17:32:10 -0800 | [diff] [blame] | 20 | from tempest.lib import decorators |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 21 | from tempest import test |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 22 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 23 | CONF = config.CONF |
| 24 | |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 25 | |
Christian Schwede | 1acc63a | 2013-12-27 15:21:32 +0000 | [diff] [blame] | 26 | LOG = logging.getLogger(__name__) |
| 27 | |
| 28 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 29 | class ExtensionsTestJSON(base.BaseV2ComputeTest): |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 30 | |
Ken'ichi Ohmichi | 6c92edf | 2017-01-27 17:32:10 -0800 | [diff] [blame] | 31 | @decorators.idempotent_id('3bb27738-b759-4e0d-a5fa-37d7a6df07d1') |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 32 | def test_list_extensions(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 33 | # List of all extensions |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 34 | if len(CONF.compute_feature_enabled.api_extensions) == 0: |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 35 | raise self.skipException('There are not any extensions configured') |
ghanshyam | f1f0e19 | 2015-08-04 15:56:29 +0900 | [diff] [blame] | 36 | extensions = self.extensions_client.list_extensions()['extensions'] |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 37 | ext = CONF.compute_feature_enabled.api_extensions[0] |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 38 | if ext == 'all': |
| 39 | self.assertIn('Hosts', map(lambda x: x['name'], extensions)) |
| 40 | elif ext: |
Matthew Treinish | 54176ce | 2014-12-08 21:28:05 +0000 | [diff] [blame] | 41 | self.assertIn(ext, map(lambda x: x['alias'], extensions)) |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 42 | else: |
| 43 | raise self.skipException('There are not any extensions configured') |
| 44 | # Log extensions list |
Matthew Treinish | 54176ce | 2014-12-08 21:28:05 +0000 | [diff] [blame] | 45 | extension_list = map(lambda x: x['alias'], extensions) |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 46 | LOG.debug("Nova extensions: %s", ','.join(extension_list)) |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 47 | |
Ken'ichi Ohmichi | 6c92edf | 2017-01-27 17:32:10 -0800 | [diff] [blame] | 48 | @decorators.idempotent_id('05762f39-bdfa-4cdb-9b46-b78f8e78e2fd') |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 49 | @test.requires_ext(extension='os-consoles', service='compute') |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 50 | def test_get_extension(self): |
| 51 | # get the specified extensions |
Ken'ichi Ohmichi | 3de6d98 | 2015-04-13 00:20:41 +0000 | [diff] [blame] | 52 | extension = self.extensions_client.show_extension('os-consoles') |
ghanshyam | f1f0e19 | 2015-08-04 15:56:29 +0900 | [diff] [blame] | 53 | self.assertEqual('os-consoles', extension['extension']['alias']) |