blob: baa8cadc9012d40b6fcf7b52d91cc36cad22a4fc [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
16from tempest.api.network import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090017from tempest.common.utils import data_utils
mouad benchchaouiea2440d2013-12-22 00:38:06 +010018from tempest import test
raiesmh080fe76852013-09-13 11:52:56 +053019
20
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +090021class LoadBalancerTestJSON(base.BaseNetworkTest):
raiesmh080fe76852013-09-13 11:52:56 +053022 _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
raiesmh08f5153f72013-09-16 13:38:37 +053035 show pool
36 list pool
raiesmh0832580d02013-09-17 13:11:34 +053037 health monitoring operations
raiesmh080fe76852013-09-13 11:52:56 +053038 """
39
40 @classmethod
Andrea Frittolida4a2452014-09-15 13:12:08 +010041 def resource_setup(cls):
42 super(LoadBalancerTestJSON, cls).resource_setup()
mouad benchchaouiea2440d2013-12-22 00:38:06 +010043 if not test.is_extension_enabled('lbaas', 'network'):
44 msg = "lbaas extension not enabled."
45 raise cls.skipException(msg)
raiesmh080fe76852013-09-13 11:52:56 +053046 cls.network = cls.create_network()
47 cls.name = cls.network['name']
48 cls.subnet = cls.create_subnet(cls.network)
Masayuki Igawa259c1132013-10-31 17:48:44 +090049 pool_name = data_utils.rand_name('pool-')
50 vip_name = data_utils.rand_name('vip-')
raiesmh080fe76852013-09-13 11:52:56 +053051 cls.pool = cls.create_pool(pool_name, "ROUND_ROBIN",
52 "HTTP", cls.subnet)
Elena Ezhova43c70a22014-01-14 12:42:51 +040053 cls.vip = cls.create_vip(name=vip_name,
54 protocol="HTTP",
55 protocol_port=80,
56 subnet=cls.subnet,
57 pool=cls.pool)
raiesmh08f8437ed2013-09-17 10:59:38 +053058 cls.member = cls.create_member(80, cls.pool)
Elena Ezhova43c70a22014-01-14 12:42:51 +040059 cls.health_monitor = cls.create_health_monitor(delay=4,
60 max_retries=3,
61 Type="TCP",
62 timeout=1)
raiesmh080fe76852013-09-13 11:52:56 +053063
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040064 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 Kanadeeeb21642014-08-14 12:00:26 +020069 _, body = create_obj(**kwargs)
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040070 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 Kanadeeeb21642014-08-14 12:00:26 +020076 _, body = list_objs(**{key: value})
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040077 objs = [v[key] for v in body[obj_name + 's']]
78 self.assertIn(value, objs)
79
mouad benchchaouiea2440d2013-12-22 00:38:06 +010080 @test.attr(type='smoke')
raiesmh080fe76852013-09-13 11:52:56 +053081 def test_list_vips(self):
82 # Verify the vIP exists in the list of all vIPs
Rohan Kanadeeeb21642014-08-14 12:00:26 +020083 _, body = self.client.list_vips()
raiesmh080fe76852013-09-13 11:52:56 +053084 vips = body['vips']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040085 self.assertIn(self.vip['id'], [v['id'] for v in vips])
raiesmh080fe76852013-09-13 11:52:56 +053086
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +040087 @test.attr(type='smoke')
88 def test_list_vips_with_filter(self):
89 name = data_utils.rand_name('vip-')
Rohan Kanadeeeb21642014-08-14 12:00:26 +020090 _, 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 Kamyshnikova2bc1c432013-12-10 17:31:50 +040094 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')
raiesmh080fe76852013-09-13 11:52:56 +0530105 def test_create_update_delete_pool_vip(self):
106 # Creates a vip
Masayuki Igawa259c1132013-10-31 17:48:44 +0900107 name = data_utils.rand_name('vip-')
Elena Ezhovab40848f2014-01-15 10:17:35 +0400108 address = self.subnet['allocation_pools'][0]['end']
Eugene Nikanorov431e04a2013-12-17 15:44:27 +0400109 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'])
raiesmh080fe76852013-09-13 11:52:56 +0530114 pool = body['pool']
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200115 _, 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)
raiesmh080fe76852013-09-13 11:52:56 +0530121 vip = body['vip']
122 vip_id = vip['id']
Elena Ezhovab40848f2014-01-15 10:17:35 +0400123 # Confirm VIP's address correctness with a show
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200124 _, body = self.client.show_vip(vip_id)
Elena Ezhovab40848f2014-01-15 10:17:35 +0400125 vip = body['vip']
126 self.assertEqual(address, vip['address'])
raiesmh080fe76852013-09-13 11:52:56 +0530127 # Verification of vip update
128 new_name = "New_vip"
Elena Ezhovab40848f2014-01-15 10:17:35 +0400129 new_description = "New description"
130 persistence_type = "HTTP_COOKIE"
131 update_data = {"session_persistence": {
132 "type": persistence_type}}
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200133 _, 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)
raiesmh080fe76852013-09-13 11:52:56 +0530139 updated_vip = body['vip']
Elena Ezhovab40848f2014-01-15 10:17:35 +0400140 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 Kanadeeeb21642014-08-14 12:00:26 +0200146 self.client.delete_vip(vip['id'])
izikpensod9a01a62014-02-17 20:02:32 +0200147 self.client.wait_for_resource_deletion('vip', vip['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530148 # Verification of pool update
149 new_name = "New_pool"
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200150 _, body = self.client.update_pool(pool['id'],
151 name=new_name,
152 description="new_description",
153 lb_method='LEAST_CONNECTIONS')
raiesmh080fe76852013-09-13 11:52:56 +0530154 updated_pool = body['pool']
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400155 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 Kanadeeeb21642014-08-14 12:00:26 +0200158 self.client.delete_pool(pool['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530159
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100160 @test.attr(type='smoke')
raiesmh080fe76852013-09-13 11:52:56 +0530161 def test_show_vip(self):
162 # Verifies the details of a vip
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200163 _, body = self.client.show_vip(self.vip['id'])
raiesmh080fe76852013-09-13 11:52:56 +0530164 vip = body['vip']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400165 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)
raiesmh0802d04b02013-09-16 12:10:10 +0530169
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100170 @test.attr(type='smoke')
raiesmh08f5153f72013-09-16 13:38:37 +0530171 def test_show_pool(self):
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400172 # Here we need to new pool without any dependence with vips
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200173 _, 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'])
raiesmh08f5153f72013-09-16 13:38:37 +0530177 pool = body['pool']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400178 self.addCleanup(self.client.delete_pool, pool['id'])
179 # Verifies the details of a pool
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200180 _, body = self.client.show_pool(pool['id'])
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400181 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])
raiesmh08f5153f72013-09-16 13:38:37 +0530186
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100187 @test.attr(type='smoke')
raiesmh08f5153f72013-09-16 13:38:37 +0530188 def test_list_pools(self):
189 # Verify the pool exists in the list of all pools
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200190 _, body = self.client.list_pools()
raiesmh08f5153f72013-09-16 13:38:37 +0530191 pools = body['pools']
192 self.assertIn(self.pool['id'], [p['id'] for p in pools])
193
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100194 @test.attr(type='smoke')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400195 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')
raiesmh08f8437ed2013-09-17 10:59:38 +0530206 def test_list_members(self):
207 # Verify the member exists in the list of all members
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200208 _, body = self.client.list_members()
raiesmh08f8437ed2013-09-17 10:59:38 +0530209 members = body['members']
210 self.assertIn(self.member['id'], [m['id'] for m in members])
211
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100212 @test.attr(type='smoke')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400213 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')
raiesmh08f8437ed2013-09-17 10:59:38 +0530220 def test_create_update_delete_member(self):
221 # Creates a member
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200222 _, body = self.client.create_member(address="10.0.9.47",
223 protocol_port=80,
224 pool_id=self.pool['id'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530225 member = body['member']
226 # Verification of member update
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200227 _, body = self.client.update_member(member['id'],
228 admin_state_up=False)
raiesmh08f8437ed2013-09-17 10:59:38 +0530229 updated_member = body['member']
Elena Ezhova43c70a22014-01-14 12:42:51 +0400230 self.assertFalse(updated_member['admin_state_up'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530231 # Verification of member delete
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200232 self.client.delete_member(member['id'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530233
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100234 @test.attr(type='smoke')
raiesmh08f8437ed2013-09-17 10:59:38 +0530235 def test_show_member(self):
236 # Verifies the details of a member
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200237 _, body = self.client.show_member(self.member['id'])
raiesmh08f8437ed2013-09-17 10:59:38 +0530238 member = body['member']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400239 for key, value in member.iteritems():
Matthew Treinishc795b9e2014-06-09 17:01:10 -0400240 # 'status' should not be confirmed in api tests
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400241 if key != 'status':
242 self.assertEqual(self.member[key], value)
raiesmh08f8437ed2013-09-17 10:59:38 +0530243
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100244 @test.attr(type='smoke')
raiesmh0832580d02013-09-17 13:11:34 +0530245 def test_list_health_monitors(self):
246 # Verify the health monitor exists in the list of all health monitors
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200247 _, body = self.client.list_health_monitors()
raiesmh0832580d02013-09-17 13:11:34 +0530248 health_monitors = body['health_monitors']
249 self.assertIn(self.health_monitor['id'],
250 [h['id'] for h in health_monitors])
251
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100252 @test.attr(type='smoke')
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400253 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')
raiesmh0832580d02013-09-17 13:11:34 +0530260 def test_create_update_delete_health_monitor(self):
261 # Creates a health_monitor
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200262 _, body = self.client.create_health_monitor(delay=4,
263 max_retries=3,
264 type="TCP",
265 timeout=1)
raiesmh0832580d02013-09-17 13:11:34 +0530266 health_monitor = body['health_monitor']
267 # Verification of health_monitor update
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200268 _, body = (self.client.update_health_monitor
269 (health_monitor['id'],
270 admin_state_up=False))
raiesmh0832580d02013-09-17 13:11:34 +0530271 updated_health_monitor = body['health_monitor']
Elena Ezhova43c70a22014-01-14 12:42:51 +0400272 self.assertFalse(updated_health_monitor['admin_state_up'])
raiesmh0832580d02013-09-17 13:11:34 +0530273 # Verification of health_monitor delete
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200274 _, body = self.client.delete_health_monitor(health_monitor['id'])
raiesmh0832580d02013-09-17 13:11:34 +0530275
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100276 @test.attr(type='smoke')
Elena Ezhovab40848f2014-01-15 10:17:35 +0400277 def test_create_health_monitor_http_type(self):
278 hm_type = "HTTP"
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200279 _, body = self.client.create_health_monitor(delay=4,
280 max_retries=3,
281 type=hm_type,
282 timeout=1)
Elena Ezhovab40848f2014-01-15 10:17:35 +0400283 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 Kanadeeeb21642014-08-14 12:00:26 +0200290 _, body = self.client.create_health_monitor(delay=4,
291 max_retries=3,
292 type="HTTP",
293 timeout=1)
Elena Ezhovab40848f2014-01-15 10:17:35 +0400294 health_monitor = body['health_monitor']
295 self.addCleanup(self.client.delete_health_monitor,
296 health_monitor['id'])
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200297 _, body = (self.client.update_health_monitor
298 (health_monitor['id'],
299 http_method="POST",
300 url_path="/home/user",
301 expected_codes="290"))
Elena Ezhovab40848f2014-01-15 10:17:35 +0400302 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')
raiesmh0832580d02013-09-17 13:11:34 +0530308 def test_show_health_monitor(self):
309 # Verifies the details of a health_monitor
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200310 _, body = self.client.show_health_monitor(self.health_monitor['id'])
raiesmh0832580d02013-09-17 13:11:34 +0530311 health_monitor = body['health_monitor']
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400312 for key, value in health_monitor.iteritems():
Matthew Treinishc795b9e2014-06-09 17:01:10 -0400313 # 'status' should not be confirmed in api tests
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400314 if key != 'status':
315 self.assertEqual(self.health_monitor[key], value)
raiesmh0832580d02013-09-17 13:11:34 +0530316
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100317 @test.attr(type='smoke')
raiesmh0832580d02013-09-17 13:11:34 +0530318 def test_associate_disassociate_health_monitor_with_pool(self):
319 # Verify that a health monitor can be associated with a pool
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200320 _, body = (self.client.associate_health_monitor_with_pool
321 (self.health_monitor['id'], self.pool['id']))
Ann Kamyshnikova2bc1c432013-12-10 17:31:50 +0400322 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'])
raiesmh0832580d02013-09-17 13:11:34 +0530330 # Verify that a health monitor can be disassociated from a pool
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200331 (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 Kamyshnikova2bc1c432013-12-10 17:31:50 +0400334 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']])
raiesmh0832580d02013-09-17 13:11:34 +0530341
nayna-patel87b4ef22014-02-07 10:24:59 +0000342 @test.attr(type='smoke')
343 def test_get_lb_pool_stats(self):
344 # Verify the details of pool stats
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200345 _, body = self.client.list_lb_pool_stats(self.pool['id'])
nayna-patel87b4ef22014-02-07 10:24:59 +0000346 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 Kamyshnikovab6659402014-01-09 17:50:31 +0400352 @test.attr(type='smoke')
353 def test_update_list_of_health_monitors_associated_with_pool(self):
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200354 (self.client.associate_health_monitor_with_pool
355 (self.health_monitor['id'], self.pool['id']))
356 self.client.update_health_monitor(
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400357 self.health_monitor['id'], admin_state_up=False)
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200358 _, body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400359 health_monitors = body['pool']['health_monitors']
360 for health_monitor_id in health_monitors:
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200361 _, body = self.client.show_health_monitor(health_monitor_id)
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400362 self.assertFalse(body['health_monitor']['admin_state_up'])
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200363 (self.client.disassociate_health_monitor_with_pool
364 (self.health_monitor['id'], self.pool['id']))
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400365
366 @test.attr(type='smoke')
367 def test_update_admin_state_up_of_pool(self):
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200368 self.client.update_pool(self.pool['id'],
369 admin_state_up=False)
370 _, body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400371 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 Kanadeeeb21642014-08-14 12:00:26 +0200376 _, body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400377 pool = body['pool']
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200378 _, body = self.client.show_vip(pool['vip_id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400379 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 Kanadeeeb21642014-08-14 12:00:26 +0200385 _, body = self.client.show_pool(self.pool['id'])
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400386 members = body['pool']['members']
387 for member_id in members:
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200388 _, body = self.client.show_member(member_id)
Ann Kamyshnikovab6659402014-01-09 17:50:31 +0400389 self.assertIsNotNone(body['member']['status'])
390 self.assertEqual(member_id, body['member']['id'])
391 self.assertIsNotNone(body['member']['admin_state_up'])
392
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400393 @test.attr(type='smoke')
394 def test_update_pool_related_to_member(self):
395 # Create new pool
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200396 _, 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 Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400400 new_pool = body['pool']
401 self.addCleanup(self.client.delete_pool, new_pool['id'])
402 # Update member with new pool's id
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200403 _, body = self.client.update_member(self.member['id'],
404 pool_id=new_pool['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400405 # 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 Kanadeeeb21642014-08-14 12:00:26 +0200410 _, body = self.client.update_member(self.member['id'],
411 pool_id=self.pool['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400412
413 @test.attr(type='smoke')
414 def test_update_member_weight(self):
Rohan Kanadeeeb21642014-08-14 12:00:26 +0200415 self.client.update_member(self.member['id'],
416 weight=2)
417 _, body = self.client.show_member(self.member['id'])
Ann Kamyshnikova4f5d0b92014-01-13 16:53:48 +0400418 member = body['member']
419 self.assertEqual(2, member['weight'])
420
raiesmh0802d04b02013-09-16 12:10:10 +0530421
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +0900422class LoadBalancerTestXML(LoadBalancerTestJSON):
raiesmh0802d04b02013-09-16 12:10:10 +0530423 _interface = 'xml'