Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 1 | # Copyright (c) 2013 Mirantis Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 12 | # implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | import logging |
| 17 | import subprocess |
| 18 | |
| 19 | from tempest import cli |
| 20 | from tempest import config |
| 21 | from tempest import test |
| 22 | |
| 23 | CONF = config.CONF |
| 24 | |
| 25 | LOG = logging.getLogger(__name__) |
| 26 | |
| 27 | |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 28 | class SimpleReadOnlySaharaClientTest(cli.ClientTestBase): |
| 29 | """Basic, read-only tests for Sahara CLI client. |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 30 | |
| 31 | Checks return values and output of read-only commands. |
| 32 | These tests do not presume any content, nor do they create |
| 33 | their own. They only verify the structure of output if present. |
| 34 | """ |
| 35 | |
| 36 | @classmethod |
| 37 | def setUpClass(cls): |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 38 | if not CONF.service_available.sahara: |
| 39 | msg = "Skipping all Sahara cli tests because it is not available" |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 40 | raise cls.skipException(msg) |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 41 | super(SimpleReadOnlySaharaClientTest, cls).setUpClass() |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 42 | |
| 43 | @test.attr(type='negative') |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 44 | def test_sahara_fake_action(self): |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 45 | self.assertRaises(subprocess.CalledProcessError, |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 46 | self.sahara, |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 47 | 'this-does-not-exist') |
| 48 | |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 49 | def test_sahara_plugins_list(self): |
| 50 | plugins = self.parser.listing(self.sahara('plugin-list')) |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 51 | self.assertTableStruct(plugins, ['name', 'versions', 'title']) |
| 52 | |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 53 | def test_sahara_plugins_show(self): |
| 54 | plugin = self.parser.listing(self.sahara('plugin-show', |
| 55 | params='--name vanilla')) |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 56 | self.assertTableStruct(plugin, ['Property', 'Value']) |
| 57 | |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 58 | def test_sahara_node_group_template_list(self): |
| 59 | plugins = self.parser.listing(self.sahara('node-group-template-list')) |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 60 | self.assertTableStruct(plugins, ['name', 'id', 'plugin_name', |
| 61 | 'node_processes', 'description']) |
| 62 | |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 63 | def test_sahara_cluster_template_list(self): |
| 64 | plugins = self.parser.listing(self.sahara('cluster-template-list')) |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 65 | self.assertTableStruct(plugins, ['name', 'id', 'plugin_name', |
| 66 | 'node_groups', 'description']) |
| 67 | |
Sergey Lukjanov | 9c95a25 | 2014-03-13 23:59:22 +0400 | [diff] [blame] | 68 | def test_sahara_cluster_list(self): |
| 69 | plugins = self.parser.listing(self.sahara('cluster-list')) |
Sergey Lukjanov | 582d1c6 | 2014-01-21 19:51:21 +0400 | [diff] [blame] | 70 | self.assertTableStruct(plugins, ['name', 'id', 'status', 'node_count']) |