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 | |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 16 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 17 | from tempest.api.compute import base |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 18 | from tempest import config |
Christian Schwede | 1acc63a | 2013-12-27 15:21:32 +0000 | [diff] [blame] | 19 | from tempest.openstack.common import log as logging |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 20 | from tempest import test |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 21 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 22 | CONF = config.CONF |
| 23 | |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 24 | |
Christian Schwede | 1acc63a | 2013-12-27 15:21:32 +0000 | [diff] [blame] | 25 | LOG = logging.getLogger(__name__) |
| 26 | |
| 27 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 28 | class ExtensionsTestJSON(base.BaseV2ComputeTest): |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 29 | |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 30 | @test.attr(type='gate') |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 31 | def test_list_extensions(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 32 | # List of all extensions |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 33 | if len(CONF.compute_feature_enabled.api_extensions) == 0: |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 34 | raise self.skipException('There are not any extensions configured') |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 35 | resp, extensions = self.extensions_client.list_extensions() |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 36 | self.assertEqual(200, resp.status) |
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) |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 46 | LOG.debug("Nova extensions: %s" % ','.join(extension_list)) |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 47 | |
Matthew Treinish | 78e28bd | 2013-11-27 15:58:58 +0000 | [diff] [blame] | 48 | @test.requires_ext(extension='os-consoles', service='compute') |
ivan-zhu | 4025344 | 2013-11-18 16:31:01 +0800 | [diff] [blame] | 49 | @test.attr(type='gate') |
| 50 | def test_get_extension(self): |
| 51 | # get the specified extensions |
| 52 | resp, extension = self.extensions_client.get_extension('os-consoles') |
| 53 | self.assertEqual(200, resp.status) |
| 54 | self.assertEqual('os-consoles', extension['alias']) |