blob: bbcc5b10b9611f7bc76448f7a5fbf168e3bae11b [file] [log] [blame]
Joe Gordon4edb6452013-03-05 21:18:59 +00001# 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
18import logging
19import subprocess
20
Joe Gordon4edb6452013-03-05 21:18:59 +000021import cli
22
23
24LOG = logging.getLogger(__name__)
25
26
27class 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 Gordon4edb6452013-03-05 21:18:59 +000050 def test_version_flag(self):
Joe Gordone8b0e152013-03-25 13:37:15 -040051 # Bug 1159957: nova-manage --version writes to stderr
Joe Gordon0e7cbf82013-03-25 19:49:12 +000052 self.assertNotEqual("", self.nova_manage('', '--version',
53 merge_stderr=True))
Joe Gordon488057a2013-03-14 22:26:50 +000054 self.assertEqual(self.nova_manage('version'),
Joe Gordon0e7cbf82013-03-25 19:49:12 +000055 self.nova_manage('', '--version', merge_stderr=True))
Joe Gordon488057a2013-03-14 22:26:50 +000056
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 Gordon4edb6452013-03-05 21:18:59 +000064
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 Gordon0e7cbf82013-03-25 19:49:12 +000071 self.assertEqual(self.nova_manage('instance_type list'),
72 self.nova_manage('flavor list'))
Joe Gordon488057a2013-03-14 22:26:50 +000073
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'))