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 |
| 41 | def setUpClass(cls): |
Ken'ichi Ohmichi | 91c675d | 2014-02-06 02:15:21 +0900 | [diff] [blame] | 42 | super(LoadBalancerTestJSON, cls).setUpClass() |
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 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 64 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 65 | def test_list_vips(self): |
| 66 | # Verify the vIP exists in the list of all vIPs |
| 67 | resp, body = self.client.list_vips() |
| 68 | self.assertEqual('200', resp['status']) |
| 69 | vips = body['vips'] |
| 70 | found = None |
| 71 | for n in vips: |
| 72 | if (n['id'] == self.vip['id']): |
| 73 | found = n['id'] |
| 74 | msg = "vIPs list doesn't contain created vip" |
| 75 | self.assertIsNotNone(found, msg) |
| 76 | |
| 77 | def test_create_update_delete_pool_vip(self): |
| 78 | # Creates a vip |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 79 | name = data_utils.rand_name('vip-') |
Eugene Nikanorov | 431e04a | 2013-12-17 15:44:27 +0400 | [diff] [blame] | 80 | resp, body = self.client.create_pool( |
| 81 | name=data_utils.rand_name("pool-"), |
| 82 | lb_method='ROUND_ROBIN', |
| 83 | protocol='HTTP', |
| 84 | subnet_id=self.subnet['id']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 85 | pool = body['pool'] |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 86 | resp, body = self.client.create_vip(name=name, |
| 87 | protocol="HTTP", |
| 88 | protocol_port=80, |
| 89 | subnet_id=self.subnet['id'], |
| 90 | pool_id=pool['id']) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 91 | self.assertEqual('201', resp['status']) |
| 92 | vip = body['vip'] |
| 93 | vip_id = vip['id'] |
| 94 | # Verification of vip update |
| 95 | new_name = "New_vip" |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 96 | resp, body = self.client.update_vip(vip_id, name=new_name) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 97 | self.assertEqual('200', resp['status']) |
| 98 | updated_vip = body['vip'] |
| 99 | self.assertEqual(updated_vip['name'], new_name) |
| 100 | # Verification of vip delete |
| 101 | resp, body = self.client.delete_vip(vip['id']) |
| 102 | self.assertEqual('204', resp['status']) |
| 103 | # Verification of pool update |
| 104 | new_name = "New_pool" |
Eugene Nikanorov | 431e04a | 2013-12-17 15:44:27 +0400 | [diff] [blame] | 105 | resp, body = self.client.update_pool(pool['id'], |
| 106 | name=new_name) |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 107 | self.assertEqual('200', resp['status']) |
| 108 | updated_pool = body['pool'] |
| 109 | self.assertEqual(updated_pool['name'], new_name) |
| 110 | # Verification of pool delete |
| 111 | resp, body = self.client.delete_pool(pool['id']) |
| 112 | self.assertEqual('204', resp['status']) |
| 113 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 114 | @test.attr(type='smoke') |
raiesmh08 | 0fe7685 | 2013-09-13 11:52:56 +0530 | [diff] [blame] | 115 | def test_show_vip(self): |
| 116 | # Verifies the details of a vip |
| 117 | resp, body = self.client.show_vip(self.vip['id']) |
| 118 | self.assertEqual('200', resp['status']) |
| 119 | vip = body['vip'] |
| 120 | self.assertEqual(self.vip['id'], vip['id']) |
| 121 | self.assertEqual(self.vip['name'], vip['name']) |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 122 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 123 | @test.attr(type='smoke') |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 124 | def test_show_pool(self): |
| 125 | # Verifies the details of a pool |
| 126 | resp, body = self.client.show_pool(self.pool['id']) |
| 127 | self.assertEqual('200', resp['status']) |
| 128 | pool = body['pool'] |
| 129 | self.assertEqual(self.pool['id'], pool['id']) |
| 130 | self.assertEqual(self.pool['name'], pool['name']) |
| 131 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 132 | @test.attr(type='smoke') |
raiesmh08 | f5153f7 | 2013-09-16 13:38:37 +0530 | [diff] [blame] | 133 | def test_list_pools(self): |
| 134 | # Verify the pool exists in the list of all pools |
| 135 | resp, body = self.client.list_pools() |
| 136 | self.assertEqual('200', resp['status']) |
| 137 | pools = body['pools'] |
| 138 | self.assertIn(self.pool['id'], [p['id'] for p in pools]) |
| 139 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 140 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 141 | def test_list_members(self): |
| 142 | # Verify the member exists in the list of all members |
| 143 | resp, body = self.client.list_members() |
| 144 | self.assertEqual('200', resp['status']) |
| 145 | members = body['members'] |
| 146 | self.assertIn(self.member['id'], [m['id'] for m in members]) |
| 147 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 148 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 149 | def test_create_update_delete_member(self): |
| 150 | # Creates a member |
Stephen Gran | abbe563 | 2013-11-19 19:16:14 +0000 | [diff] [blame] | 151 | resp, body = self.client.create_member("10.0.9.47", 80, |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 152 | self.pool['id']) |
| 153 | self.assertEqual('201', resp['status']) |
| 154 | member = body['member'] |
| 155 | # Verification of member update |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 156 | resp, body = self.client.update_member(False, member['id']) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 157 | self.assertEqual('200', resp['status']) |
| 158 | updated_member = body['member'] |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 159 | self.assertFalse(updated_member['admin_state_up']) |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 160 | # Verification of member delete |
| 161 | resp, body = self.client.delete_member(member['id']) |
| 162 | self.assertEqual('204', resp['status']) |
| 163 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 164 | @test.attr(type='smoke') |
raiesmh08 | f8437ed | 2013-09-17 10:59:38 +0530 | [diff] [blame] | 165 | def test_show_member(self): |
| 166 | # Verifies the details of a member |
| 167 | resp, body = self.client.show_member(self.member['id']) |
| 168 | self.assertEqual('200', resp['status']) |
| 169 | member = body['member'] |
| 170 | self.assertEqual(self.member['id'], member['id']) |
| 171 | self.assertEqual(self.member['admin_state_up'], |
| 172 | member['admin_state_up']) |
| 173 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 174 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 175 | def test_list_health_monitors(self): |
| 176 | # Verify the health monitor exists in the list of all health monitors |
| 177 | resp, body = self.client.list_health_monitors() |
| 178 | self.assertEqual('200', resp['status']) |
| 179 | health_monitors = body['health_monitors'] |
| 180 | self.assertIn(self.health_monitor['id'], |
| 181 | [h['id'] for h in health_monitors]) |
| 182 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 183 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 184 | def test_create_update_delete_health_monitor(self): |
| 185 | # Creates a health_monitor |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 186 | resp, body = self.client.create_health_monitor(delay=4, |
| 187 | max_retries=3, |
| 188 | type="TCP", |
| 189 | timeout=1) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 190 | self.assertEqual('201', resp['status']) |
| 191 | health_monitor = body['health_monitor'] |
| 192 | # Verification of health_monitor update |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 193 | resp, body = (self.client.update_health_monitor |
| 194 | (health_monitor['id'], |
| 195 | admin_state_up=False)) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 196 | self.assertEqual('200', resp['status']) |
| 197 | updated_health_monitor = body['health_monitor'] |
Elena Ezhova | 43c70a2 | 2014-01-14 12:42:51 +0400 | [diff] [blame] | 198 | self.assertFalse(updated_health_monitor['admin_state_up']) |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 199 | # Verification of health_monitor delete |
| 200 | resp, body = self.client.delete_health_monitor(health_monitor['id']) |
| 201 | self.assertEqual('204', resp['status']) |
| 202 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 203 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 204 | def test_show_health_monitor(self): |
| 205 | # Verifies the details of a health_monitor |
| 206 | resp, body = self.client.show_health_monitor(self.health_monitor['id']) |
| 207 | self.assertEqual('200', resp['status']) |
| 208 | health_monitor = body['health_monitor'] |
| 209 | self.assertEqual(self.health_monitor['id'], health_monitor['id']) |
| 210 | self.assertEqual(self.health_monitor['admin_state_up'], |
| 211 | health_monitor['admin_state_up']) |
| 212 | |
mouad benchchaoui | ea2440d | 2013-12-22 00:38:06 +0100 | [diff] [blame] | 213 | @test.attr(type='smoke') |
raiesmh08 | 32580d0 | 2013-09-17 13:11:34 +0530 | [diff] [blame] | 214 | def test_associate_disassociate_health_monitor_with_pool(self): |
| 215 | # Verify that a health monitor can be associated with a pool |
| 216 | resp, body = (self.client.associate_health_monitor_with_pool |
| 217 | (self.health_monitor['id'], self.pool['id'])) |
| 218 | self.assertEqual('201', resp['status']) |
| 219 | # Verify that a health monitor can be disassociated from a pool |
| 220 | resp, body = (self.client.disassociate_health_monitor_with_pool |
| 221 | (self.health_monitor['id'], self.pool['id'])) |
| 222 | self.assertEqual('204', resp['status']) |
| 223 | |
nayna-patel | 87b4ef2 | 2014-02-07 10:24:59 +0000 | [diff] [blame] | 224 | @test.attr(type='smoke') |
| 225 | def test_get_lb_pool_stats(self): |
| 226 | # Verify the details of pool stats |
| 227 | resp, body = self.client.list_lb_pool_stats(self.pool['id']) |
| 228 | self.assertEqual('200', resp['status']) |
| 229 | stats = body['stats'] |
| 230 | self.assertIn("bytes_in", stats) |
| 231 | self.assertIn("total_connections", stats) |
| 232 | self.assertIn("active_connections", stats) |
| 233 | self.assertIn("bytes_out", stats) |
| 234 | |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 235 | |
Ken'ichi Ohmichi | 91c675d | 2014-02-06 02:15:21 +0900 | [diff] [blame] | 236 | class LoadBalancerTestXML(LoadBalancerTestJSON): |
raiesmh08 | 02d04b0 | 2013-09-16 12:10:10 +0530 | [diff] [blame] | 237 | _interface = 'xml' |