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