blob: 38a6fe9bbed886fa30028ebb8bdfa3226ebfbeff [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2013 OpenStack Foundation
raiesmh080fe76852013-09-13 11:52:56 +05302# 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
Matthew Treinish71426682015-04-23 11:19:38 -040016import six
Matthew Treinish01472ff2015-02-20 17:26:52 -050017from tempest_lib.common.utils import data_utils
Matthew Treinishc49fcbe2015-02-05 23:37:34 -050018from tempest_lib import decorators
19
raiesmh080fe76852013-09-13 11:52:56 +053020from tempest.api.network import base
mouad benchchaouiea2440d2013-12-22 00:38:06 +010021from tempest import test
raiesmh080fe76852013-09-13 11:52:56 +053022
23
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +090024class LoadBalancerTestJSON(base.BaseNetworkTest):
raiesmh080fe76852013-09-13 11:52:56 +053025 """
26 Tests the following operations in the Neutron API using the REST client for
27 Neutron:
28
29 create vIP, and Pool
30 show vIP
31 list vIP
32 update vIP
33 delete vIP
34 update pool
35 delete pool
raiesmh08f5153f72013-09-16 13:38:37 +053036 show pool
37 list pool
raiesmh0832580d02013-09-17 13:11:34 +053038 health monitoring operations
raiesmh080fe76852013-09-13 11:52:56 +053039 """
40
41 @classmethod
Rohan Kanadea565e452015-01-27 14:00:13 +053042 def skip_checks(cls):
43 super(LoadBalancerTestJSON, cls).skip_checks()
mouad benchchaouiea2440d2013-12-22 00:38:06 +010044 if not test.is_extension_enabled('lbaas', 'network'):
45 msg = "lbaas extension not enabled."
46 raise cls.skipException(msg)
Rohan Kanadea565e452015-01-27 14:00:13 +053047
48 @classmethod
49 def resource_setup(cls):
50 super(LoadBalancerTestJSON, cls).resource_setup()
raiesmh080fe76852013-09-13 11:52:56 +053051 cls.network = cls.create_network()
52 cls.name = cls.network['name']
53 cls.subnet = cls.create_subnet(cls.network)
Masayuki Igawa259c1132013-10-31 17:48:44 +090054 pool_name = data_utils.rand_name('pool-')
55 vip_name = data_utils.rand_name('vip-')
raiesmh080fe76852013-09-13 11:52:56 +053056 cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
57 "HTTP", cls.subnet)
Elena Ezhova43c70a22014-01-14 12:42:51 +040058 cls.vip = cls.create_vip(name=vip_name,
59 protocol="HTTP",
60 protocol_port=80,
61 subnet=cls.subnet,
62 pool=cls.pool)
Sergey Shnaidman97e6a0f2014-11-12 20:00:53 +030063 cls.member = cls.create_member(80, cls.pool, cls._ip_version)
64 cls.member_address = ("10.0.9.47" if cls._ip_version == 4
65 else "2015::beef")
Elena Ezhova43c70a22014-01-14 12:42:51 +040066 cls.health_monitor = cls.create_health_monitor(delay=4,
67 max_retries=3,
68 Type="TCP",
69 timeout=1)
raiesmh080fe76852013-09-13 11:52:56 +053070
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040071 def _check_list_with_filter(self, obj_name, attr_exceptions, **kwargs):
72 create_obj = getattr(self.client, 'create_' + obj_name)
73 delete_obj = getattr(self.client, 'delete_' + obj_name)
74 list_objs = getattr(self.client, 'list_' + obj_name + 's')
75
David Kranz34e88122014-12-11 15:24:05 -050076 body = create_obj(**kwargs)
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040077 obj = body[obj_name]
78 self.addCleanup(delete_obj, obj['id'])
Matthew Treinish71426682015-04-23 11:19:38 -040079 for key, value in six.iteritems(obj):
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040080 # It is not relevant to filter by all arguments. That is why
81 # there is a list of attr to except
82 if key not in attr_exceptions:
David Kranz34e88122014-12-11 15:24:05 -050083 body = list_objs(**{key: value})
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040084 objs = [v[key] for v in body[obj_name + 's']]
85 self.assertIn(value, objs)
86
Chris Hoge7579c1a2015-02-26 14:12:15 -080087 @test.idempotent_id('c96dbfab-4a80-4e74-a535-e950b5bedd47')
raiesmh080fe76852013-09-13 11:52:56 +053088 def test_list_vips(self):
89 # Verify the vIP exists in the list of all vIPs
David Kranz34e88122014-12-11 15:24:05 -050090 body = self.client.list_vips()
raiesmh080fe76852013-09-13 11:52:56 +053091 vips = body['vips']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040092 self.assertIn(self.vip['id'], [v['id'] for v in vips])
raiesmh080fe76852013-09-13 11:52:56 +053093
Chris Hoge7579c1a2015-02-26 14:12:15 -080094 @test.idempotent_id('b8853f65-5089-4e69-befd-041a143427ff')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040095 def test_list_vips_with_filter(self):
96 name = data_utils.rand_name('vip-')
David Kranz34e88122014-12-11 15:24:05 -050097 body = self.client.create_pool(name=data_utils.rand_name("pool-"),
98 lb_method="ROUND_ROBIN",
99 protocol="HTTPS",
100 subnet_id=self.subnet['id'])
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400101 pool = body['pool']
102 self.addCleanup(self.client.delete_pool, pool['id'])
103 attr_exceptions = ['status', 'session_persistence',
104 'status_description']
105 self._check_list_with_filter(
106 'vip', attr_exceptions, name=name, protocol="HTTPS",
107 protocol_port=81, subnet_id=self.subnet['id'], pool_id=pool['id'],
108 description=data_utils.rand_name('description-'),
109 admin_state_up=False)
110
Chris Hoge7579c1a2015-02-26 14:12:15 -0800111 @test.idempotent_id('27f56083-9af9-4a48-abe9-ca1bcc6c9035')
raiesmh080fe76852013-09-13 11:52:56 +0530112 def test_create_update_delete_pool_vip(self):
113 # Creates a vip
Masayuki Igawa259c1132013-10-31 17:48:44 +0900114 name = data_utils.rand_name('vip-')
Elena Ezhovab40848f2014-01-15 10:17:35 +0400115 address = self.subnet['allocation_pools'][0]['end']
David Kranz34e88122014-12-11 15:24:05 -0500116 body = self.client.create_pool(
Eugene Nikanorov431e04a2013-12-17 15:44:27 +0400117 name=data_utils.rand_name("pool-"),
118 lb_method='ROUND_ROBIN',
119 protocol='HTTP',
120 subnet_id=self.subnet['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530121 pool = body['pool']
David Kranz34e88122014-12-11 15:24:05 -0500122 body = self.client.create_vip(name=name,
123 protocol="HTTP",
124 protocol_port=80,
125 subnet_id=self.subnet['id'],
126 pool_id=pool['id'],
127 address=address)
raiesmh080fe76852013-09-13 11:52:56 +0530128 vip = body['vip']
129 vip_id = vip['id']
Elena Ezhovab40848f2014-01-15 10:17:35 +0400130 # Confirm VIP's address correctness with a show
David Kranz34e88122014-12-11 15:24:05 -0500131 body = self.client.show_vip(vip_id)
Elena Ezhovab40848f2014-01-15 10:17:35 +0400132 vip = body['vip']
133 self.assertEqual(address, vip['address'])
raiesmh080fe76852013-09-13 11:52:56 +0530134 # Verification of vip update
135 new_name = "New_vip"
Elena Ezhovab40848f2014-01-15 10:17:35 +0400136 new_description = "New description"
137 persistence_type = "HTTP_COOKIE"
138 update_data = {"session_persistence": {
139 "type": persistence_type}}
David Kranz34e88122014-12-11 15:24:05 -0500140 body = self.client.update_vip(vip_id,
141 name=new_name,
142 description=new_description,
143 connection_limit=10,
144 admin_state_up=False,
145 **update_data)
raiesmh080fe76852013-09-13 11:52:56 +0530146 updated_vip = body['vip']
Elena Ezhovab40848f2014-01-15 10:17:35 +0400147 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'])
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200153 self.client.delete_vip(vip['id'])
izikpensod9a01a62014-02-17 20:02:32 +0200154 self.client.wait_for_resource_deletion('vip', vip['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530155 # Verification of pool update
156 new_name = "New_pool"
David Kranz34e88122014-12-11 15:24:05 -0500157 body = self.client.update_pool(pool['id'],
158 name=new_name,
159 description="new_description",
160 lb_method='LEAST_CONNECTIONS')
raiesmh080fe76852013-09-13 11:52:56 +0530161 updated_pool = body['pool']
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400162 self.assertEqual(new_name, updated_pool['name'])
163 self.assertEqual('new_description', updated_pool['description'])
164 self.assertEqual('LEAST_CONNECTIONS', updated_pool['lb_method'])
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200165 self.client.delete_pool(pool['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530166
Chris Hoge7579c1a2015-02-26 14:12:15 -0800167 @test.idempotent_id('0435a95e-1d19-4d90-9e9f-3b979e9ad089')
raiesmh080fe76852013-09-13 11:52:56 +0530168 def test_show_vip(self):
169 # Verifies the details of a vip
David Kranz34e88122014-12-11 15:24:05 -0500170 body = self.client.show_vip(self.vip['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530171 vip = body['vip']
Matthew Treinish71426682015-04-23 11:19:38 -0400172 for key, value in six.iteritems(vip):
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400173 # 'status' should not be confirmed in api tests
174 if key != 'status':
175 self.assertEqual(self.vip[key], value)
raiesmh0802d04b02013-09-16 12:10:10 +0530176
Chris Hoge7579c1a2015-02-26 14:12:15 -0800177 @test.idempotent_id('6e7a7d31-8451-456d-b24a-e50479ce42a7')
raiesmh08f5153f72013-09-16 13:38:37 +0530178 def test_show_pool(self):
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400179 # Here we need to new pool without any dependence with vips
David Kranz34e88122014-12-11 15:24:05 -0500180 body = self.client.create_pool(name=data_utils.rand_name("pool-"),
181 lb_method='ROUND_ROBIN',
182 protocol='HTTP',
183 subnet_id=self.subnet['id'])
raiesmh08f5153f72013-09-16 13:38:37 +0530184 pool = body['pool']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400185 self.addCleanup(self.client.delete_pool, pool['id'])
186 # Verifies the details of a pool
David Kranz34e88122014-12-11 15:24:05 -0500187 body = self.client.show_pool(pool['id'])
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400188 shown_pool = body['pool']
Matthew Treinish71426682015-04-23 11:19:38 -0400189 for key, value in six.iteritems(pool):
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400190 # 'status' should not be confirmed in api tests
191 if key != 'status':
192 self.assertEqual(value, shown_pool[key])
raiesmh08f5153f72013-09-16 13:38:37 +0530193
Chris Hoge7579c1a2015-02-26 14:12:15 -0800194 @test.idempotent_id('d1ab1ffa-e06a-487f-911f-56418cb27727')
raiesmh08f5153f72013-09-16 13:38:37 +0530195 def test_list_pools(self):
196 # Verify the pool exists in the list of all pools
David Kranz34e88122014-12-11 15:24:05 -0500197 body = self.client.list_pools()
raiesmh08f5153f72013-09-16 13:38:37 +0530198 pools = body['pools']
199 self.assertIn(self.pool['id'], [p['id'] for p in pools])
200
Chris Hoge7579c1a2015-02-26 14:12:15 -0800201 @test.idempotent_id('27cc4c1a-caac-4273-b983-2acb4afaad4f')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400202 def test_list_pools_with_filters(self):
203 attr_exceptions = ['status', 'vip_id', 'members', 'provider',
204 'status_description']
205 self._check_list_with_filter(
206 'pool', attr_exceptions, name=data_utils.rand_name("pool-"),
207 lb_method="ROUND_ROBIN", protocol="HTTPS",
208 subnet_id=self.subnet['id'],
209 description=data_utils.rand_name('description-'),
210 admin_state_up=False)
211
Chris Hoge7579c1a2015-02-26 14:12:15 -0800212 @test.idempotent_id('282d0dfd-5c3a-4c9b-b39c-c99782f39193')
raiesmh08f8437ed2013-09-17 10:59:38 +0530213 def test_list_members(self):
214 # Verify the member exists in the list of all members
David Kranz34e88122014-12-11 15:24:05 -0500215 body = self.client.list_members()
raiesmh08f8437ed2013-09-17 10:59:38 +0530216 members = body['members']
217 self.assertIn(self.member['id'], [m['id'] for m in members])
218
Chris Hoge7579c1a2015-02-26 14:12:15 -0800219 @test.idempotent_id('243b5126-24c6-4879-953e-7c7e32d8a57f')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400220 def test_list_members_with_filters(self):
221 attr_exceptions = ['status', 'status_description']
222 self._check_list_with_filter('member', attr_exceptions,
Sergey Shnaidman97e6a0f2014-11-12 20:00:53 +0300223 address=self.member_address,
224 protocol_port=80,
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400225 pool_id=self.pool['id'])
226
Chris Hoge7579c1a2015-02-26 14:12:15 -0800227 @test.idempotent_id('fb833ee8-9e69-489f-b540-a409762b78b2')
raiesmh08f8437ed2013-09-17 10:59:38 +0530228 def test_create_update_delete_member(self):
229 # Creates a member
David Kranz34e88122014-12-11 15:24:05 -0500230 body = self.client.create_member(address=self.member_address,
231 protocol_port=80,
232 pool_id=self.pool['id'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530233 member = body['member']
234 # Verification of member update
David Kranz34e88122014-12-11 15:24:05 -0500235 body = self.client.update_member(member['id'],
236 admin_state_up=False)
raiesmh08f8437ed2013-09-17 10:59:38 +0530237 updated_member = body['member']
Elena Ezhova43c70a22014-01-14 12:42:51 +0400238 self.assertFalse(updated_member['admin_state_up'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530239 # Verification of member delete
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200240 self.client.delete_member(member['id'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530241
Chris Hoge7579c1a2015-02-26 14:12:15 -0800242 @test.idempotent_id('893cd71f-a7dd-4485-b162-f6ab9a534914')
raiesmh08f8437ed2013-09-17 10:59:38 +0530243 def test_show_member(self):
244 # Verifies the details of a member
David Kranz34e88122014-12-11 15:24:05 -0500245 body = self.client.show_member(self.member['id'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530246 member = body['member']
Matthew Treinish71426682015-04-23 11:19:38 -0400247 for key, value in six.iteritems(member):
Matthew Treinishc795b9e2014-06-09 17:01:10 -0400248 # 'status' should not be confirmed in api tests
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400249 if key != 'status':
250 self.assertEqual(self.member[key], value)
raiesmh08f8437ed2013-09-17 10:59:38 +0530251
Chris Hoge7579c1a2015-02-26 14:12:15 -0800252 @test.idempotent_id('8e5822c5-68a4-4224-8d6c-a617741ebc2d')
raiesmh0832580d02013-09-17 13:11:34 +0530253 def test_list_health_monitors(self):
254 # Verify the health monitor exists in the list of all health monitors
David Kranz34e88122014-12-11 15:24:05 -0500255 body = self.client.list_health_monitors()
raiesmh0832580d02013-09-17 13:11:34 +0530256 health_monitors = body['health_monitors']
257 self.assertIn(self.health_monitor['id'],
258 [h['id'] for h in health_monitors])
259
Chris Hoge7579c1a2015-02-26 14:12:15 -0800260 @test.idempotent_id('49bac58a-511c-4875-b794-366698211d25')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400261 def test_list_health_monitors_with_filters(self):
262 attr_exceptions = ['status', 'status_description', 'pools']
263 self._check_list_with_filter('health_monitor', attr_exceptions,
264 delay=5, max_retries=4, type="TCP",
265 timeout=2)
266
Chris Hoge7579c1a2015-02-26 14:12:15 -0800267 @test.idempotent_id('e8ce05c4-d554-4d1e-a257-ad32ce134bb5')
raiesmh0832580d02013-09-17 13:11:34 +0530268 def test_create_update_delete_health_monitor(self):
269 # Creates a health_monitor
David Kranz34e88122014-12-11 15:24:05 -0500270 body = self.client.create_health_monitor(delay=4,
271 max_retries=3,
272 type="TCP",
273 timeout=1)
raiesmh0832580d02013-09-17 13:11:34 +0530274 health_monitor = body['health_monitor']
275 # Verification of health_monitor update
David Kranz34e88122014-12-11 15:24:05 -0500276 body = (self.client.update_health_monitor
277 (health_monitor['id'],
278 admin_state_up=False))
raiesmh0832580d02013-09-17 13:11:34 +0530279 updated_health_monitor = body['health_monitor']
Elena Ezhova43c70a22014-01-14 12:42:51 +0400280 self.assertFalse(updated_health_monitor['admin_state_up'])
raiesmh0832580d02013-09-17 13:11:34 +0530281 # Verification of health_monitor delete
David Kranz34e88122014-12-11 15:24:05 -0500282 body = self.client.delete_health_monitor(health_monitor['id'])
raiesmh0832580d02013-09-17 13:11:34 +0530283
Chris Hoge7579c1a2015-02-26 14:12:15 -0800284 @test.idempotent_id('d3e1aebc-06c2-49b3-9816-942af54012eb')
Elena Ezhovab40848f2014-01-15 10:17:35 +0400285 def test_create_health_monitor_http_type(self):
286 hm_type = "HTTP"
David Kranz34e88122014-12-11 15:24:05 -0500287 body = self.client.create_health_monitor(delay=4,
288 max_retries=3,
289 type=hm_type,
290 timeout=1)
Elena Ezhovab40848f2014-01-15 10:17:35 +0400291 health_monitor = body['health_monitor']
292 self.addCleanup(self.client.delete_health_monitor,
293 health_monitor['id'])
294 self.assertEqual(hm_type, health_monitor['type'])
295
Chris Hoge7579c1a2015-02-26 14:12:15 -0800296 @test.idempotent_id('0eff9f67-90fb-4bb1-b4ed-c5fda99fff0c')
Elena Ezhovab40848f2014-01-15 10:17:35 +0400297 def test_update_health_monitor_http_method(self):
David Kranz34e88122014-12-11 15:24:05 -0500298 body = self.client.create_health_monitor(delay=4,
299 max_retries=3,
300 type="HTTP",
301 timeout=1)
Elena Ezhovab40848f2014-01-15 10:17:35 +0400302 health_monitor = body['health_monitor']
303 self.addCleanup(self.client.delete_health_monitor,
304 health_monitor['id'])
David Kranz34e88122014-12-11 15:24:05 -0500305 body = (self.client.update_health_monitor
306 (health_monitor['id'],
307 http_method="POST",
308 url_path="/home/user",
309 expected_codes="290"))
Elena Ezhovab40848f2014-01-15 10:17:35 +0400310 updated_health_monitor = body['health_monitor']
311 self.assertEqual("POST", updated_health_monitor['http_method'])
312 self.assertEqual("/home/user", updated_health_monitor['url_path'])
313 self.assertEqual("290", updated_health_monitor['expected_codes'])
314
Chris Hoge7579c1a2015-02-26 14:12:15 -0800315 @test.idempotent_id('08e126ab-1407-483f-a22e-b11cc032ca7c')
raiesmh0832580d02013-09-17 13:11:34 +0530316 def test_show_health_monitor(self):
317 # Verifies the details of a health_monitor
David Kranz34e88122014-12-11 15:24:05 -0500318 body = self.client.show_health_monitor(self.health_monitor['id'])
raiesmh0832580d02013-09-17 13:11:34 +0530319 health_monitor = body['health_monitor']
Matthew Treinish71426682015-04-23 11:19:38 -0400320 for key, value in six.iteritems(health_monitor):
Matthew Treinishc795b9e2014-06-09 17:01:10 -0400321 # 'status' should not be confirmed in api tests
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400322 if key != 'status':
323 self.assertEqual(self.health_monitor[key], value)
raiesmh0832580d02013-09-17 13:11:34 +0530324
Chris Hoge7579c1a2015-02-26 14:12:15 -0800325 @test.idempotent_id('87f7628e-8918-493d-af50-0602845dbb5b')
raiesmh0832580d02013-09-17 13:11:34 +0530326 def test_associate_disassociate_health_monitor_with_pool(self):
327 # Verify that a health monitor can be associated with a pool
David Kranz34e88122014-12-11 15:24:05 -0500328 self.client.associate_health_monitor_with_pool(
329 self.health_monitor['id'], self.pool['id'])
330 body = self.client.show_health_monitor(
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400331 self.health_monitor['id'])
332 health_monitor = body['health_monitor']
David Kranz34e88122014-12-11 15:24:05 -0500333 body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400334 pool = body['pool']
335 self.assertIn(pool['id'],
336 [p['pool_id'] for p in health_monitor['pools']])
337 self.assertIn(health_monitor['id'], pool['health_monitors'])
raiesmh0832580d02013-09-17 13:11:34 +0530338 # Verify that a health monitor can be disassociated from a pool
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200339 (self.client.disassociate_health_monitor_with_pool
340 (self.health_monitor['id'], self.pool['id']))
David Kranz34e88122014-12-11 15:24:05 -0500341 body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400342 pool = body['pool']
David Kranz34e88122014-12-11 15:24:05 -0500343 body = self.client.show_health_monitor(
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400344 self.health_monitor['id'])
345 health_monitor = body['health_monitor']
346 self.assertNotIn(health_monitor['id'], pool['health_monitors'])
347 self.assertNotIn(pool['id'],
348 [p['pool_id'] for p in health_monitor['pools']])
raiesmh0832580d02013-09-17 13:11:34 +0530349
Chris Hoge7579c1a2015-02-26 14:12:15 -0800350 @test.idempotent_id('525fc7dc-be24-408d-938d-822e9783e027')
nayna-patel87b4ef22014-02-07 10:24:59 +0000351 def test_get_lb_pool_stats(self):
352 # Verify the details of pool stats
David Kranz34e88122014-12-11 15:24:05 -0500353 body = self.client.list_lb_pool_stats(self.pool['id'])
nayna-patel87b4ef22014-02-07 10:24:59 +0000354 stats = body['stats']
355 self.assertIn("bytes_in", stats)
356 self.assertIn("total_connections", stats)
357 self.assertIn("active_connections", stats)
358 self.assertIn("bytes_out", stats)
359
Chris Hoge7579c1a2015-02-26 14:12:15 -0800360 @test.idempotent_id('66236be2-5121-4047-8cde-db4b83b110a5')
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400361 def test_update_list_of_health_monitors_associated_with_pool(self):
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200362 (self.client.associate_health_monitor_with_pool
363 (self.health_monitor['id'], self.pool['id']))
364 self.client.update_health_monitor(
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400365 self.health_monitor['id'], admin_state_up=False)
David Kranz34e88122014-12-11 15:24:05 -0500366 body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400367 health_monitors = body['pool']['health_monitors']
368 for health_monitor_id in health_monitors:
David Kranz34e88122014-12-11 15:24:05 -0500369 body = self.client.show_health_monitor(health_monitor_id)
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400370 self.assertFalse(body['health_monitor']['admin_state_up'])
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200371 (self.client.disassociate_health_monitor_with_pool
372 (self.health_monitor['id'], self.pool['id']))
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400373
Chris Hoge7579c1a2015-02-26 14:12:15 -0800374 @test.idempotent_id('44ec9b40-b501-41e2-951f-4fc673b15ac0')
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400375 def test_update_admin_state_up_of_pool(self):
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200376 self.client.update_pool(self.pool['id'],
377 admin_state_up=False)
David Kranz34e88122014-12-11 15:24:05 -0500378 body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400379 pool = body['pool']
380 self.assertFalse(pool['admin_state_up'])
381
Chris Hoge7579c1a2015-02-26 14:12:15 -0800382 @test.idempotent_id('466a9d4c-37c6-4ea2-b807-133437beb48c')
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400383 def test_show_vip_associated_with_pool(self):
David Kranz34e88122014-12-11 15:24:05 -0500384 body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400385 pool = body['pool']
David Kranz34e88122014-12-11 15:24:05 -0500386 body = self.client.show_vip(pool['vip_id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400387 vip = body['vip']
388 self.assertEqual(self.vip['name'], vip['name'])
389 self.assertEqual(self.vip['id'], vip['id'])
390
Chris Hoge7579c1a2015-02-26 14:12:15 -0800391 @test.idempotent_id('7b97694e-69d0-4151-b265-e1052a465aa8')
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400392 def test_show_members_associated_with_pool(self):
David Kranz34e88122014-12-11 15:24:05 -0500393 body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400394 members = body['pool']['members']
395 for member_id in members:
David Kranz34e88122014-12-11 15:24:05 -0500396 body = self.client.show_member(member_id)
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400397 self.assertIsNotNone(body['member']['status'])
398 self.assertEqual(member_id, body['member']['id'])
399 self.assertIsNotNone(body['member']['admin_state_up'])
400
Chris Hoge7579c1a2015-02-26 14:12:15 -0800401 @test.idempotent_id('73ed6f27-595b-4b2c-969c-dbdda6b8ab34')
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400402 def test_update_pool_related_to_member(self):
403 # Create new pool
David Kranz34e88122014-12-11 15:24:05 -0500404 body = self.client.create_pool(name=data_utils.rand_name("pool-"),
405 lb_method='ROUND_ROBIN',
406 protocol='HTTP',
407 subnet_id=self.subnet['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400408 new_pool = body['pool']
409 self.addCleanup(self.client.delete_pool, new_pool['id'])
410 # Update member with new pool's id
David Kranz34e88122014-12-11 15:24:05 -0500411 body = self.client.update_member(self.member['id'],
412 pool_id=new_pool['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400413 # Confirm with show that pool_id change
David Kranz34e88122014-12-11 15:24:05 -0500414 body = self.client.show_member(self.member['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400415 member = body['member']
416 self.assertEqual(member['pool_id'], new_pool['id'])
417 # Update member with old pool id, this is needed for clean up
David Kranz34e88122014-12-11 15:24:05 -0500418 body = self.client.update_member(self.member['id'],
419 pool_id=self.pool['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400420
Chris Hoge7579c1a2015-02-26 14:12:15 -0800421 @test.idempotent_id('cf63f071-bbe3-40ba-97a0-a33e11923162')
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400422 def test_update_member_weight(self):
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200423 self.client.update_member(self.member['id'],
424 weight=2)
David Kranz34e88122014-12-11 15:24:05 -0500425 body = self.client.show_member(self.member['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400426 member = body['member']
427 self.assertEqual(2, member['weight'])
428
raiesmh0802d04b02013-09-16 12:10:10 +0530429
Matthew Treinishc49fcbe2015-02-05 23:37:34 -0500430@decorators.skip_because(bug="1402007")
Sergey Shnaidman97e6a0f2014-11-12 20:00:53 +0300431class LoadBalancerIpV6TestJSON(LoadBalancerTestJSON):
432 _ip_version = 6