blob: 65eebf299dd806410b5fa017a4a450f6110ad156 [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
21class LoadBalancerJSON(base.BaseNetworkTest):
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
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
41 def setUpClass(cls):
42 super(LoadBalancerJSON, cls).setUpClass()
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)
53 cls.vip = cls.create_vip(vip_name, "HTTP", 80, cls.subnet, cls.pool)
raiesmh08f8437ed2013-09-17 10:59:38 +053054 cls.member = cls.create_member(80, cls.pool)
raiesmh0832580d02013-09-17 13:11:34 +053055 cls.health_monitor = cls.create_health_monitor(4, 3, "TCP", 1)
raiesmh080fe76852013-09-13 11:52:56 +053056
mouad benchchaouiea2440d2013-12-22 00:38:06 +010057 @test.attr(type='smoke')
raiesmh080fe76852013-09-13 11:52:56 +053058 def test_list_vips(self):
59 # Verify the vIP exists in the list of all vIPs
60 resp, body = self.client.list_vips()
61 self.assertEqual('200', resp['status'])
62 vips = body['vips']
63 found = None
64 for n in vips:
65 if (n['id'] == self.vip['id']):
66 found = n['id']
67 msg = "vIPs list doesn't contain created vip"
68 self.assertIsNotNone(found, msg)
69
70 def test_create_update_delete_pool_vip(self):
71 # Creates a vip
Masayuki Igawa259c1132013-10-31 17:48:44 +090072 name = data_utils.rand_name('vip-')
Eugene Nikanorov431e04a2013-12-17 15:44:27 +040073 resp, body = self.client.create_pool(
74 name=data_utils.rand_name("pool-"),
75 lb_method='ROUND_ROBIN',
76 protocol='HTTP',
77 subnet_id=self.subnet['id'])
raiesmh080fe76852013-09-13 11:52:56 +053078 pool = body['pool']
79 resp, body = self.client.create_vip(name, "HTTP", 80,
80 self.subnet['id'], pool['id'])
81 self.assertEqual('201', resp['status'])
82 vip = body['vip']
83 vip_id = vip['id']
84 # Verification of vip update
85 new_name = "New_vip"
86 resp, body = self.client.update_vip(vip_id, new_name)
87 self.assertEqual('200', resp['status'])
88 updated_vip = body['vip']
89 self.assertEqual(updated_vip['name'], new_name)
90 # Verification of vip delete
91 resp, body = self.client.delete_vip(vip['id'])
92 self.assertEqual('204', resp['status'])
93 # Verification of pool update
94 new_name = "New_pool"
Eugene Nikanorov431e04a2013-12-17 15:44:27 +040095 resp, body = self.client.update_pool(pool['id'],
96 name=new_name)
raiesmh080fe76852013-09-13 11:52:56 +053097 self.assertEqual('200', resp['status'])
98 updated_pool = body['pool']
99 self.assertEqual(updated_pool['name'], new_name)
100 # Verification of pool delete
101 resp, body = self.client.delete_pool(pool['id'])
102 self.assertEqual('204', resp['status'])
103
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100104 @test.attr(type='smoke')
raiesmh080fe76852013-09-13 11:52:56 +0530105 def test_show_vip(self):
106 # Verifies the details of a vip
107 resp, body = self.client.show_vip(self.vip['id'])
108 self.assertEqual('200', resp['status'])
109 vip = body['vip']
110 self.assertEqual(self.vip['id'], vip['id'])
111 self.assertEqual(self.vip['name'], vip['name'])
raiesmh0802d04b02013-09-16 12:10:10 +0530112
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100113 @test.attr(type='smoke')
raiesmh08f5153f72013-09-16 13:38:37 +0530114 def test_show_pool(self):
115 # Verifies the details of a pool
116 resp, body = self.client.show_pool(self.pool['id'])
117 self.assertEqual('200', resp['status'])
118 pool = body['pool']
119 self.assertEqual(self.pool['id'], pool['id'])
120 self.assertEqual(self.pool['name'], pool['name'])
121
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100122 @test.attr(type='smoke')
raiesmh08f5153f72013-09-16 13:38:37 +0530123 def test_list_pools(self):
124 # Verify the pool exists in the list of all pools
125 resp, body = self.client.list_pools()
126 self.assertEqual('200', resp['status'])
127 pools = body['pools']
128 self.assertIn(self.pool['id'], [p['id'] for p in pools])
129
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100130 @test.attr(type='smoke')
raiesmh08f8437ed2013-09-17 10:59:38 +0530131 def test_list_members(self):
132 # Verify the member exists in the list of all members
133 resp, body = self.client.list_members()
134 self.assertEqual('200', resp['status'])
135 members = body['members']
136 self.assertIn(self.member['id'], [m['id'] for m in members])
137
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100138 @test.attr(type='smoke')
raiesmh08f8437ed2013-09-17 10:59:38 +0530139 def test_create_update_delete_member(self):
140 # Creates a member
Stephen Granabbe5632013-11-19 19:16:14 +0000141 resp, body = self.client.create_member("10.0.9.47", 80,
raiesmh08f8437ed2013-09-17 10:59:38 +0530142 self.pool['id'])
143 self.assertEqual('201', resp['status'])
144 member = body['member']
145 # Verification of member update
146 admin_state = [False, 'False']
147 resp, body = self.client.update_member(admin_state[0], member['id'])
148 self.assertEqual('200', resp['status'])
149 updated_member = body['member']
150 self.assertIn(updated_member['admin_state_up'], admin_state)
151 # Verification of member delete
152 resp, body = self.client.delete_member(member['id'])
153 self.assertEqual('204', resp['status'])
154
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100155 @test.attr(type='smoke')
raiesmh08f8437ed2013-09-17 10:59:38 +0530156 def test_show_member(self):
157 # Verifies the details of a member
158 resp, body = self.client.show_member(self.member['id'])
159 self.assertEqual('200', resp['status'])
160 member = body['member']
161 self.assertEqual(self.member['id'], member['id'])
162 self.assertEqual(self.member['admin_state_up'],
163 member['admin_state_up'])
164
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100165 @test.attr(type='smoke')
raiesmh0832580d02013-09-17 13:11:34 +0530166 def test_list_health_monitors(self):
167 # Verify the health monitor exists in the list of all health monitors
168 resp, body = self.client.list_health_monitors()
169 self.assertEqual('200', resp['status'])
170 health_monitors = body['health_monitors']
171 self.assertIn(self.health_monitor['id'],
172 [h['id'] for h in health_monitors])
173
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100174 @test.attr(type='smoke')
raiesmh0832580d02013-09-17 13:11:34 +0530175 def test_create_update_delete_health_monitor(self):
176 # Creates a health_monitor
177 resp, body = self.client.create_health_monitor(4, 3, "TCP", 1)
178 self.assertEqual('201', resp['status'])
179 health_monitor = body['health_monitor']
180 # Verification of health_monitor update
181 admin_state = [False, 'False']
182 resp, body = self.client.update_health_monitor(admin_state[0],
183 health_monitor['id'])
184 self.assertEqual('200', resp['status'])
185 updated_health_monitor = body['health_monitor']
186 self.assertIn(updated_health_monitor['admin_state_up'], admin_state)
187 # Verification of health_monitor delete
188 resp, body = self.client.delete_health_monitor(health_monitor['id'])
189 self.assertEqual('204', resp['status'])
190
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100191 @test.attr(type='smoke')
raiesmh0832580d02013-09-17 13:11:34 +0530192 def test_show_health_monitor(self):
193 # Verifies the details of a health_monitor
194 resp, body = self.client.show_health_monitor(self.health_monitor['id'])
195 self.assertEqual('200', resp['status'])
196 health_monitor = body['health_monitor']
197 self.assertEqual(self.health_monitor['id'], health_monitor['id'])
198 self.assertEqual(self.health_monitor['admin_state_up'],
199 health_monitor['admin_state_up'])
200
mouad benchchaouiea2440d2013-12-22 00:38:06 +0100201 @test.attr(type='smoke')
raiesmh0832580d02013-09-17 13:11:34 +0530202 def test_associate_disassociate_health_monitor_with_pool(self):
203 # Verify that a health monitor can be associated with a pool
204 resp, body = (self.client.associate_health_monitor_with_pool
205 (self.health_monitor['id'], self.pool['id']))
206 self.assertEqual('201', resp['status'])
207 # Verify that a health monitor can be disassociated from a pool
208 resp, body = (self.client.disassociate_health_monitor_with_pool
209 (self.health_monitor['id'], self.pool['id']))
210 self.assertEqual('204', resp['status'])
211
raiesmh0802d04b02013-09-16 12:10:10 +0530212
213class LoadBalancerXML(LoadBalancerJSON):
214 _interface = 'xml'