blob: 650ef10f8bc7322e4a1d5d9d8d734162187ae439 [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
21import testtools
22
23import cli
24
25
26LOG = logging.getLogger(__name__)
27
28
29class SimpleReadOnlyNovaManageTest(cli.ClientTestBase):
30
31 """
32 This is a first pass at a simple read only nova-manage test. This
33 only exercises client commands that are read only.
34
35 This should test commands:
36 * with and without optional parameters
37 * initially just check return codes, and later test command outputs
38
39 """
40
41 def test_admin_fake_action(self):
42 self.assertRaises(subprocess.CalledProcessError,
43 self.nova_manage,
44 'this-does-nova-exist')
45
46 #NOTE(jogo): Commands in order listed in 'nova-manage -h'
47
48 # test flags
49 def test_help_flag(self):
50 self.nova_manage('', '-h')
51
Joe Gordon4edb6452013-03-05 21:18:59 +000052 def test_version_flag(self):
Joe Gordone8b0e152013-03-25 13:37:15 -040053 # Bug 1159957: nova-manage --version writes to stderr
Joe Gordon0e7cbf82013-03-25 19:49:12 +000054 self.assertNotEqual("", self.nova_manage('', '--version',
55 merge_stderr=True))
Joe Gordon488057a2013-03-14 22:26:50 +000056 self.assertEqual(self.nova_manage('version'),
Joe Gordon0e7cbf82013-03-25 19:49:12 +000057 self.nova_manage('', '--version', merge_stderr=True))
Joe Gordon488057a2013-03-14 22:26:50 +000058
59 def test_debug_flag(self):
60 self.assertNotEqual("", self.nova_manage('instance_type list',
61 '--debug'))
62
63 def test_verbose_flag(self):
64 self.assertNotEqual("", self.nova_manage('instance_type list',
65 '--verbose'))
Joe Gordon4edb6452013-03-05 21:18:59 +000066
67 # test actions
68 def test_version(self):
69 self.assertNotEqual("", self.nova_manage('version'))
70
71 def test_flavor_list(self):
72 self.assertNotEqual("", self.nova_manage('flavor list'))
Joe Gordon0e7cbf82013-03-25 19:49:12 +000073 self.assertEqual(self.nova_manage('instance_type list'),
74 self.nova_manage('flavor list'))
Joe Gordon488057a2013-03-14 22:26:50 +000075
76 def test_db_archive_deleted_rows(self):
77 # make sure command doesn't error out
78 self.nova_manage('db archive_deleted_rows 50')
79
80 def test_db_sync(self):
81 # make sure command doesn't error out
82 self.nova_manage('db sync')
83
84 def test_db_version(self):
85 self.assertNotEqual("", self.nova_manage('db version'))