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