ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2013 OpenStack Foundation |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | from tempest.api.network import base |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 17 | from tempest.common.utils import data_utils |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 18 | from tempest import test |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 19 | |
| 20 | |
| 21 | class LoadBalancerJSON(base.BaseNetworkTest): |
| 22 | _interface = 'json' |
| 23 | |
| 24 | """ |
| 25 | Tests the following operations in the Neutron API using the REST client for |
| 26 | Neutron: |
| 27 | |
| 28 | create vIP, and Pool |
| 29 | show vIP |
| 30 | list vIP |
| 31 | update vIP |
| 32 | delete vIP |
| 33 | update pool |
| 34 | delete pool |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 35 | show pool |
| 36 | list pool |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 37 | health monitoring operations |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 38 | """ |
| 39 | |
| 40 | @classmethod |
| 41 | def setUpClass(cls): |
| 42 | super(LoadBalancerJSON, cls).setUpClass() |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 43 | if not test.is_extension_enabled('lbaas', 'network'): |
| 44 | msg = "lbaas extension not enabled." |
| 45 | raise cls.skipException(msg) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 46 | cls.network = cls.create_network() |
| 47 | cls.name = cls.network['name'] |
| 48 | cls.subnet = cls.create_subnet(cls.network) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 49 | pool_name = data_utils.rand_name('pool-') |
| 50 | vip_name = data_utils.rand_name('vip-') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 51 | cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN", |
| 52 | "HTTP", cls.subnet) |
| 53 | cls.vip = cls.create_vip(vip_name, "HTTP", 80, cls.subnet, cls.pool) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 54 | cls.member = cls.create_member(80, cls.pool) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 55 | cls.health_monitor = cls.create_health_monitor(4, 3, "TCP", 1) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 56 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 57 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 58 | def test_list_vips(self): |
| 59 | # Verify the vIP exists in the list of all vIPs |
| 60 | resp, body = self.client.list_vips() |
| 61 | self.assertEqual('200', resp['status']) |
| 62 | vips = body['vips'] |
| 63 | found = None |
| 64 | for n in vips: |
| 65 | if (n['id'] == self.vip['id']): |
| 66 | found = n['id'] |
| 67 | msg = "vIPs list doesn't contain created vip" |
| 68 | self.assertIsNotNone(found, msg) |
| 69 | |
| 70 | def test_create_update_delete_pool_vip(self): |
| 71 | # Creates a vip |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 72 | name = data_utils.rand_name('vip-') |
Eugene Nikanorov | 431e04a | 2013-12-17 15:44:27 +0400 | [diff] [blame] | 73 | resp, body = self.client.create_pool( |
| 74 | name=data_utils.rand_name("pool-"), |
| 75 | lb_method='ROUND_ROBIN', |
| 76 | protocol='HTTP', |
| 77 | subnet_id=self.subnet['id']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 78 | pool = body['pool'] |
| 79 | resp, body = self.client.create_vip(name, "HTTP", 80, |
| 80 | self.subnet['id'], pool['id']) |
| 81 | self.assertEqual('201', resp['status']) |
| 82 | vip = body['vip'] |
| 83 | vip_id = vip['id'] |
| 84 | # Verification of vip update |
| 85 | new_name = "New_vip" |
| 86 | resp, body = self.client.update_vip(vip_id, new_name) |
| 87 | self.assertEqual('200', resp['status']) |
| 88 | updated_vip = body['vip'] |
| 89 | self.assertEqual(updated_vip['name'], new_name) |
| 90 | # Verification of vip delete |
| 91 | resp, body = self.client.delete_vip(vip['id']) |
| 92 | self.assertEqual('204', resp['status']) |
| 93 | # Verification of pool update |
| 94 | new_name = "New_pool" |
Eugene Nikanorov | 431e04a | 2013-12-17 15:44:27 +0400 | [diff] [blame] | 95 | resp, body = self.client.update_pool(pool['id'], |
| 96 | name=new_name) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 97 | self.assertEqual('200', resp['status']) |
| 98 | updated_pool = body['pool'] |
| 99 | self.assertEqual(updated_pool['name'], new_name) |
| 100 | # Verification of pool delete |
| 101 | resp, body = self.client.delete_pool(pool['id']) |
| 102 | self.assertEqual('204', resp['status']) |
| 103 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 104 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 105 | def test_show_vip(self): |
| 106 | # Verifies the details of a vip |
| 107 | resp, body = self.client.show_vip(self.vip['id']) |
| 108 | self.assertEqual('200', resp['status']) |
| 109 | vip = body['vip'] |
| 110 | self.assertEqual(self.vip['id'], vip['id']) |
| 111 | self.assertEqual(self.vip['name'], vip['name']) |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 112 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 113 | @test.attr(type='smoke') |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 114 | def test_show_pool(self): |
| 115 | # Verifies the details of a pool |
| 116 | resp, body = self.client.show_pool(self.pool['id']) |
| 117 | self.assertEqual('200', resp['status']) |
| 118 | pool = body['pool'] |
| 119 | self.assertEqual(self.pool['id'], pool['id']) |
| 120 | self.assertEqual(self.pool['name'], pool['name']) |
| 121 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 122 | @test.attr(type='smoke') |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 123 | def test_list_pools(self): |
| 124 | # Verify the pool exists in the list of all pools |
| 125 | resp, body = self.client.list_pools() |
| 126 | self.assertEqual('200', resp['status']) |
| 127 | pools = body['pools'] |
| 128 | self.assertIn(self.pool['id'], [p['id'] for p in pools]) |
| 129 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 130 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 131 | def test_list_members(self): |
| 132 | # Verify the member exists in the list of all members |
| 133 | resp, body = self.client.list_members() |
| 134 | self.assertEqual('200', resp['status']) |
| 135 | members = body['members'] |
| 136 | self.assertIn(self.member['id'], [m['id'] for m in members]) |
| 137 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 138 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 139 | def test_create_update_delete_member(self): |
| 140 | # Creates a member |
Stephen Gran | abbe563 | 2013-11-19 19:16:14 +0000 | [diff] [blame] | 141 | resp, body = self.client.create_member("10.0.9.47", 80, |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 142 | self.pool['id']) |
| 143 | self.assertEqual('201', resp['status']) |
| 144 | member = body['member'] |
| 145 | # Verification of member update |
| 146 | admin_state = [False, 'False'] |
| 147 | resp, body = self.client.update_member(admin_state[0], member['id']) |
| 148 | self.assertEqual('200', resp['status']) |
| 149 | updated_member = body['member'] |
| 150 | self.assertIn(updated_member['admin_state_up'], admin_state) |
| 151 | # Verification of member delete |
| 152 | resp, body = self.client.delete_member(member['id']) |
| 153 | self.assertEqual('204', resp['status']) |
| 154 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 155 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 156 | def test_show_member(self): |
| 157 | # Verifies the details of a member |
| 158 | resp, body = self.client.show_member(self.member['id']) |
| 159 | self.assertEqual('200', resp['status']) |
| 160 | member = body['member'] |
| 161 | self.assertEqual(self.member['id'], member['id']) |
| 162 | self.assertEqual(self.member['admin_state_up'], |
| 163 | member['admin_state_up']) |
| 164 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 165 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 166 | def test_list_health_monitors(self): |
| 167 | # Verify the health monitor exists in the list of all health monitors |
| 168 | resp, body = self.client.list_health_monitors() |
| 169 | self.assertEqual('200', resp['status']) |
| 170 | health_monitors = body['health_monitors'] |
| 171 | self.assertIn(self.health_monitor['id'], |
| 172 | [h['id'] for h in health_monitors]) |
| 173 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 174 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 175 | def test_create_update_delete_health_monitor(self): |
| 176 | # Creates a health_monitor |
| 177 | resp, body = self.client.create_health_monitor(4, 3, "TCP", 1) |
| 178 | self.assertEqual('201', resp['status']) |
| 179 | health_monitor = body['health_monitor'] |
| 180 | # Verification of health_monitor update |
| 181 | admin_state = [False, 'False'] |
| 182 | resp, body = self.client.update_health_monitor(admin_state[0], |
| 183 | health_monitor['id']) |
| 184 | self.assertEqual('200', resp['status']) |
| 185 | updated_health_monitor = body['health_monitor'] |
| 186 | self.assertIn(updated_health_monitor['admin_state_up'], admin_state) |
| 187 | # Verification of health_monitor delete |
| 188 | resp, body = self.client.delete_health_monitor(health_monitor['id']) |
| 189 | self.assertEqual('204', resp['status']) |
| 190 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 191 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 192 | def test_show_health_monitor(self): |
| 193 | # Verifies the details of a health_monitor |
| 194 | resp, body = self.client.show_health_monitor(self.health_monitor['id']) |
| 195 | self.assertEqual('200', resp['status']) |
| 196 | health_monitor = body['health_monitor'] |
| 197 | self.assertEqual(self.health_monitor['id'], health_monitor['id']) |
| 198 | self.assertEqual(self.health_monitor['admin_state_up'], |
| 199 | health_monitor['admin_state_up']) |
| 200 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 201 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 202 | def test_associate_disassociate_health_monitor_with_pool(self): |
| 203 | # Verify that a health monitor can be associated with a pool |
| 204 | resp, body = (self.client.associate_health_monitor_with_pool |
| 205 | (self.health_monitor['id'], self.pool['id'])) |
| 206 | self.assertEqual('201', resp['status']) |
| 207 | # Verify that a health monitor can be disassociated from a pool |
| 208 | resp, body = (self.client.disassociate_health_monitor_with_pool |
| 209 | (self.health_monitor['id'], self.pool['id'])) |
| 210 | self.assertEqual('204', resp['status']) |
| 211 | |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 212 | |
| 213 | class LoadBalancerXML(LoadBalancerJSON): |
| 214 | _interface = 'xml' |