blob: d301d38046a2aa9b8c3696f0321f6e91eff7964a [file] [log] [blame]
Joe Gordonc97f5c72013-02-14 01:15:57 +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
Joe Gordonc97f5c72013-02-14 01:15:57 +000019import subprocess
20
Matthew Treinish90aedd12013-02-25 17:56:49 -050021from oslo.config import cfg
Joe Gordonc97f5c72013-02-14 01:15:57 +000022import testtools
23
24import cli
Joe Gordonc97f5c72013-02-14 01:15:57 +000025
26
27CONF = cfg.CONF
28
29
30LOG = logging.getLogger(__name__)
31
32
Pavel Sedláka2b757c2013-02-25 18:16:04 +010033class SimpleReadOnlyNovaClientTest(cli.ClientTestBase):
Joe Gordonc97f5c72013-02-14 01:15:57 +000034
35 """
36 This is a first pass at a simple read only python-novaclient test. This
37 only exercises client commands that are read only.
38
39 This should test commands:
40 * as a regular user
41 * as a admin user
42 * with and without optional parameters
43 * initially just check return codes, and later test command outputs
44
45 """
46
Joe Gordonc97f5c72013-02-14 01:15:57 +000047 def test_admin_fake_action(self):
48 self.assertRaises(subprocess.CalledProcessError,
49 self.nova,
50 'this-does-nova-exist')
51
Joe Gordon34dc84d2013-02-21 02:19:23 +000052 #NOTE(jogo): Commands in order listed in 'nova help'
53
54 # Positional arguments:
55
56 def test_admin_absolute_limites(self):
57 self.nova('absolute-limits')
Joe Gordon4edb6452013-03-05 21:18:59 +000058 self.nova('absolute-limits', params='--reserved')
Joe Gordon34dc84d2013-02-21 02:19:23 +000059
Joe Gordonc97f5c72013-02-14 01:15:57 +000060 def test_admin_aggregate_list(self):
61 self.nova('aggregate-list')
62
Joe Gordon34dc84d2013-02-21 02:19:23 +000063 def test_admin_availability_zone_list(self):
Joe Gordon4edb6452013-03-05 21:18:59 +000064 self.assertIn("internal", self.nova('availability-zone-list'))
Joe Gordon34dc84d2013-02-21 02:19:23 +000065
Joe Gordonc97f5c72013-02-14 01:15:57 +000066 def test_admin_cloudpipe_list(self):
67 self.nova('cloudpipe-list')
68
Joe Gordon34dc84d2013-02-21 02:19:23 +000069 def test_admin_credentials(self):
70 self.nova('credentials')
Joe Gordonc97f5c72013-02-14 01:15:57 +000071
72 def test_admin_dns_domains(self):
73 self.nova('dns-domains')
74
Matthew Treinish770e5a42013-03-22 15:35:16 -040075 @testtools.skip("Test needs parameters, Bug #1157349")
Joe Gordon34dc84d2013-02-21 02:19:23 +000076 def test_admin_dns_list(self):
77 self.nova('dns-list')
78
79 def test_admin_endpoints(self):
80 self.nova('endpoints')
81
82 def test_admin_flavor_acces_list(self):
83 self.assertRaises(subprocess.CalledProcessError,
84 self.nova,
85 'flavor-access-list')
86 # Failed to get access list for public flavor type
87 self.assertRaises(subprocess.CalledProcessError,
88 self.nova,
89 'flavor-access-list',
90 params='--flavor m1.tiny')
91
Joe Gordonc97f5c72013-02-14 01:15:57 +000092 def test_admin_flavor_list(self):
Joe Gordon4edb6452013-03-05 21:18:59 +000093 self.assertIn("Memory_MB", self.nova('flavor-list'))
Joe Gordonc97f5c72013-02-14 01:15:57 +000094
Joe Gordon34dc84d2013-02-21 02:19:23 +000095 def test_admin_floating_ip_bulk_list(self):
96 self.nova('floating-ip-bulk-list')
97
98 def test_admin_floating_ip_list(self):
99 self.nova('floating-ip-list')
100
101 def test_admin_floating_ip_pool_list(self):
102 self.nova('floating-ip-pool-list')
103
104 def test_admin_host_list(self):
105 self.nova('host-list')
106
107 def test_admin_hypervisor_list(self):
108 self.nova('hypervisor-list')
109
110 def test_admin_image_list(self):
111 self.nova('image-list')
112
Matthew Treinish770e5a42013-03-22 15:35:16 -0400113 @testtools.skip("Test needs parameters, Bug #1157349")
Joe Gordon34dc84d2013-02-21 02:19:23 +0000114 def test_admin_interface_list(self):
115 self.nova('interface-list')
116
117 def test_admin_keypair_list(self):
118 self.nova('keypair-list')
119
120 def test_admin_list(self):
121 self.nova('list')
122 self.nova('list', params='--all-tenants 1')
123 self.nova('list', params='--all-tenants 0')
124 self.assertRaises(subprocess.CalledProcessError,
125 self.nova,
126 'list',
127 params='--all-tenants bad')
128
129 def test_admin_network_list(self):
130 self.nova('network-list')
131
132 def test_admin_rate_limits(self):
133 self.nova('rate-limits')
134
135 def test_admin_secgroup_list(self):
136 self.nova('secgroup-list')
137
Matthew Treinish770e5a42013-03-22 15:35:16 -0400138 @testtools.skip("Test needs parameters, Bug #1157349")
Joe Gordon34dc84d2013-02-21 02:19:23 +0000139 def test_admin_secgroup_list_rules(self):
140 self.nova('secgroup-list-rules')
141
142 def test_admin_servce_list(self):
143 self.nova('service-list')
144
145 def test_admin_usage(self):
146 self.nova('usage')
147
148 def test_admin_usage_list(self):
149 self.nova('usage-list')
150
151 def test_admin_volume_list(self):
152 self.nova('volume-list')
153
154 def test_admin_volume_snapshot_list(self):
155 self.nova('volume-snapshot-list')
156
157 def test_admin_volume_type_list(self):
158 self.nova('volume-type-list')
159
160 def test_admin_help(self):
161 self.nova('help')
162
163 def test_admin_list_extensions(self):
164 self.nova('list-extensions')
165
166 def test_admin_net_list(self):
167 self.nova('net-list')
168
169 # Optional arguments:
170
171 def test_admin_version(self):
172 self.nova('', flags='--version')
173
174 def test_admin_debug_list(self):
175 self.nova('list', flags='--debug')
176
177 def test_admin_timeout(self):
178 self.nova('list', flags='--timeout 2')
179
180 def test_admin_timing(self):
181 self.nova('list', flags='--timing')