Joe Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2013 OpenStack Foundation |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
| 18 | import logging |
| 19 | import subprocess |
| 20 | |
Joe Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 21 | import cli |
| 22 | |
| 23 | |
| 24 | LOG = logging.getLogger(__name__) |
| 25 | |
| 26 | |
| 27 | class SimpleReadOnlyNovaManageTest(cli.ClientTestBase): |
| 28 | |
| 29 | """ |
| 30 | This is a first pass at a simple read only nova-manage test. This |
| 31 | only exercises client commands that are read only. |
| 32 | |
| 33 | This should test commands: |
| 34 | * with and without optional parameters |
| 35 | * initially just check return codes, and later test command outputs |
| 36 | |
| 37 | """ |
| 38 | |
| 39 | def test_admin_fake_action(self): |
| 40 | self.assertRaises(subprocess.CalledProcessError, |
| 41 | self.nova_manage, |
| 42 | 'this-does-nova-exist') |
| 43 | |
| 44 | #NOTE(jogo): Commands in order listed in 'nova-manage -h' |
| 45 | |
| 46 | # test flags |
| 47 | def test_help_flag(self): |
| 48 | self.nova_manage('', '-h') |
| 49 | |
Joe Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 50 | def test_version_flag(self): |
Joe Gordon | e8b0e15 | 2013-03-25 13:37:15 -0400 | [diff] [blame] | 51 | # Bug 1159957: nova-manage --version writes to stderr |
Joe Gordon | 0e7cbf8 | 2013-03-25 19:49:12 +0000 | [diff] [blame] | 52 | self.assertNotEqual("", self.nova_manage('', '--version', |
| 53 | merge_stderr=True)) |
Joe Gordon | 488057a | 2013-03-14 22:26:50 +0000 | [diff] [blame] | 54 | self.assertEqual(self.nova_manage('version'), |
Joe Gordon | 0e7cbf8 | 2013-03-25 19:49:12 +0000 | [diff] [blame] | 55 | self.nova_manage('', '--version', merge_stderr=True)) |
Joe Gordon | 488057a | 2013-03-14 22:26:50 +0000 | [diff] [blame] | 56 | |
| 57 | def test_debug_flag(self): |
| 58 | self.assertNotEqual("", self.nova_manage('instance_type list', |
| 59 | '--debug')) |
| 60 | |
| 61 | def test_verbose_flag(self): |
| 62 | self.assertNotEqual("", self.nova_manage('instance_type list', |
| 63 | '--verbose')) |
Joe Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 64 | |
| 65 | # test actions |
| 66 | def test_version(self): |
| 67 | self.assertNotEqual("", self.nova_manage('version')) |
| 68 | |
| 69 | def test_flavor_list(self): |
| 70 | self.assertNotEqual("", self.nova_manage('flavor list')) |
Joe Gordon | 0e7cbf8 | 2013-03-25 19:49:12 +0000 | [diff] [blame] | 71 | self.assertEqual(self.nova_manage('instance_type list'), |
| 72 | self.nova_manage('flavor list')) |
Joe Gordon | 488057a | 2013-03-14 22:26:50 +0000 | [diff] [blame] | 73 | |
| 74 | def test_db_archive_deleted_rows(self): |
| 75 | # make sure command doesn't error out |
| 76 | self.nova_manage('db archive_deleted_rows 50') |
| 77 | |
| 78 | def test_db_sync(self): |
| 79 | # make sure command doesn't error out |
| 80 | self.nova_manage('db sync') |
| 81 | |
| 82 | def test_db_version(self): |
| 83 | self.assertNotEqual("", self.nova_manage('db version')) |