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 | |
Ken'ichi Ohmichi | 91c675d | 2014-02-06 02:15:21 +0900 | [diff] [blame] | 21 | class LoadBalancerTestJSON(base.BaseNetworkTest): |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 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 |
Masayuki Igawa | 6d495d6 | 2014-03-19 16:38:57 +0900 | [diff] [blame] | 41 | @test.safe_setup |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 42 | def setUpClass(cls): |
Ken'ichi Ohmichi | 91c675d | 2014-02-06 02:15:21 +0900 | [diff] [blame] | 43 | super(LoadBalancerTestJSON, cls).setUpClass() |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 44 | if not test.is_extension_enabled('lbaas', 'network'): |
| 45 | msg = "lbaas extension not enabled." |
| 46 | raise cls.skipException(msg) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 47 | cls.network = cls.create_network() |
| 48 | cls.name = cls.network['name'] |
| 49 | cls.subnet = cls.create_subnet(cls.network) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 50 | pool_name = data_utils.rand_name('pool-') |
| 51 | vip_name = data_utils.rand_name('vip-') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 52 | cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN", |
| 53 | "HTTP", cls.subnet) |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 54 | cls.vip = cls.create_vip(name=vip_name, |
| 55 | protocol="HTTP", |
| 56 | protocol_port=80, |
| 57 | subnet=cls.subnet, |
| 58 | pool=cls.pool) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 59 | cls.member = cls.create_member(80, cls.pool) |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 60 | cls.health_monitor = cls.create_health_monitor(delay=4, |
| 61 | max_retries=3, |
| 62 | Type="TCP", |
| 63 | timeout=1) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 64 | |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 65 | def _check_list_with_filter(self, obj_name, attr_exceptions, **kwargs): |
| 66 | create_obj = getattr(self.client, 'create_' + obj_name) |
| 67 | delete_obj = getattr(self.client, 'delete_' + obj_name) |
| 68 | list_objs = getattr(self.client, 'list_' + obj_name + 's') |
| 69 | |
| 70 | resp, body = create_obj(**kwargs) |
| 71 | self.assertEqual('201', resp['status']) |
| 72 | obj = body[obj_name] |
| 73 | self.addCleanup(delete_obj, obj['id']) |
| 74 | for key, value in obj.iteritems(): |
| 75 | # It is not relevant to filter by all arguments. That is why |
| 76 | # there is a list of attr to except |
| 77 | if key not in attr_exceptions: |
| 78 | resp, body = list_objs(**{key: value}) |
| 79 | self.assertEqual('200', resp['status']) |
| 80 | objs = [v[key] for v in body[obj_name + 's']] |
| 81 | self.assertIn(value, objs) |
| 82 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 83 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 84 | def test_list_vips(self): |
| 85 | # Verify the vIP exists in the list of all vIPs |
| 86 | resp, body = self.client.list_vips() |
| 87 | self.assertEqual('200', resp['status']) |
| 88 | vips = body['vips'] |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 89 | self.assertIn(self.vip['id'], [v['id'] for v in vips]) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 90 | |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 91 | @test.attr(type='smoke') |
| 92 | def test_list_vips_with_filter(self): |
| 93 | name = data_utils.rand_name('vip-') |
| 94 | resp, body = self.client.create_pool( |
| 95 | name=data_utils.rand_name("pool-"), lb_method="ROUND_ROBIN", |
| 96 | protocol="HTTPS", subnet_id=self.subnet['id']) |
| 97 | self.assertEqual('201', resp['status']) |
| 98 | pool = body['pool'] |
| 99 | self.addCleanup(self.client.delete_pool, pool['id']) |
| 100 | attr_exceptions = ['status', 'session_persistence', |
| 101 | 'status_description'] |
| 102 | self._check_list_with_filter( |
| 103 | 'vip', attr_exceptions, name=name, protocol="HTTPS", |
| 104 | protocol_port=81, subnet_id=self.subnet['id'], pool_id=pool['id'], |
| 105 | description=data_utils.rand_name('description-'), |
| 106 | admin_state_up=False) |
| 107 | |
| 108 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 109 | def test_create_update_delete_pool_vip(self): |
| 110 | # Creates a vip |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 111 | name = data_utils.rand_name('vip-') |
Elena Ezhova | b40848f | 2014-01-15 10:17:35 +0400 | [diff] [blame] | 112 | address = self.subnet['allocation_pools'][0]['end'] |
Eugene Nikanorov | 431e04a | 2013-12-17 15:44:27 +0400 | [diff] [blame] | 113 | resp, body = self.client.create_pool( |
| 114 | name=data_utils.rand_name("pool-"), |
| 115 | lb_method='ROUND_ROBIN', |
| 116 | protocol='HTTP', |
| 117 | subnet_id=self.subnet['id']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 118 | pool = body['pool'] |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 119 | resp, body = self.client.create_vip(name=name, |
| 120 | protocol="HTTP", |
| 121 | protocol_port=80, |
| 122 | subnet_id=self.subnet['id'], |
Elena Ezhova | b40848f | 2014-01-15 10:17:35 +0400 | [diff] [blame] | 123 | pool_id=pool['id'], |
| 124 | address=address) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 125 | self.assertEqual('201', resp['status']) |
| 126 | vip = body['vip'] |
| 127 | vip_id = vip['id'] |
Elena Ezhova | b40848f | 2014-01-15 10:17:35 +0400 | [diff] [blame] | 128 | # Confirm VIP's address correctness with a show |
| 129 | resp, body = self.client.show_vip(vip_id) |
| 130 | self.assertEqual('200', resp['status']) |
| 131 | vip = body['vip'] |
| 132 | self.assertEqual(address, vip['address']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 133 | # Verification of vip update |
| 134 | new_name = "New_vip" |
Elena Ezhova | b40848f | 2014-01-15 10:17:35 +0400 | [diff] [blame] | 135 | new_description = "New description" |
| 136 | persistence_type = "HTTP_COOKIE" |
| 137 | update_data = {"session_persistence": { |
| 138 | "type": persistence_type}} |
| 139 | resp, body = self.client.update_vip(vip_id, |
| 140 | name=new_name, |
| 141 | description=new_description, |
| 142 | connection_limit=10, |
| 143 | admin_state_up=False, |
| 144 | **update_data) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 145 | self.assertEqual('200', resp['status']) |
| 146 | updated_vip = body['vip'] |
Elena Ezhova | b40848f | 2014-01-15 10:17:35 +0400 | [diff] [blame] | 147 | self.assertEqual(new_name, updated_vip['name']) |
| 148 | self.assertEqual(new_description, updated_vip['description']) |
| 149 | self.assertEqual(10, updated_vip['connection_limit']) |
| 150 | self.assertFalse(updated_vip['admin_state_up']) |
| 151 | self.assertEqual(persistence_type, |
| 152 | updated_vip['session_persistence']['type']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 153 | # Verification of vip delete |
| 154 | resp, body = self.client.delete_vip(vip['id']) |
| 155 | self.assertEqual('204', resp['status']) |
izikpenso | d9a01a6 | 2014-02-17 20:02:32 +0200 | [diff] [blame] | 156 | self.client.wait_for_resource_deletion('vip', vip['id']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 157 | # Verification of pool update |
| 158 | new_name = "New_pool" |
Eugene Nikanorov | 431e04a | 2013-12-17 15:44:27 +0400 | [diff] [blame] | 159 | resp, body = self.client.update_pool(pool['id'], |
Ann Kamyshnikova | b665940 | 2014-01-09 17:50:31 +0400 | [diff] [blame] | 160 | name=new_name, |
| 161 | description="new_description", |
| 162 | lb_method='LEAST_CONNECTIONS') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 163 | self.assertEqual('200', resp['status']) |
| 164 | updated_pool = body['pool'] |
Ann Kamyshnikova | b665940 | 2014-01-09 17:50:31 +0400 | [diff] [blame] | 165 | self.assertEqual(new_name, updated_pool['name']) |
| 166 | self.assertEqual('new_description', updated_pool['description']) |
| 167 | self.assertEqual('LEAST_CONNECTIONS', updated_pool['lb_method']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 168 | # Verification of pool delete |
| 169 | resp, body = self.client.delete_pool(pool['id']) |
| 170 | self.assertEqual('204', resp['status']) |
| 171 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 172 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 173 | def test_show_vip(self): |
| 174 | # Verifies the details of a vip |
| 175 | resp, body = self.client.show_vip(self.vip['id']) |
| 176 | self.assertEqual('200', resp['status']) |
| 177 | vip = body['vip'] |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 178 | for key, value in vip.iteritems(): |
| 179 | # 'status' should not be confirmed in api tests |
| 180 | if key != 'status': |
| 181 | self.assertEqual(self.vip[key], value) |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 182 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 183 | @test.attr(type='smoke') |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 184 | def test_show_pool(self): |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 185 | # Here we need to new pool without any dependence with vips |
| 186 | resp, body = self.client.create_pool( |
| 187 | name=data_utils.rand_name("pool-"), |
| 188 | lb_method='ROUND_ROBIN', |
| 189 | protocol='HTTP', |
| 190 | subnet_id=self.subnet['id']) |
| 191 | self.assertEqual('201', resp['status']) |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 192 | pool = body['pool'] |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 193 | self.addCleanup(self.client.delete_pool, pool['id']) |
| 194 | # Verifies the details of a pool |
| 195 | resp, body = self.client.show_pool(pool['id']) |
| 196 | self.assertEqual('200', resp['status']) |
| 197 | shown_pool = body['pool'] |
| 198 | for key, value in pool.iteritems(): |
| 199 | # 'status' should not be confirmed in api tests |
| 200 | if key != 'status': |
| 201 | self.assertEqual(value, shown_pool[key]) |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 202 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 203 | @test.attr(type='smoke') |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 204 | def test_list_pools(self): |
| 205 | # Verify the pool exists in the list of all pools |
| 206 | resp, body = self.client.list_pools() |
| 207 | self.assertEqual('200', resp['status']) |
| 208 | pools = body['pools'] |
| 209 | self.assertIn(self.pool['id'], [p['id'] for p in pools]) |
| 210 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 211 | @test.attr(type='smoke') |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 212 | def test_list_pools_with_filters(self): |
| 213 | attr_exceptions = ['status', 'vip_id', 'members', 'provider', |
| 214 | 'status_description'] |
| 215 | self._check_list_with_filter( |
| 216 | 'pool', attr_exceptions, name=data_utils.rand_name("pool-"), |
| 217 | lb_method="ROUND_ROBIN", protocol="HTTPS", |
| 218 | subnet_id=self.subnet['id'], |
| 219 | description=data_utils.rand_name('description-'), |
| 220 | admin_state_up=False) |
| 221 | |
| 222 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 223 | def test_list_members(self): |
| 224 | # Verify the member exists in the list of all members |
| 225 | resp, body = self.client.list_members() |
| 226 | self.assertEqual('200', resp['status']) |
| 227 | members = body['members'] |
| 228 | self.assertIn(self.member['id'], [m['id'] for m in members]) |
| 229 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 230 | @test.attr(type='smoke') |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 231 | def test_list_members_with_filters(self): |
| 232 | attr_exceptions = ['status', 'status_description'] |
| 233 | self._check_list_with_filter('member', attr_exceptions, |
| 234 | address="10.0.9.47", protocol_port=80, |
| 235 | pool_id=self.pool['id']) |
| 236 | |
| 237 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 238 | def test_create_update_delete_member(self): |
| 239 | # Creates a member |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 240 | resp, body = self.client.create_member(address="10.0.9.47", |
| 241 | protocol_port=80, |
| 242 | pool_id=self.pool['id']) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 243 | self.assertEqual('201', resp['status']) |
| 244 | member = body['member'] |
| 245 | # Verification of member update |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 246 | resp, body = self.client.update_member(member['id'], |
| 247 | admin_state_up=False) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 248 | self.assertEqual('200', resp['status']) |
| 249 | updated_member = body['member'] |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 250 | self.assertFalse(updated_member['admin_state_up']) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 251 | # Verification of member delete |
| 252 | resp, body = self.client.delete_member(member['id']) |
| 253 | self.assertEqual('204', resp['status']) |
| 254 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 255 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 256 | def test_show_member(self): |
| 257 | # Verifies the details of a member |
| 258 | resp, body = self.client.show_member(self.member['id']) |
| 259 | self.assertEqual('200', resp['status']) |
| 260 | member = body['member'] |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 261 | for key, value in member.iteritems(): |
| 262 | # 'status' should not be confirmed in api tests |
| 263 | if key != 'status': |
| 264 | self.assertEqual(self.member[key], value) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 265 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 266 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 267 | def test_list_health_monitors(self): |
| 268 | # Verify the health monitor exists in the list of all health monitors |
| 269 | resp, body = self.client.list_health_monitors() |
| 270 | self.assertEqual('200', resp['status']) |
| 271 | health_monitors = body['health_monitors'] |
| 272 | self.assertIn(self.health_monitor['id'], |
| 273 | [h['id'] for h in health_monitors]) |
| 274 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 275 | @test.attr(type='smoke') |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 276 | def test_list_health_monitors_with_filters(self): |
| 277 | attr_exceptions = ['status', 'status_description', 'pools'] |
| 278 | self._check_list_with_filter('health_monitor', attr_exceptions, |
| 279 | delay=5, max_retries=4, type="TCP", |
| 280 | timeout=2) |
| 281 | |
| 282 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 283 | def test_create_update_delete_health_monitor(self): |
| 284 | # Creates a health_monitor |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 285 | resp, body = self.client.create_health_monitor(delay=4, |
| 286 | max_retries=3, |
| 287 | type="TCP", |
| 288 | timeout=1) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 289 | self.assertEqual('201', resp['status']) |
| 290 | health_monitor = body['health_monitor'] |
| 291 | # Verification of health_monitor update |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 292 | resp, body = (self.client.update_health_monitor |
| 293 | (health_monitor['id'], |
| 294 | admin_state_up=False)) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 295 | self.assertEqual('200', resp['status']) |
| 296 | updated_health_monitor = body['health_monitor'] |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 297 | self.assertFalse(updated_health_monitor['admin_state_up']) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 298 | # Verification of health_monitor delete |
| 299 | resp, body = self.client.delete_health_monitor(health_monitor['id']) |
| 300 | self.assertEqual('204', resp['status']) |
| 301 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 302 | @test.attr(type='smoke') |
Elena Ezhova | b40848f | 2014-01-15 10:17:35 +0400 | [diff] [blame] | 303 | def test_create_health_monitor_http_type(self): |
| 304 | hm_type = "HTTP" |
| 305 | resp, body = self.client.create_health_monitor(delay=4, |
| 306 | max_retries=3, |
| 307 | type=hm_type, |
| 308 | timeout=1) |
| 309 | self.assertEqual('201', resp['status']) |
| 310 | health_monitor = body['health_monitor'] |
| 311 | self.addCleanup(self.client.delete_health_monitor, |
| 312 | health_monitor['id']) |
| 313 | self.assertEqual(hm_type, health_monitor['type']) |
| 314 | |
| 315 | @test.attr(type='smoke') |
| 316 | def test_update_health_monitor_http_method(self): |
| 317 | resp, body = self.client.create_health_monitor(delay=4, |
| 318 | max_retries=3, |
| 319 | type="HTTP", |
| 320 | timeout=1) |
| 321 | self.assertEqual('201', resp['status']) |
| 322 | health_monitor = body['health_monitor'] |
| 323 | self.addCleanup(self.client.delete_health_monitor, |
| 324 | health_monitor['id']) |
| 325 | resp, body = (self.client.update_health_monitor |
| 326 | (health_monitor['id'], |
| 327 | http_method="POST", |
| 328 | url_path="/home/user", |
| 329 | expected_codes="290")) |
| 330 | self.assertEqual('200', resp['status']) |
| 331 | updated_health_monitor = body['health_monitor'] |
| 332 | self.assertEqual("POST", updated_health_monitor['http_method']) |
| 333 | self.assertEqual("/home/user", updated_health_monitor['url_path']) |
| 334 | self.assertEqual("290", updated_health_monitor['expected_codes']) |
| 335 | |
| 336 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 337 | def test_show_health_monitor(self): |
| 338 | # Verifies the details of a health_monitor |
| 339 | resp, body = self.client.show_health_monitor(self.health_monitor['id']) |
| 340 | self.assertEqual('200', resp['status']) |
| 341 | health_monitor = body['health_monitor'] |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 342 | for key, value in health_monitor.iteritems(): |
| 343 | # 'status' should not be confirmed in api tests |
| 344 | if key != 'status': |
| 345 | self.assertEqual(self.health_monitor[key], value) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 346 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 347 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 348 | def test_associate_disassociate_health_monitor_with_pool(self): |
| 349 | # Verify that a health monitor can be associated with a pool |
| 350 | resp, body = (self.client.associate_health_monitor_with_pool |
| 351 | (self.health_monitor['id'], self.pool['id'])) |
| 352 | self.assertEqual('201', resp['status']) |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 353 | resp, body = self.client.show_health_monitor( |
| 354 | self.health_monitor['id']) |
| 355 | health_monitor = body['health_monitor'] |
| 356 | resp, body = self.client.show_pool(self.pool['id']) |
| 357 | pool = body['pool'] |
| 358 | self.assertIn(pool['id'], |
| 359 | [p['pool_id'] for p in health_monitor['pools']]) |
| 360 | self.assertIn(health_monitor['id'], pool['health_monitors']) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 361 | # Verify that a health monitor can be disassociated from a pool |
| 362 | resp, body = (self.client.disassociate_health_monitor_with_pool |
| 363 | (self.health_monitor['id'], self.pool['id'])) |
| 364 | self.assertEqual('204', resp['status']) |
Ann Kamyshnikova | 2bc1c43 | 2013-12-10 17:31:50 +0400 | [diff] [blame] | 365 | resp, body = self.client.show_pool(self.pool['id']) |
| 366 | pool = body['pool'] |
| 367 | resp, body = self.client.show_health_monitor( |
| 368 | self.health_monitor['id']) |
| 369 | health_monitor = body['health_monitor'] |
| 370 | self.assertNotIn(health_monitor['id'], pool['health_monitors']) |
| 371 | self.assertNotIn(pool['id'], |
| 372 | [p['pool_id'] for p in health_monitor['pools']]) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 373 | |
nayna-patel | 87b4ef2 | 2014-02-07 10:24:59 +0000 | [diff] [blame] | 374 | @test.attr(type='smoke') |
| 375 | def test_get_lb_pool_stats(self): |
| 376 | # Verify the details of pool stats |
| 377 | resp, body = self.client.list_lb_pool_stats(self.pool['id']) |
| 378 | self.assertEqual('200', resp['status']) |
| 379 | stats = body['stats'] |
| 380 | self.assertIn("bytes_in", stats) |
| 381 | self.assertIn("total_connections", stats) |
| 382 | self.assertIn("active_connections", stats) |
| 383 | self.assertIn("bytes_out", stats) |
| 384 | |
Ann Kamyshnikova | b665940 | 2014-01-09 17:50:31 +0400 | [diff] [blame] | 385 | @test.attr(type='smoke') |
| 386 | def test_update_list_of_health_monitors_associated_with_pool(self): |
| 387 | resp, _ = (self.client.associate_health_monitor_with_pool |
| 388 | (self.health_monitor['id'], self.pool['id'])) |
| 389 | self.assertEqual('201', resp['status']) |
| 390 | resp, _ = self.client.update_health_monitor( |
| 391 | self.health_monitor['id'], admin_state_up=False) |
| 392 | self.assertEqual('200', resp['status']) |
| 393 | resp, body = self.client.show_pool(self.pool['id']) |
| 394 | self.assertEqual('200', resp['status']) |
| 395 | health_monitors = body['pool']['health_monitors'] |
| 396 | for health_monitor_id in health_monitors: |
| 397 | resp, body = self.client.show_health_monitor(health_monitor_id) |
| 398 | self.assertEqual('200', resp['status']) |
| 399 | self.assertFalse(body['health_monitor']['admin_state_up']) |
| 400 | resp, _ = (self.client.disassociate_health_monitor_with_pool |
| 401 | (self.health_monitor['id'], self.pool['id'])) |
| 402 | self.assertEqual('204', resp['status']) |
| 403 | |
| 404 | @test.attr(type='smoke') |
| 405 | def test_update_admin_state_up_of_pool(self): |
| 406 | resp, _ = self.client.update_pool(self.pool['id'], |
| 407 | admin_state_up=False) |
| 408 | self.assertEqual('200', resp['status']) |
| 409 | resp, body = self.client.show_pool(self.pool['id']) |
| 410 | self.assertEqual('200', resp['status']) |
| 411 | pool = body['pool'] |
| 412 | self.assertFalse(pool['admin_state_up']) |
| 413 | |
| 414 | @test.attr(type='smoke') |
| 415 | def test_show_vip_associated_with_pool(self): |
| 416 | resp, body = self.client.show_pool(self.pool['id']) |
| 417 | self.assertEqual('200', resp['status']) |
| 418 | pool = body['pool'] |
| 419 | resp, body = self.client.show_vip(pool['vip_id']) |
| 420 | self.assertEqual('200', resp['status']) |
| 421 | vip = body['vip'] |
| 422 | self.assertEqual(self.vip['name'], vip['name']) |
| 423 | self.assertEqual(self.vip['id'], vip['id']) |
| 424 | |
| 425 | @test.attr(type='smoke') |
| 426 | def test_show_members_associated_with_pool(self): |
| 427 | resp, body = self.client.show_pool(self.pool['id']) |
| 428 | self.assertEqual('200', resp['status']) |
| 429 | members = body['pool']['members'] |
| 430 | for member_id in members: |
| 431 | resp, body = self.client.show_member(member_id) |
| 432 | self.assertEqual('200', resp['status']) |
| 433 | self.assertIsNotNone(body['member']['status']) |
| 434 | self.assertEqual(member_id, body['member']['id']) |
| 435 | self.assertIsNotNone(body['member']['admin_state_up']) |
| 436 | |
Ann Kamyshnikova | 4f5d0b9 | 2014-01-13 16:53:48 +0400 | [diff] [blame] | 437 | @test.attr(type='smoke') |
| 438 | def test_update_pool_related_to_member(self): |
| 439 | # Create new pool |
| 440 | resp, body = self.client.create_pool( |
| 441 | name=data_utils.rand_name("pool-"), |
| 442 | lb_method='ROUND_ROBIN', |
| 443 | protocol='HTTP', |
| 444 | subnet_id=self.subnet['id']) |
| 445 | self.assertEqual('201', resp['status']) |
| 446 | new_pool = body['pool'] |
| 447 | self.addCleanup(self.client.delete_pool, new_pool['id']) |
| 448 | # Update member with new pool's id |
| 449 | resp, body = self.client.update_member(self.member['id'], |
| 450 | pool_id=new_pool['id']) |
| 451 | self.assertEqual('200', resp['status']) |
| 452 | # Confirm with show that pool_id change |
| 453 | resp, body = self.client.show_member(self.member['id']) |
| 454 | member = body['member'] |
| 455 | self.assertEqual(member['pool_id'], new_pool['id']) |
| 456 | # Update member with old pool id, this is needed for clean up |
| 457 | resp, body = self.client.update_member(self.member['id'], |
| 458 | pool_id=self.pool['id']) |
| 459 | self.assertEqual('200', resp['status']) |
| 460 | |
| 461 | @test.attr(type='smoke') |
| 462 | def test_update_member_weight(self): |
| 463 | resp, _ = self.client.update_member(self.member['id'], |
| 464 | weight=2) |
| 465 | self.assertEqual('200', resp['status']) |
| 466 | resp, body = self.client.show_member(self.member['id']) |
| 467 | self.assertEqual('200', resp['status']) |
| 468 | member = body['member'] |
| 469 | self.assertEqual(2, member['weight']) |
| 470 | |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 471 | |
Ken'ichi Ohmichi | 91c675d | 2014-02-06 02:15:21 +0900 | [diff] [blame] | 472 | class LoadBalancerTestXML(LoadBalancerTestJSON): |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 473 | _interface = 'xml' |