Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +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 |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 19 | import subprocess |
| 20 | |
Matthew Treinish | 90aedd1 | 2013-02-25 17:56:49 -0500 | [diff] [blame] | 21 | from oslo.config import cfg |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 22 | import testtools |
| 23 | |
| 24 | import cli |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 25 | |
| 26 | |
| 27 | CONF = cfg.CONF |
| 28 | |
| 29 | |
| 30 | LOG = logging.getLogger(__name__) |
| 31 | |
| 32 | |
Pavel Sedlák | a2b757c | 2013-02-25 18:16:04 +0100 | [diff] [blame] | 33 | class SimpleReadOnlyNovaClientTest(cli.ClientTestBase): |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 34 | |
| 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 Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 47 | def test_admin_fake_action(self): |
| 48 | self.assertRaises(subprocess.CalledProcessError, |
| 49 | self.nova, |
| 50 | 'this-does-nova-exist') |
| 51 | |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 52 | #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 Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 58 | self.nova('absolute-limits', params='--reserved') |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 59 | |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 60 | def test_admin_aggregate_list(self): |
| 61 | self.nova('aggregate-list') |
| 62 | |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 63 | def test_admin_availability_zone_list(self): |
Joe Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 64 | self.assertIn("internal", self.nova('availability-zone-list')) |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 65 | |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 66 | def test_admin_cloudpipe_list(self): |
| 67 | self.nova('cloudpipe-list') |
| 68 | |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 69 | def test_admin_credentials(self): |
| 70 | self.nova('credentials') |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 71 | |
| 72 | def test_admin_dns_domains(self): |
| 73 | self.nova('dns-domains') |
| 74 | |
Matthew Treinish | 770e5a4 | 2013-03-22 15:35:16 -0400 | [diff] [blame] | 75 | @testtools.skip("Test needs parameters, Bug #1157349") |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 76 | 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 Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 92 | def test_admin_flavor_list(self): |
Joe Gordon | 4edb645 | 2013-03-05 21:18:59 +0000 | [diff] [blame] | 93 | self.assertIn("Memory_MB", self.nova('flavor-list')) |
Joe Gordon | c97f5c7 | 2013-02-14 01:15:57 +0000 | [diff] [blame] | 94 | |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 95 | 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 Treinish | 770e5a4 | 2013-03-22 15:35:16 -0400 | [diff] [blame] | 113 | @testtools.skip("Test needs parameters, Bug #1157349") |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 114 | 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 Treinish | 770e5a4 | 2013-03-22 15:35:16 -0400 | [diff] [blame] | 138 | @testtools.skip("Test needs parameters, Bug #1157349") |
Joe Gordon | 34dc84d | 2013-02-21 02:19:23 +0000 | [diff] [blame] | 139 | 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') |