| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
import testtools |
| 16 |
import time |
| 17 |
from uuid import UUID |
| 18 |
|
| 19 |
from dateutil import parser |
| 20 |
from tempest import config |
| 21 |
from tempest.lib.common.utils import data_utils |
| 22 |
from tempest.lib import decorators |
| 23 |
from tempest.lib import exceptions |
| 24 |
|
| 25 |
from octavia_tempest_plugin.common import constants as const |
| 26 |
from octavia_tempest_plugin.tests import test_base |
| 27 |
from octavia_tempest_plugin.tests import waiters |
| 28 |
|
| 29 |
CONF = config.CONF |
| 30 |
|
| 31 |
|
| 32 |
class PoolAPITest(test_base.LoadBalancerBaseTest): |
| 33 |
"""Test the pool object API.""" |
| 34 |
|
| 35 |
@classmethod |
| 36 |
def resource_setup(cls): |
| 37 |
"""Setup resources needed by the tests.""" |
| 38 |
super(PoolAPITest, cls).resource_setup() |
| 39 |
|
| 40 |
lb_name = data_utils.rand_name("lb_member_lb1_pool") |
| 41 |
lb_kwargs = {const.PROVIDER: CONF.load_balancer.provider, |
| 42 |
const.NAME: lb_name} |
| 43 |
cls._setup_lb_network_kwargs(lb_kwargs) |
| 44 |
|
| 45 |
lb = cls.mem_lb_client.create_loadbalancer(**lb_kwargs) |
| 46 |
cls.lb_id = lb[const.ID] |
| 47 |
cls.addClassResourceCleanup( |
| 48 |
cls.mem_lb_client.cleanup_loadbalancer, |
| 49 |
cls.lb_id, cascade=True) |
| 50 |
|
| 51 |
waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer, |
| 52 |
cls.lb_id, const.PROVISIONING_STATUS, |
| 53 |
const.ACTIVE, |
| 54 |
CONF.load_balancer.lb_build_interval, |
| 55 |
CONF.load_balancer.lb_build_timeout) |
| 56 |
|
| 57 |
|
| 58 |
@decorators.idempotent_id('29f1a69d-6a0d-4a85-b178-f50f5b4bdfbc') |
| 59 |
def test_HTTP_LC_pool_standalone_create(self): |
| 60 |
self._test_pool_create(listener_protocol=None, |
| 61 |
pool_protocol=const.HTTP, protocol_port=10, |
| 62 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 63 |
|
| 64 |
@decorators.idempotent_id('5086402a-2339-4238-bddb-d30508e6cc53') |
| 65 |
def test_HTTP_LC_pool_with_listener_create(self): |
| 66 |
self._test_pool_create(listener_protocol=const.HTTP, |
| 67 |
pool_protocol=const.HTTP, protocol_port=11, |
| 68 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 69 |
|
| 70 |
@decorators.idempotent_id('eb84fabc-68e6-44f7-955d-4919f045cd08') |
| 71 |
def test_HTTPS_LC_pool_standalone_create(self): |
| 72 |
self._test_pool_create(listener_protocol=None, |
| 73 |
pool_protocol=const.HTTPS, protocol_port=12, |
| 74 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 75 |
|
| 76 |
@decorators.idempotent_id('664fc4d3-70d9-41c5-b3f8-c006726062ae') |
| 77 |
def test_HTTPS_LC_pool_with_listener_create(self): |
| 78 |
self._test_pool_create(listener_protocol=const.HTTPS, |
| 79 |
pool_protocol=const.HTTPS, protocol_port=13, |
| 80 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 81 |
|
| 82 |
@decorators.idempotent_id('08e35f78-a85d-48d2-8ac3-14c5e68b64f7') |
| 83 |
def test_PROXY_LC_pool_standalone_create(self): |
| 84 |
self._test_pool_create(listener_protocol=None, |
| 85 |
pool_protocol=const.PROXY, protocol_port=14, |
| 86 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 87 |
|
| 88 |
@decorators.idempotent_id('044f460b-47ec-4e97-96be-c7ab812bfa16') |
| 89 |
def test_PROXY_LC_pool_with_listener_create(self): |
| 90 |
self._test_pool_create(listener_protocol=const.TCP, |
| 91 |
pool_protocol=const.PROXY, protocol_port=15, |
| 92 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 93 |
|
| 94 |
@decorators.idempotent_id('8f552da6-38f8-44b8-b69b-072cc1e232a6') |
| 95 |
def test_TCP_LC_pool_standalone_create(self): |
| 96 |
self._test_pool_create(listener_protocol=None, |
| 97 |
pool_protocol=const.TCP, protocol_port=16, |
| 98 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 99 |
|
| 100 |
@decorators.idempotent_id('728b974f-ff59-479b-ada5-de280bbaaf02') |
| 101 |
def test_TCP_LC_pool_with_listener_create(self): |
| 102 |
self._test_pool_create(listener_protocol=const.TCP, |
| 103 |
pool_protocol=const.TCP, protocol_port=17, |
| 104 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 105 |
|
| 106 |
@decorators.idempotent_id('0cb032d9-e092-476e-9aaf-463eea58fc16') |
| 107 |
def test_UDP_LC_pool_standalone_create(self): |
| 108 |
self._test_pool_create(listener_protocol=None, |
| 109 |
pool_protocol=const.UDP, protocol_port=18, |
| 110 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 111 |
|
| 112 |
@decorators.idempotent_id('9bf3bb05-ee36-47f3-b669-78f06a94035d') |
| 113 |
def test_UDP_LC_pool_with_listener_create(self): |
| 114 |
self._test_pool_create(listener_protocol=const.UDP, |
| 115 |
pool_protocol=const.UDP, protocol_port=19, |
| 116 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 117 |
|
| 118 |
|
| 119 |
@decorators.idempotent_id('7587fe48-87ba-4538-9f03-190911f100ff') |
| 120 |
def test_HTTP_RR_pool_standalone_create(self): |
| 121 |
self._test_pool_create(listener_protocol=None, |
| 122 |
pool_protocol=const.HTTP, protocol_port=20, |
| 123 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 124 |
|
| 125 |
@decorators.idempotent_id('c9c0df79-f07e-428c-ae57-b9d4078eec79') |
| 126 |
def test_HTTP_RR_pool_with_listener_create(self): |
| 127 |
self._test_pool_create(listener_protocol=const.HTTP, |
| 128 |
pool_protocol=const.HTTP, protocol_port=21, |
| 129 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 130 |
|
| 131 |
@decorators.idempotent_id('cc940a8b-b21c-46f5-9976-d2c8dd73b626') |
| 132 |
def test_HTTPS_RR_pool_standalone_create(self): |
| 133 |
self._test_pool_create(listener_protocol=None, |
| 134 |
pool_protocol=const.HTTPS, protocol_port=22, |
| 135 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 136 |
|
| 137 |
@decorators.idempotent_id('10df2793-63b2-42a3-a5d0-9241a9d700a3') |
| 138 |
def test_HTTPS_RR_pool_with_listener_create(self): |
| 139 |
self._test_pool_create(listener_protocol=const.HTTPS, |
| 140 |
pool_protocol=const.HTTPS, protocol_port=23, |
| 141 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 142 |
|
| 143 |
@decorators.idempotent_id('4d6c124e-73ea-4b32-bd1c-3ff7be2c4e55') |
| 144 |
def test_PROXY_RR_pool_standalone_create(self): |
| 145 |
self._test_pool_create(listener_protocol=None, |
| 146 |
pool_protocol=const.PROXY, protocol_port=24, |
| 147 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 148 |
|
| 149 |
@decorators.idempotent_id('60406086-b0a9-4f55-8f64-df161981443c') |
| 150 |
def test_PROXY_RR_pool_with_listener_create(self): |
| 151 |
self._test_pool_create(listener_protocol=const.TCP, |
| 152 |
pool_protocol=const.PROXY, protocol_port=25, |
| 153 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 154 |
|
| 155 |
@decorators.idempotent_id('41a5f22e-80e8-4d85-bfd6-2726846ed2ce') |
| 156 |
def test_TCP_RR_pool_standalone_create(self): |
| 157 |
self._test_pool_create(listener_protocol=None, |
| 158 |
pool_protocol=const.TCP, protocol_port=26, |
| 159 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 160 |
|
| 161 |
@decorators.idempotent_id('b76432ae-1aa2-4048-b326-1cbda28415ac') |
| 162 |
def test_TCP_RR_pool_with_listener_create(self): |
| 163 |
self._test_pool_create(listener_protocol=const.TCP, |
| 164 |
pool_protocol=const.TCP, protocol_port=27, |
| 165 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 166 |
|
| 167 |
@decorators.idempotent_id('c09be35d-8a8b-4abd-8752-2cb4d7d7fab2') |
| 168 |
def test_UDP_RR_pool_standalone_create(self): |
| 169 |
self._test_pool_create(listener_protocol=None, |
| 170 |
pool_protocol=const.UDP, protocol_port=28, |
| 171 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 172 |
|
| 173 |
@decorators.idempotent_id('4fb59ed9-5c44-437e-a5f9-bb01b9ba6a72') |
| 174 |
def test_UDP_RR_pool_with_listener_create(self): |
| 175 |
self._test_pool_create(listener_protocol=const.UDP, |
| 176 |
pool_protocol=const.UDP, protocol_port=29, |
| 177 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 178 |
|
| 179 |
|
| 180 |
@decorators.idempotent_id('a8b1b41c-5c3c-4c17-a2d4-b7c344520e3d') |
| 181 |
def test_HTTP_SI_pool_standalone_create(self): |
| 182 |
self._test_pool_create(listener_protocol=None, |
| 183 |
pool_protocol=const.HTTP, protocol_port=30, |
| 184 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 185 |
|
| 186 |
@decorators.idempotent_id('0136341c-4622-4f65-a59d-b9983331d627') |
| 187 |
def test_HTTP_SI_pool_with_listener_create(self): |
| 188 |
self._test_pool_create(listener_protocol=const.HTTP, |
| 189 |
pool_protocol=const.HTTP, protocol_port=31, |
| 190 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 191 |
|
| 192 |
@decorators.idempotent_id('d69c5e0b-43b5-4afe-a94a-1a4f93e44a93') |
| 193 |
def test_HTTPS_SI_pool_standalone_create(self): |
| 194 |
self._test_pool_create(listener_protocol=None, |
| 195 |
pool_protocol=const.HTTPS, protocol_port=32, |
| 196 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 197 |
|
| 198 |
@decorators.idempotent_id('04cc43f2-9eab-4552-b8c1-cea9e1325696') |
| 199 |
def test_HTTPS_SI_pool_with_listener_create(self): |
| 200 |
self._test_pool_create(listener_protocol=const.HTTPS, |
| 201 |
pool_protocol=const.HTTPS, protocol_port=33, |
| 202 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 203 |
|
| 204 |
@decorators.idempotent_id('cc42779d-71f8-4a7c-8217-02127be344ce') |
| 205 |
def test_PROXY_SI_pool_standalone_create(self): |
| 206 |
self._test_pool_create(listener_protocol=None, |
| 207 |
pool_protocol=const.PROXY, protocol_port=34, |
| 208 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 209 |
|
| 210 |
@decorators.idempotent_id('c845d8d3-30d7-42c3-8943-9a4582c62e2d') |
| 211 |
def test_PROXY_SI_pool_with_listener_create(self): |
| 212 |
self._test_pool_create(listener_protocol=const.TCP, |
| 213 |
pool_protocol=const.PROXY, protocol_port=35, |
| 214 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 215 |
|
| 216 |
@decorators.idempotent_id('869b4208-5821-44f5-acf6-4f087c4dd79c') |
| 217 |
def test_TCP_SI_pool_standalone_create(self): |
| 218 |
self._test_pool_create(listener_protocol=None, |
| 219 |
pool_protocol=const.TCP, protocol_port=36, |
| 220 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 221 |
|
| 222 |
@decorators.idempotent_id('4b0be593-b2e4-4704-a347-c36dae76aaad') |
| 223 |
def test_TCP_SI_pool_with_listener_create(self): |
| 224 |
self._test_pool_create(listener_protocol=const.TCP, |
| 225 |
pool_protocol=const.TCP, protocol_port=37, |
| 226 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 227 |
|
| 228 |
@decorators.idempotent_id('47af95cb-685a-48de-9d17-66108cdfd3fa') |
| 229 |
def test_UDP_SI_pool_standalone_create(self): |
| 230 |
self._test_pool_create(listener_protocol=None, |
| 231 |
pool_protocol=const.UDP, protocol_port=38, |
| 232 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 233 |
|
| 234 |
@decorators.idempotent_id('0115ab0c-e8fd-434a-9448-7fba55a8f27d') |
| 235 |
def test_UDP_SI_pool_with_listener_create(self): |
| 236 |
self._test_pool_create(listener_protocol=const.UDP, |
| 237 |
pool_protocol=const.UDP, protocol_port=39, |
| 238 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 239 |
|
| 240 |
|
| 241 |
@decorators.idempotent_id('265ba978-a528-429c-9ef7-c36373ee2225') |
| 242 |
def test_HTTP_SIP_pool_standalone_create(self): |
| 243 |
self._test_pool_create(listener_protocol=None, |
| 244 |
pool_protocol=const.HTTP, protocol_port=40, |
| 245 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 246 |
|
| 247 |
@decorators.idempotent_id('a07e2ff0-90f3-43d3-a7ec-5ca93b7f29bf') |
| 248 |
def test_HTTP_SIP_pool_with_listener_create(self): |
| 249 |
self._test_pool_create(listener_protocol=const.HTTP, |
| 250 |
pool_protocol=const.HTTP, protocol_port=41, |
| 251 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 252 |
|
| 253 |
@decorators.idempotent_id('7da08af5-e225-46df-b0b4-a5f1834a5377') |
| 254 |
def test_HTTPS_SIP_pool_standalone_create(self): |
| 255 |
self._test_pool_create(listener_protocol=None, |
| 256 |
pool_protocol=const.HTTPS, protocol_port=42, |
| 257 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 258 |
|
| 259 |
@decorators.idempotent_id('3d52a82e-e488-445a-8599-87e9bb7153eb') |
| 260 |
def test_HTTPS_SIP_pool_with_listener_create(self): |
| 261 |
self._test_pool_create(listener_protocol=const.HTTPS, |
| 262 |
pool_protocol=const.HTTPS, protocol_port=43, |
| 263 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 264 |
|
| 265 |
@decorators.idempotent_id('ad4cb862-fa37-4874-99c1-511cdcd86f91') |
| 266 |
def test_PROXY_SIP_pool_standalone_create(self): |
| 267 |
self._test_pool_create(listener_protocol=None, |
| 268 |
pool_protocol=const.PROXY, protocol_port=44, |
| 269 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 270 |
|
| 271 |
@decorators.idempotent_id('bcf76f26-e801-4ab4-b338-b210457d592e') |
| 272 |
def test_PROXY_SIP_pool_with_listener_create(self): |
| 273 |
self._test_pool_create(listener_protocol=const.TCP, |
| 274 |
pool_protocol=const.PROXY, protocol_port=45, |
| 275 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 276 |
|
| 277 |
@decorators.idempotent_id('42382080-7fd5-46d7-afd7-d47c880f0397') |
| 278 |
def test_TCP_SIP_pool_standalone_create(self): |
| 279 |
self._test_pool_create(listener_protocol=None, |
| 280 |
pool_protocol=const.TCP, protocol_port=46, |
| 281 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 282 |
|
| 283 |
@decorators.idempotent_id('53687dd3-e076-4e93-b917-93c76a160444') |
| 284 |
def test_TCP_SIP_pool_with_listener_create(self): |
| 285 |
self._test_pool_create(listener_protocol=const.TCP, |
| 286 |
pool_protocol=const.TCP, protocol_port=47, |
| 287 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 288 |
|
| 289 |
@decorators.idempotent_id('02d40127-d46e-4aba-8428-96f6deff3554') |
| 290 |
def test_UDP_SIP_pool_standalone_create(self): |
| 291 |
self._test_pool_create(listener_protocol=None, |
| 292 |
pool_protocol=const.UDP, protocol_port=48, |
| 293 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 294 |
|
| 295 |
@decorators.idempotent_id('5f1acd3e-305d-40d5-81e9-fe6250411d49') |
| 296 |
def test_UDP_SIP_pool_with_listener_create(self): |
| 297 |
self._test_pool_create(listener_protocol=const.UDP, |
| 298 |
pool_protocol=const.UDP, protocol_port=49, |
| 299 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 300 |
|
| 301 |
|
| 302 |
@decorators.idempotent_id('c8b84032-1c20-4d85-9db2-2fe5b9eff37a') |
| 303 |
def test_HTTP_RR_app_cookie_pool_with_listener_create(self): |
| 304 |
self._test_pool_create( |
| 305 |
listener_protocol=const.HTTP, |
| 306 |
pool_protocol=const.HTTP, protocol_port=50, |
| 307 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 308 |
session_persistence=const.SESSION_PERSISTENCE_APP_COOKIE) |
| 309 |
|
| 310 |
@decorators.idempotent_id('0296cccb-83be-425c-ac6a-828774734d5a') |
| 311 |
def test_HTTP_RR_http_cookie_pool_with_listener_create(self): |
| 312 |
self._test_pool_create( |
| 313 |
listener_protocol=const.HTTP, |
| 314 |
pool_protocol=const.HTTP, protocol_port=51, |
| 315 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 316 |
session_persistence=const.SESSION_PERSISTENCE_HTTP_COOKIE) |
| 317 |
|
| 318 |
@decorators.idempotent_id('882263e6-d50f-47b4-9083-f76c2b92eef0') |
| 319 |
def test_HTTP_RR_source_IP_pool_with_listener_create(self): |
| 320 |
self._test_pool_create( |
| 321 |
listener_protocol=const.HTTP, |
| 322 |
pool_protocol=const.HTTP, protocol_port=52, |
| 323 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 324 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 325 |
|
| 326 |
@decorators.idempotent_id('1d5eed30-86bf-4bf4-87d0-22adee3defa1') |
| 327 |
def test_UDP_RR_source_ip_pool_with_listener_create(self): |
| 328 |
self._test_pool_create( |
| 329 |
listener_protocol=const.UDP, |
| 330 |
pool_protocol=const.UDP, protocol_port=53, |
| 331 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 332 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 333 |
|
| 334 |
def _test_pool_create(self, listener_protocol, pool_protocol, |
| 335 |
protocol_port, algorithm, session_persistence=None): |
| 336 |
"""Tests pool create and basic show APIs. |
| 337 |
|
| 338 |
* Tests that users without the loadbalancer member role cannot |
| 339 |
create pools. |
| 340 |
* Create a fully populated pool. |
| 341 |
* Show pool details. |
| 342 |
* Validate the show reflects the requested values. |
| 343 |
""" |
| 344 |
if (algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 345 |
self.mem_listener_client.is_version_supported( |
| 346 |
self.api_version, '2.13')): |
| 347 |
raise testtools.TestCase.skipException( |
| 348 |
'Skipping this test as load balancing algorithm ' |
| 349 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 350 |
|
| 351 |
if listener_protocol is not None: |
| 352 |
listener_name = data_utils.rand_name("lb_member_listener1_pool") |
| 353 |
listener_kwargs = { |
| 354 |
const.NAME: listener_name, |
| 355 |
const.PROTOCOL: listener_protocol, |
| 356 |
const.PROTOCOL_PORT: protocol_port, |
| 357 |
const.LOADBALANCER_ID: self.lb_id, |
| 358 |
} |
| 359 |
listener = self.mem_listener_client.create_listener( |
| 360 |
**listener_kwargs) |
| 361 |
|
| 362 |
self.addClassResourceCleanup( |
| 363 |
self.mem_listener_client.cleanup_listener, |
| 364 |
listener[const.ID], |
| 365 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 366 |
|
| 367 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 368 |
self.lb_id, const.PROVISIONING_STATUS, |
| 369 |
const.ACTIVE, |
| 370 |
CONF.load_balancer.build_interval, |
| 371 |
CONF.load_balancer.build_timeout) |
| 372 |
|
| 373 |
pool_name = data_utils.rand_name("lb_member_pool1-create") |
| 374 |
pool_description = data_utils.arbitrary_string(size=255) |
| 375 |
pool_sp_cookie_name = 'my_cookie' |
| 376 |
pool_kwargs = { |
| 377 |
const.NAME: pool_name, |
| 378 |
const.DESCRIPTION: pool_description, |
| 379 |
const.ADMIN_STATE_UP: True, |
| 380 |
const.PROTOCOL: pool_protocol, |
| 381 |
const.LB_ALGORITHM: algorithm, |
| 382 |
} |
| 383 |
|
| 384 |
if self.mem_lb_client.is_version_supported(self.api_version, '2.5'): |
| 385 |
pool_tags = ["Hello", "World"] |
| 386 |
pool_kwargs.update({ |
| 387 |
const.TAGS: pool_tags |
| 388 |
}) |
| 389 |
|
| 390 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 391 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 392 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 393 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 394 |
} |
| 395 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 396 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 397 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 398 |
} |
| 399 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 400 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 401 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 402 |
} |
| 403 |
|
| 404 |
if listener_protocol is not None: |
| 405 |
pool_kwargs[const.LISTENER_ID] = listener[const.ID] |
| 406 |
else: |
| 407 |
pool_kwargs[const.LOADBALANCER_ID] = self.lb_id |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 412 |
'os_roles_lb_member'] |
| 413 |
self.check_create_RBAC_enforcement( |
| 414 |
'PoolClient', 'create_pool', |
| 415 |
expected_allowed, |
| 416 |
status_method=self.mem_lb_client.show_loadbalancer, |
| 417 |
obj_id=self.lb_id, **pool_kwargs) |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
try: |
| 423 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 424 |
except exceptions.NotImplemented as e: |
| 425 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 426 |
raise |
| 427 |
message = ("The configured provider driver '{driver}' " |
| 428 |
"does not support a feature required for this " |
| 429 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 430 |
if hasattr(e, 'resp_body'): |
| 431 |
message = e.resp_body.get('faultstring', message) |
| 432 |
raise testtools.TestCase.skipException(message) |
| 433 |
|
| 434 |
self.addCleanup( |
| 435 |
self.mem_pool_client.cleanup_pool, |
| 436 |
pool[const.ID], |
| 437 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 438 |
|
| 439 |
waiters.wait_for_status( |
| 440 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 441 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 442 |
CONF.load_balancer.build_interval, |
| 443 |
CONF.load_balancer.build_timeout) |
| 444 |
pool = waiters.wait_for_status( |
| 445 |
self.mem_pool_client.show_pool, |
| 446 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 447 |
const.ACTIVE, |
| 448 |
CONF.load_balancer.build_interval, |
| 449 |
CONF.load_balancer.build_timeout) |
| 450 |
if (listener_protocol is not None and |
| 451 |
not CONF.load_balancer.test_with_noop): |
| 452 |
pool = waiters.wait_for_status( |
| 453 |
self.mem_pool_client.show_pool, |
| 454 |
pool[const.ID], const.OPERATING_STATUS, |
| 455 |
const.ONLINE, |
| 456 |
CONF.load_balancer.build_interval, |
| 457 |
CONF.load_balancer.build_timeout) |
| 458 |
else: |
| 459 |
self.assertEqual(const.OFFLINE, pool[const.OPERATING_STATUS]) |
| 460 |
|
| 461 |
self.assertEqual(pool_name, pool[const.NAME]) |
| 462 |
self.assertEqual(pool_description, pool[const.DESCRIPTION]) |
| 463 |
self.assertTrue(pool[const.ADMIN_STATE_UP]) |
| 464 |
parser.parse(pool[const.CREATED_AT]) |
| 465 |
parser.parse(pool[const.UPDATED_AT]) |
| 466 |
UUID(pool[const.ID]) |
| 467 |
|
| 468 |
if (listener_protocol is not None and |
| 469 |
not CONF.load_balancer.test_with_noop): |
| 470 |
|
| 471 |
self.assertEqual(const.ONLINE, pool[const.OPERATING_STATUS]) |
| 472 |
else: |
| 473 |
|
| 474 |
self.assertEqual(const.OFFLINE, pool[const.OPERATING_STATUS]) |
| 475 |
self.assertEqual(pool_protocol, pool[const.PROTOCOL]) |
| 476 |
self.assertEqual(1, len(pool[const.LOADBALANCERS])) |
| 477 |
self.assertEqual(self.lb_id, pool[const.LOADBALANCERS][0][const.ID]) |
| 478 |
if listener_protocol is not None: |
| 479 |
self.assertEqual(1, len(pool[const.LISTENERS])) |
| 480 |
self.assertEqual(listener[const.ID], |
| 481 |
pool[const.LISTENERS][0][const.ID]) |
| 482 |
else: |
| 483 |
self.assertEmpty(pool[const.LISTENERS]) |
| 484 |
self.assertEqual(algorithm, pool[const.LB_ALGORITHM]) |
| 485 |
|
| 486 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 487 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 488 |
self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE, |
| 489 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 490 |
self.assertEqual(pool_sp_cookie_name, |
| 491 |
pool[const.SESSION_PERSISTENCE][ |
| 492 |
const.COOKIE_NAME]) |
| 493 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 494 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 495 |
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE, |
| 496 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 497 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 498 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 499 |
self.assertEqual(const.SESSION_PERSISTENCE_SOURCE_IP, |
| 500 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 501 |
|
| 502 |
if self.mem_lb_client.is_version_supported(self.api_version, '2.5'): |
| 503 |
self.assertCountEqual(pool_kwargs[const.TAGS], |
| 504 |
pool[const.TAGS]) |
| 505 |
|
| 506 |
@decorators.idempotent_id('4b4c8021-f4dd-4826-b825-7e3dc0beaba4') |
| 507 |
def test_HTTP_LC_pool_list(self): |
| 508 |
self._test_pool_list(const.HTTP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 509 |
|
| 510 |
@decorators.idempotent_id('6959a32e-fb34-4f3e-be68-8880c6450016') |
| 511 |
def test_HTTP_RR_pool_list(self): |
| 512 |
self._test_pool_list(const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 513 |
|
| 514 |
@decorators.idempotent_id('b2cb9879-c1b3-491a-bd20-773bc57625b0') |
| 515 |
def test_HTTP_SI_pool_list(self): |
| 516 |
self._test_pool_list(const.HTTP, const.LB_ALGORITHM_SOURCE_IP) |
| 517 |
|
| 518 |
@decorators.idempotent_id('871b5a7f-c8f3-4d05-9533-f9498e2465fa') |
| 519 |
def test_HTTP_SIP_pool_list(self): |
| 520 |
self._test_pool_list(const.HTTP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 521 |
|
| 522 |
@decorators.idempotent_id('8ace3b65-7183-4b55-837d-3e7f438ea079') |
| 523 |
def test_HTTPS_LC_pool_list(self): |
| 524 |
self._test_pool_list(const.HTTPS, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 525 |
|
| 526 |
@decorators.idempotent_id('7e01fa71-34fd-42e6-9db8-4b2a57cda38d') |
| 527 |
def test_HTTPS_RR_pool_list(self): |
| 528 |
self._test_pool_list(const.HTTPS, const.LB_ALGORITHM_ROUND_ROBIN) |
| 529 |
|
| 530 |
@decorators.idempotent_id('25d4b0d2-ab46-40ad-afec-1b0afa88a559') |
| 531 |
def test_HTTPS_SI_pool_list(self): |
| 532 |
self._test_pool_list(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP) |
| 533 |
|
| 534 |
@decorators.idempotent_id('250e6bf6-5017-47c9-ae12-1e64515d3bfd') |
| 535 |
def test_HTTPS_SIP_pool_list(self): |
| 536 |
self._test_pool_list(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 537 |
|
| 538 |
@decorators.idempotent_id('f3f3565e-a6b3-4541-9fb3-d9900231771b') |
| 539 |
def test_PROXY_LC_pool_list(self): |
| 540 |
self._test_pool_list(const.PROXY, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 541 |
|
| 542 |
@decorators.idempotent_id('fb267dae-b4e3-4858-a85e-72ecb1d91eff') |
| 543 |
def test_PROXY_RR_pool_list(self): |
| 544 |
self._test_pool_list(const.PROXY, const.LB_ALGORITHM_ROUND_ROBIN) |
| 545 |
|
| 546 |
@decorators.idempotent_id('42a3e3e3-ad71-418e-a262-628a213a7b03') |
| 547 |
def test_PROXY_SI_pool_list(self): |
| 548 |
self._test_pool_list(const.PROXY, const.LB_ALGORITHM_SOURCE_IP) |
| 549 |
|
| 550 |
@decorators.idempotent_id('69d3f811-6ce8-403e-bae9-745d51cb268a') |
| 551 |
def test_PROXY_SIP_pool_list(self): |
| 552 |
self._test_pool_list(const.PROXY, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 553 |
|
| 554 |
@decorators.idempotent_id('f3a74c0c-3083-44a5-9938-a245176babcd') |
| 555 |
def test_TCP_LC_pool_list(self): |
| 556 |
self._test_pool_list(const.TCP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 557 |
|
| 558 |
@decorators.idempotent_id('1a0b616f-ee77-4ac1-bb5f-300c2a10a7f2') |
| 559 |
def test_TCP_RR_pool_list(self): |
| 560 |
self._test_pool_list(const.TCP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 561 |
|
| 562 |
@decorators.idempotent_id('ec0fda75-f2d7-4fa6-ba91-c5eb9a7e9874') |
| 563 |
def test_TCP_SI_pool_list(self): |
| 564 |
self._test_pool_list(const.TCP, const.LB_ALGORITHM_SOURCE_IP) |
| 565 |
|
| 566 |
@decorators.idempotent_id('8ca217d0-705f-4a7a-87c2-752bb1ee88f1') |
| 567 |
def test_TCP_SIP_pool_list(self): |
| 568 |
self._test_pool_list(const.TCP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 569 |
|
| 570 |
@decorators.idempotent_id('ed26899d-a590-46fc-bf70-27c5a9c59cbf') |
| 571 |
def test_UDP_LC_pool_list(self): |
| 572 |
self._test_pool_list(const.UDP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 573 |
|
| 574 |
@decorators.idempotent_id('6fb6a6e3-ff65-4f2c-8876-2997d3903cfe') |
| 575 |
def test_UDP_RR_pool_list(self): |
| 576 |
self._test_pool_list(const.UDP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 577 |
|
| 578 |
@decorators.idempotent_id('0bb02800-d7c9-4916-a532-ac1ac7b945d0') |
| 579 |
def test_UDP_SI_pool_list(self): |
| 580 |
self._test_pool_list(const.UDP, const.LB_ALGORITHM_SOURCE_IP) |
| 581 |
|
| 582 |
@decorators.idempotent_id('bdc7df5f-ffdb-48c8-823e-a3b5d76868a0') |
| 583 |
def test_UDP_SIP_pool_list(self): |
| 584 |
self._test_pool_list(const.UDP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 585 |
|
| 586 |
def _test_pool_list(self, pool_protocol, algorithm): |
| 587 |
"""Tests pool list API and field filtering. |
| 588 |
|
| 589 |
* Create three pools. |
| 590 |
* Validates that other accounts cannot list the pools. |
| 591 |
* List the pools using the default sort order. |
| 592 |
* List the pools using descending sort order. |
| 593 |
* List the pools using ascending sort order. |
| 594 |
* List the pools returning one field at a time. |
| 595 |
* List the pools returning two fields. |
| 596 |
* List the pools filtering to one of the three. |
| 597 |
* List the pools filtered, one field, and sorted. |
| 598 |
""" |
| 599 |
|
| 600 |
test_ids = [] |
| 601 |
|
| 602 |
if (algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 603 |
self.mem_listener_client.is_version_supported( |
| 604 |
self.api_version, '2.13')): |
| 605 |
raise testtools.TestCase.skipException( |
| 606 |
'Skipping this test as load balancing algorithm ' |
| 607 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 608 |
|
| 609 |
lb_id = self.lb_id |
| 610 |
|
| 611 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 612 |
lb_id, |
| 613 |
const.PROVISIONING_STATUS, |
| 614 |
const.ACTIVE, |
| 615 |
CONF.load_balancer.lb_build_interval, |
| 616 |
CONF.load_balancer.lb_build_timeout) |
| 617 |
|
| 618 |
pool1_name = data_utils.rand_name("lb_member_pool2-list") |
| 619 |
pool1_desc = 'B' |
| 620 |
pool1_kwargs = { |
| 621 |
const.NAME: pool1_name, |
| 622 |
const.DESCRIPTION: pool1_desc, |
| 623 |
const.ADMIN_STATE_UP: True, |
| 624 |
const.PROTOCOL: pool_protocol, |
| 625 |
const.LB_ALGORITHM: algorithm, |
| 626 |
const.LOADBALANCER_ID: lb_id, |
| 627 |
} |
| 628 |
|
| 629 |
if self.mem_pool_client.is_version_supported( |
| 630 |
self.api_version, '2.5'): |
| 631 |
pool1_tags = ["English", "Mathematics", |
| 632 |
"Marketing", "Creativity"] |
| 633 |
pool1_kwargs.update({const.TAGS: pool1_tags}) |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
try: |
| 639 |
pool1 = self.mem_pool_client.create_pool(**pool1_kwargs) |
| 640 |
except exceptions.NotImplemented as e: |
| 641 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 642 |
raise |
| 643 |
message = ("The configured provider driver '{driver}' " |
| 644 |
"does not support a feature required for this " |
| 645 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 646 |
if hasattr(e, 'resp_body'): |
| 647 |
message = e.resp_body.get('faultstring', message) |
| 648 |
raise testtools.TestCase.skipException(message) |
| 649 |
|
| 650 |
self.addCleanup( |
| 651 |
self.mem_pool_client.cleanup_pool, |
| 652 |
pool1[const.ID], |
| 653 |
lb_client=self.mem_lb_client, lb_id=lb_id) |
| 654 |
pool1 = waiters.wait_for_status( |
| 655 |
self.mem_pool_client.show_pool, pool1[const.ID], |
| 656 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 657 |
CONF.load_balancer.build_interval, |
| 658 |
CONF.load_balancer.build_timeout) |
| 659 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 660 |
lb_id, |
| 661 |
const.PROVISIONING_STATUS, |
| 662 |
const.ACTIVE, |
| 663 |
CONF.load_balancer.build_interval, |
| 664 |
CONF.load_balancer.build_timeout) |
| 665 |
test_ids.append(pool1[const.ID]) |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
time.sleep(1) |
| 670 |
|
| 671 |
pool2_name = data_utils.rand_name("lb_member_pool1-list") |
| 672 |
pool2_desc = 'A' |
| 673 |
pool2_kwargs = { |
| 674 |
const.NAME: pool2_name, |
| 675 |
const.DESCRIPTION: pool2_desc, |
| 676 |
const.ADMIN_STATE_UP: True, |
| 677 |
const.PROTOCOL: pool_protocol, |
| 678 |
const.LB_ALGORITHM: algorithm, |
| 679 |
const.LOADBALANCER_ID: lb_id, |
| 680 |
} |
| 681 |
|
| 682 |
if self.mem_pool_client.is_version_supported( |
| 683 |
self.api_version, '2.5'): |
| 684 |
pool2_tags = ["English", "Spanish", |
| 685 |
"Soft_skills", "Creativity"] |
| 686 |
pool2_kwargs.update({const.TAGS: pool2_tags}) |
| 687 |
|
| 688 |
pool2 = self.mem_pool_client.create_pool( |
| 689 |
**pool2_kwargs) |
| 690 |
self.addCleanup( |
| 691 |
self.mem_pool_client.cleanup_pool, |
| 692 |
pool2[const.ID], |
| 693 |
lb_client=self.mem_lb_client, lb_id=lb_id) |
| 694 |
pool2 = waiters.wait_for_status( |
| 695 |
self.mem_pool_client.show_pool, pool2[const.ID], |
| 696 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 697 |
CONF.load_balancer.build_interval, |
| 698 |
CONF.load_balancer.build_timeout) |
| 699 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 700 |
lb_id, |
| 701 |
const.PROVISIONING_STATUS, |
| 702 |
const.ACTIVE, |
| 703 |
CONF.load_balancer.build_interval, |
| 704 |
CONF.load_balancer.build_timeout) |
| 705 |
test_ids.append(pool2[const.ID]) |
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
time.sleep(1) |
| 710 |
|
| 711 |
pool3_name = data_utils.rand_name("lb_member_pool3-list") |
| 712 |
pool3_desc = 'C' |
| 713 |
pool3_kwargs = { |
| 714 |
const.NAME: pool3_name, |
| 715 |
const.DESCRIPTION: pool3_desc, |
| 716 |
const.ADMIN_STATE_UP: False, |
| 717 |
const.PROTOCOL: pool_protocol, |
| 718 |
const.LB_ALGORITHM: algorithm, |
| 719 |
const.LOADBALANCER_ID: lb_id, |
| 720 |
} |
| 721 |
|
| 722 |
if self.mem_pool_client.is_version_supported( |
| 723 |
self.api_version, '2.5'): |
| 724 |
pool3_tags = ["English", "Project_management", |
| 725 |
"Communication", "Creativity"] |
| 726 |
pool3_kwargs.update({const.TAGS: pool3_tags}) |
| 727 |
|
| 728 |
pool3 = self.mem_pool_client.create_pool( |
| 729 |
**pool3_kwargs) |
| 730 |
self.addCleanup( |
| 731 |
self.mem_pool_client.cleanup_pool, |
| 732 |
pool3[const.ID], |
| 733 |
lb_client=self.mem_lb_client, lb_id=lb_id) |
| 734 |
pool3 = waiters.wait_for_status( |
| 735 |
self.mem_pool_client.show_pool, pool3[const.ID], |
| 736 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 737 |
CONF.load_balancer.build_interval, |
| 738 |
CONF.load_balancer.build_timeout) |
| 739 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 740 |
lb_id, |
| 741 |
const.PROVISIONING_STATUS, |
| 742 |
const.ACTIVE, |
| 743 |
CONF.load_balancer.build_interval, |
| 744 |
CONF.load_balancer.build_timeout) |
| 745 |
test_ids.append(pool3[const.ID]) |
| 746 |
|
| 747 |
|
| 748 |
expected_allowed = [] |
| 749 |
if CONF.load_balancer.RBAC_test_type == const.OWNERADMIN: |
| 750 |
expected_allowed = ['os_primary', 'os_roles_lb_member2'] |
| 751 |
if CONF.load_balancer.RBAC_test_type == const.KEYSTONE_DEFAULT_ROLES: |
| 752 |
expected_allowed = ['os_primary', 'os_roles_lb_member2', |
| 753 |
'os_roles_lb_observer', |
| 754 |
'os_roles_lb_global_observer'] |
| 755 |
if CONF.load_balancer.RBAC_test_type == const.ADVANCED: |
| 756 |
expected_allowed = ['os_roles_lb_observer', 'os_roles_lb_member2'] |
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
expected_allowed = [] |
| 764 |
if CONF.load_balancer.RBAC_test_type == const.OWNERADMIN: |
| 765 |
expected_allowed = ['os_admin', 'os_roles_lb_member'] |
| 766 |
if CONF.load_balancer.RBAC_test_type == const.KEYSTONE_DEFAULT_ROLES: |
| 767 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 768 |
'os_roles_lb_member'] |
| 769 |
if CONF.load_balancer.RBAC_test_type == const.ADVANCED: |
| 770 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 771 |
'os_roles_lb_member', |
| 772 |
'os_roles_lb_global_observer'] |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
expected_allowed = [] |
| 783 |
if CONF.load_balancer.RBAC_test_type == const.OWNERADMIN: |
| 784 |
expected_allowed = ['os_admin', 'os_primary', 'os_roles_lb_admin', |
| 785 |
'os_roles_lb_member', 'os_roles_lb_member2'] |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
if CONF.load_balancer.RBAC_test_type == const.KEYSTONE_DEFAULT_ROLES: |
| 791 |
expected_allowed = ['os_admin', 'os_primary', 'os_roles_lb_admin', |
| 792 |
'os_roles_lb_observer', |
| 793 |
'os_roles_lb_global_observer', |
| 794 |
'os_roles_lb_member', 'os_roles_lb_member2'] |
| 795 |
if CONF.load_balancer.RBAC_test_type == const.ADVANCED: |
| 796 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 797 |
'os_roles_lb_observer', |
| 798 |
'os_roles_lb_global_observer', |
| 799 |
'os_roles_lb_member', 'os_roles_lb_member2'] |
| 800 |
if expected_allowed: |
| 801 |
self.check_list_RBAC_enforcement( |
| 802 |
'PoolClient', 'list_pools', expected_allowed, |
| 803 |
query_params='loadbalancer_id={lb_id}'.format(lb_id=lb_id)) |
| 804 |
|
| 805 |
|
| 806 |
pools = self.mem_pool_client.list_pools( |
| 807 |
query_params='loadbalancer_id={lb_id}'.format(lb_id=lb_id)) |
| 808 |
self.assertEqual(pool1[const.DESCRIPTION], |
| 809 |
pools[0][const.DESCRIPTION]) |
| 810 |
self.assertEqual(pool2[const.DESCRIPTION], |
| 811 |
pools[1][const.DESCRIPTION]) |
| 812 |
self.assertEqual(pool3[const.DESCRIPTION], |
| 813 |
pools[2][const.DESCRIPTION]) |
| 814 |
|
| 815 |
|
| 816 |
pools = self.mem_pool_client.list_pools( |
| 817 |
query_params='loadbalancer_id={lb_id}&{sort}={descr}:{desc}' |
| 818 |
.format(lb_id=lb_id, sort=const.SORT, |
| 819 |
descr=const.DESCRIPTION, desc=const.DESC)) |
| 820 |
self.assertEqual(pool1[const.DESCRIPTION], |
| 821 |
pools[1][const.DESCRIPTION]) |
| 822 |
self.assertEqual(pool2[const.DESCRIPTION], |
| 823 |
pools[2][const.DESCRIPTION]) |
| 824 |
self.assertEqual(pool3[const.DESCRIPTION], |
| 825 |
pools[0][const.DESCRIPTION]) |
| 826 |
|
| 827 |
|
| 828 |
pools = self.mem_pool_client.list_pools( |
| 829 |
query_params='loadbalancer_id={lb_id}&{sort}={descr}:{asc}' |
| 830 |
.format(lb_id=lb_id, sort=const.SORT, |
| 831 |
descr=const.DESCRIPTION, asc=const.ASC)) |
| 832 |
self.assertEqual(pool1[const.DESCRIPTION], |
| 833 |
pools[1][const.DESCRIPTION]) |
| 834 |
self.assertEqual(pool2[const.DESCRIPTION], |
| 835 |
pools[0][const.DESCRIPTION]) |
| 836 |
self.assertEqual(pool3[const.DESCRIPTION], |
| 837 |
pools[2][const.DESCRIPTION]) |
| 838 |
|
| 839 |
|
| 840 |
for field in const.SHOW_POOL_RESPONSE_FIELDS: |
| 841 |
pools = self.mem_pool_client.list_pools( |
| 842 |
query_params='loadbalancer_id={lb_id}&{fields}={field}' |
| 843 |
.format(lb_id=lb_id, |
| 844 |
fields=const.FIELDS, field=field)) |
| 845 |
self.assertEqual(1, len(pools[0])) |
| 846 |
self.assertEqual(pool1[field], pools[0][field]) |
| 847 |
self.assertEqual(pool2[field], pools[1][field]) |
| 848 |
self.assertEqual(pool3[field], pools[2][field]) |
| 849 |
|
| 850 |
|
| 851 |
pools = self.mem_pool_client.list_pools( |
| 852 |
query_params='loadbalancer_id={lb_id}&{fields}={admin}&' |
| 853 |
'{fields}={created}'.format( |
| 854 |
lb_id=lb_id, fields=const.FIELDS, |
| 855 |
admin=const.ADMIN_STATE_UP, |
| 856 |
created=const.CREATED_AT)) |
| 857 |
self.assertEqual(2, len(pools[0])) |
| 858 |
self.assertTrue(pools[0][const.ADMIN_STATE_UP]) |
| 859 |
parser.parse(pools[0][const.CREATED_AT]) |
| 860 |
self.assertTrue(pools[1][const.ADMIN_STATE_UP]) |
| 861 |
parser.parse(pools[1][const.CREATED_AT]) |
| 862 |
self.assertFalse(pools[2][const.ADMIN_STATE_UP]) |
| 863 |
parser.parse(pools[2][const.CREATED_AT]) |
| 864 |
|
| 865 |
|
| 866 |
pools = self.mem_pool_client.list_pools( |
| 867 |
query_params='loadbalancer_id={lb_id}&{desc}={lb_desc}'.format( |
| 868 |
lb_id=lb_id, desc=const.DESCRIPTION, |
| 869 |
lb_desc=pool2[const.DESCRIPTION])) |
| 870 |
self.assertEqual(1, len(pools)) |
| 871 |
self.assertEqual(pool2[const.DESCRIPTION], |
| 872 |
pools[0][const.DESCRIPTION]) |
| 873 |
|
| 874 |
|
| 875 |
pools = self.mem_pool_client.list_pools( |
| 876 |
query_params='loadbalancer_id={lb_id}&{admin}={true}&' |
| 877 |
'{fields}={descr}&{fields}={id}&' |
| 878 |
'{sort}={descr}:{desc}'.format( |
| 879 |
lb_id=lb_id, admin=const.ADMIN_STATE_UP, |
| 880 |
true=const.ADMIN_STATE_UP_TRUE, |
| 881 |
fields=const.FIELDS, descr=const.DESCRIPTION, |
| 882 |
id=const.ID, sort=const.SORT, desc=const.DESC)) |
| 883 |
|
| 884 |
self.assertEqual(2, len(pools)) |
| 885 |
|
| 886 |
self.assertEqual(2, len(pools[0])) |
| 887 |
|
| 888 |
self.assertEqual(pool2[const.DESCRIPTION], |
| 889 |
pools[1][const.DESCRIPTION]) |
| 890 |
self.assertEqual(pool1[const.DESCRIPTION], |
| 891 |
pools[0][const.DESCRIPTION]) |
| 892 |
|
| 893 |
|
| 894 |
if self.mem_pool_client.is_version_supported( |
| 895 |
self.api_version, '2.5'): |
| 896 |
list_of_pools = [pool1, pool2, pool3] |
| 897 |
test_list = [] |
| 898 |
for pool in list_of_pools: |
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
if "English" in pool[const.TAGS] and "Creativity" in ( |
| 903 |
pool[const.TAGS]) and "Spanish" not in ( |
| 904 |
pool[const.TAGS]): |
| 905 |
test_list.append(pool[const.NAME]) |
| 906 |
|
| 907 |
|
| 908 |
self.assertEqual( |
| 909 |
test_list, [pool1[const.NAME], pool3[const.NAME]]) |
| 910 |
|
| 911 |
|
| 912 |
self.assertTrue(not any(["" in pool[const.TAGS] |
| 913 |
for pool in list_of_pools])) |
| 914 |
|
| 915 |
@decorators.idempotent_id('416c72c6-ef63-4e70-b27e-3ed95b93c02d') |
| 916 |
def test_HTTP_LC_pool_show(self): |
| 917 |
self._test_pool_show(const.HTTP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 918 |
|
| 919 |
@decorators.idempotent_id('82568809-bdb9-444b-9790-128d0c328d72') |
| 920 |
def test_HTTPS_LC_pool_show(self): |
| 921 |
self._test_pool_show(const.HTTPS, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 922 |
|
| 923 |
@decorators.idempotent_id('93e4bc67-ce12-43fb-a50d-97de47c3a63f') |
| 924 |
def test_PROXY_LC_pool_show(self): |
| 925 |
self._test_pool_show(const.PROXY, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 926 |
|
| 927 |
@decorators.idempotent_id('ee910c1e-1704-4b41-99c1-0c1f904e577d') |
| 928 |
def test_TCP_LC_pool_show(self): |
| 929 |
self._test_pool_show(const.TCP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 930 |
|
| 931 |
@decorators.idempotent_id('5f4339f6-0387-44f4-a5f9-e385d44b5ee2') |
| 932 |
def test_UDP_LC_pool_show(self): |
| 933 |
self._test_pool_show(const.UDP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 934 |
|
| 935 |
@decorators.idempotent_id('b7932438-1aea-4175-a50c-984fee1c0cad') |
| 936 |
def test_HTTP_RR_pool_show(self): |
| 937 |
self._test_pool_show(const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 938 |
|
| 939 |
@decorators.idempotent_id('a1bffe2f-ce20-4d79-a168-bc930de5edcb') |
| 940 |
def test_HTTPS_RR_pool_show(self): |
| 941 |
self._test_pool_show(const.HTTPS, const.LB_ALGORITHM_ROUND_ROBIN) |
| 942 |
|
| 943 |
@decorators.idempotent_id('4cf9fa5c-d8e0-4253-8b79-2eb59e066772') |
| 944 |
def test_PROXY_RR_pool_show(self): |
| 945 |
self._test_pool_show(const.PROXY, const.LB_ALGORITHM_ROUND_ROBIN) |
| 946 |
|
| 947 |
@decorators.idempotent_id('e6e91bb3-76b3-4ff8-ad60-d20ac1e64381') |
| 948 |
def test_TCP_RR_pool_show(self): |
| 949 |
self._test_pool_show(const.TCP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 950 |
|
| 951 |
@decorators.idempotent_id('7c4a1c90-7fc2-42ee-ad78-d7c75b5a56d2') |
| 952 |
def test_UDP_RR_pool_show(self): |
| 953 |
self._test_pool_show(const.UDP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 954 |
|
| 955 |
@decorators.idempotent_id('af1c1b10-a6ac-4f28-82ba-2c0770903a5c') |
| 956 |
def test_HTTP_SI_pool_show(self): |
| 957 |
self._test_pool_show(const.HTTP, const.LB_ALGORITHM_SOURCE_IP) |
| 958 |
|
| 959 |
@decorators.idempotent_id('64434a6d-222e-4056-bcc0-335ebe4f03ee') |
| 960 |
def test_HTTPS_SI_pool_show(self): |
| 961 |
self._test_pool_show(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP) |
| 962 |
|
| 963 |
@decorators.idempotent_id('adbb7f3b-7a37-4a8e-a2b4-c3f827dad0ba') |
| 964 |
def test_PROXY_SI_pool_show(self): |
| 965 |
self._test_pool_show(const.PROXY, const.LB_ALGORITHM_SOURCE_IP) |
| 966 |
|
| 967 |
@decorators.idempotent_id('55f62d1a-33b0-4263-84af-672a30ee52bd') |
| 968 |
def test_TCP_SI_pool_show(self): |
| 969 |
self._test_pool_show(const.TCP, const.LB_ALGORITHM_SOURCE_IP) |
| 970 |
|
| 971 |
@decorators.idempotent_id('5b961eee-183d-435c-bdf5-b83ca68c4944') |
| 972 |
def test_UDP_SI_pool_show(self): |
| 973 |
self._test_pool_show(const.UDP, const.LB_ALGORITHM_SOURCE_IP) |
| 974 |
|
| 975 |
@decorators.idempotent_id('59964666-3dfe-4bad-81e0-bc5a4809c10c') |
| 976 |
def test_HTTP_SIP_pool_show(self): |
| 977 |
self._test_pool_show(const.HTTP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 978 |
|
| 979 |
@decorators.idempotent_id('9f8f855c-cd09-4a74-b5f2-c5c13b59422e') |
| 980 |
def test_HTTPS_SIP_pool_show(self): |
| 981 |
self._test_pool_show(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 982 |
|
| 983 |
@decorators.idempotent_id('1194bd18-20bc-43e7-b588-9f78a72e0021') |
| 984 |
def test_PROXY_SIP_pool_show(self): |
| 985 |
self._test_pool_show(const.PROXY, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 986 |
|
| 987 |
@decorators.idempotent_id('6003cbe8-73a5-416a-9be0-7aa5699dc157') |
| 988 |
def test_TCP_SIP_pool_show(self): |
| 989 |
self._test_pool_show(const.TCP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 990 |
|
| 991 |
@decorators.idempotent_id('1400529e-3a0c-4bac-b6ed-669fdd723956') |
| 992 |
def test_UDP_SIP_pool_show(self): |
| 993 |
self._test_pool_show(const.UDP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 994 |
|
| 995 |
|
| 996 |
@decorators.idempotent_id('6fa12ae6-a61a-43d0-85d7-5367811c9c5a') |
| 997 |
def test_HTTP_RR_app_cookie_pool_show(self): |
| 998 |
self._test_pool_show( |
| 999 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1000 |
session_persistence=const.SESSION_PERSISTENCE_APP_COOKIE) |
| 1001 |
|
| 1002 |
@decorators.idempotent_id('4a1b6e2c-c216-4589-9ab6-2cd63217f06a') |
| 1003 |
def test_HTTP_RR_http_cookie_pool_show(self): |
| 1004 |
self._test_pool_show( |
| 1005 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1006 |
session_persistence=const.SESSION_PERSISTENCE_HTTP_COOKIE) |
| 1007 |
|
| 1008 |
@decorators.idempotent_id('373f1c80-e51e-4260-b8d8-f6aeb512f81c') |
| 1009 |
def test_HTTP_RR_source_IP_pool_show(self): |
| 1010 |
self._test_pool_show( |
| 1011 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1012 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 1013 |
|
| 1014 |
@decorators.idempotent_id('bd732c36-bdaa-4591-bf4e-28268874d22c') |
| 1015 |
def test_UDP_RR_source_IP_pool_show(self): |
| 1016 |
self._test_pool_show( |
| 1017 |
const.UDP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1018 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 1019 |
|
| 1020 |
def _test_pool_show(self, pool_protocol, algorithm, |
| 1021 |
session_persistence=None): |
| 1022 |
"""Tests pool show API. |
| 1023 |
|
| 1024 |
* Create a fully populated pool. |
| 1025 |
* Show pool details. |
| 1026 |
* Validate the show reflects the requested values. |
| 1027 |
* Validates that other accounts cannot see the pool. |
| 1028 |
""" |
| 1029 |
if (algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 1030 |
self.mem_listener_client.is_version_supported( |
| 1031 |
self.api_version, '2.13')): |
| 1032 |
raise testtools.TestCase.skipException( |
| 1033 |
'Skipping this test as load balancing algorithm ' |
| 1034 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 1035 |
|
| 1036 |
pool_name = data_utils.rand_name("lb_member_pool1-show") |
| 1037 |
pool_description = data_utils.arbitrary_string(size=255) |
| 1038 |
pool_sp_cookie_name = 'my_cookie' |
| 1039 |
pool_kwargs = { |
| 1040 |
const.NAME: pool_name, |
| 1041 |
const.DESCRIPTION: pool_description, |
| 1042 |
const.ADMIN_STATE_UP: True, |
| 1043 |
const.PROTOCOL: pool_protocol, |
| 1044 |
const.LB_ALGORITHM: algorithm, |
| 1045 |
const.LOADBALANCER_ID: self.lb_id, |
| 1046 |
} |
| 1047 |
|
| 1048 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1049 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1050 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1051 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 1052 |
} |
| 1053 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1054 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1055 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 1056 |
} |
| 1057 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1058 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1059 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 1060 |
} |
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
try: |
| 1066 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 1067 |
except exceptions.NotImplemented as e: |
| 1068 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 1069 |
raise |
| 1070 |
message = ("The configured provider driver '{driver}' " |
| 1071 |
"does not support a feature required for this " |
| 1072 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 1073 |
if hasattr(e, 'resp_body'): |
| 1074 |
message = e.resp_body.get('faultstring', message) |
| 1075 |
raise testtools.TestCase.skipException(message) |
| 1076 |
|
| 1077 |
self.addCleanup( |
| 1078 |
self.mem_pool_client.cleanup_pool, |
| 1079 |
pool[const.ID], |
| 1080 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1081 |
|
| 1082 |
waiters.wait_for_status( |
| 1083 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1084 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1085 |
CONF.load_balancer.build_interval, |
| 1086 |
CONF.load_balancer.build_timeout) |
| 1087 |
pool = waiters.wait_for_status( |
| 1088 |
self.mem_pool_client.show_pool, |
| 1089 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 1090 |
const.ACTIVE, |
| 1091 |
CONF.load_balancer.build_interval, |
| 1092 |
CONF.load_balancer.build_timeout) |
| 1093 |
|
| 1094 |
self.assertEqual(pool_name, pool[const.NAME]) |
| 1095 |
self.assertEqual(pool_description, pool[const.DESCRIPTION]) |
| 1096 |
self.assertTrue(pool[const.ADMIN_STATE_UP]) |
| 1097 |
parser.parse(pool[const.CREATED_AT]) |
| 1098 |
parser.parse(pool[const.UPDATED_AT]) |
| 1099 |
UUID(pool[const.ID]) |
| 1100 |
|
| 1101 |
self.assertEqual(const.OFFLINE, pool[const.OPERATING_STATUS]) |
| 1102 |
self.assertEqual(pool_protocol, pool[const.PROTOCOL]) |
| 1103 |
self.assertEqual(1, len(pool[const.LOADBALANCERS])) |
| 1104 |
self.assertEqual(self.lb_id, pool[const.LOADBALANCERS][0][const.ID]) |
| 1105 |
self.assertEmpty(pool[const.LISTENERS]) |
| 1106 |
self.assertEqual(algorithm, pool[const.LB_ALGORITHM]) |
| 1107 |
|
| 1108 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1109 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1110 |
self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1111 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1112 |
self.assertEqual(pool_sp_cookie_name, |
| 1113 |
pool[const.SESSION_PERSISTENCE][ |
| 1114 |
const.COOKIE_NAME]) |
| 1115 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1116 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1117 |
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE, |
| 1118 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1119 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1120 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1121 |
self.assertEqual(const.SESSION_PERSISTENCE_SOURCE_IP, |
| 1122 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
if CONF.load_balancer.RBAC_test_type == const.ADVANCED: |
| 1127 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 1128 |
'os_roles_lb_global_observer', |
| 1129 |
'os_roles_lb_member'] |
| 1130 |
else: |
| 1131 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 1132 |
'os_roles_lb_member'] |
| 1133 |
self.check_show_RBAC_enforcement( |
| 1134 |
'PoolClient', 'show_pool', |
| 1135 |
expected_allowed, pool[const.ID]) |
| 1136 |
|
| 1137 |
@decorators.idempotent_id('d73755fe-ba3a-4248-9543-8e167a5aa7f4') |
| 1138 |
def test_HTTP_LC_pool_update(self): |
| 1139 |
self._test_pool_update(const.HTTP, |
| 1140 |
const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1141 |
|
| 1142 |
@decorators.idempotent_id('ca641999-7817-4f8f-a58b-2ccd7a5dca97') |
| 1143 |
def test_HTTPS_LC_pool_update(self): |
| 1144 |
self._test_pool_update(const.HTTPS, |
| 1145 |
const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1146 |
|
| 1147 |
@decorators.idempotent_id('67a2cbab-f4fc-41c8-93e8-97ddba39c1ab') |
| 1148 |
def test_PROXY_LC_pool_update(self): |
| 1149 |
self._test_pool_update(const.PROXY, |
| 1150 |
const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1151 |
|
| 1152 |
@decorators.idempotent_id('c9f1ed23-f6d4-4d44-9d22-bdc1fbe5854d') |
| 1153 |
def test_TCP_LC_pool_update(self): |
| 1154 |
self._test_pool_update(const.TCP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1155 |
|
| 1156 |
@decorators.idempotent_id('8e6b8802-c4a7-43eb-a4e8-9f6bf7899a7d') |
| 1157 |
def test_UDP_LC_pool_update(self): |
| 1158 |
self._test_pool_update(const.UDP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1159 |
|
| 1160 |
@decorators.idempotent_id('7bd0a6bf-57b4-46a6-83ef-f9991896658a') |
| 1161 |
def test_HTTP_RR_pool_update(self): |
| 1162 |
self._test_pool_update(const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1163 |
|
| 1164 |
@decorators.idempotent_id('ac097c2e-4f79-4714-8de4-517598d37919') |
| 1165 |
def test_HTTPS_RR_pool_update(self): |
| 1166 |
self._test_pool_update(const.HTTPS, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1167 |
|
| 1168 |
@decorators.idempotent_id('4392bc21-c18e-4e25-bb7e-2c9e3777d784') |
| 1169 |
def test_PROXY_RR_pool_update(self): |
| 1170 |
self._test_pool_update(const.PROXY, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1171 |
|
| 1172 |
@decorators.idempotent_id('f6a5970d-2f27-419b-a0ee-7a420ee7b396') |
| 1173 |
def test_TCP_RR_pool_update(self): |
| 1174 |
self._test_pool_update(const.TCP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1175 |
|
| 1176 |
@decorators.idempotent_id('a1cded67-9fd6-4155-8761-ce165d518b47') |
| 1177 |
def test_UDP_RR_pool_update(self): |
| 1178 |
self._test_pool_update(const.UDP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1179 |
|
| 1180 |
@decorators.idempotent_id('42a742d2-ef9c-47fd-8585-5588bb867431') |
| 1181 |
def test_HTTP_SI_pool_update(self): |
| 1182 |
self._test_pool_update(const.HTTP, const.LB_ALGORITHM_SOURCE_IP) |
| 1183 |
|
| 1184 |
@decorators.idempotent_id('3b4e6462-4e0c-4c05-bc30-d6f86f67bb60') |
| 1185 |
def test_HTTPS_SI_pool_update(self): |
| 1186 |
self._test_pool_update(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP) |
| 1187 |
|
| 1188 |
@decorators.idempotent_id('d2cb7a0a-8268-46bc-a519-08474c42c4ca') |
| 1189 |
def test_PROXY_SI_pool_update(self): |
| 1190 |
self._test_pool_update(const.PROXY, const.LB_ALGORITHM_SOURCE_IP) |
| 1191 |
|
| 1192 |
@decorators.idempotent_id('84e63663-0bf7-45bc-a4d9-b3bbd664fd8c') |
| 1193 |
def test_TCP_SI_pool_update(self): |
| 1194 |
self._test_pool_update(const.TCP, const.LB_ALGORITHM_SOURCE_IP) |
| 1195 |
|
| 1196 |
@decorators.idempotent_id('cdb230b9-996a-4933-a7a2-a7b09465c18c') |
| 1197 |
def test_UDP_SI_pool_update(self): |
| 1198 |
self._test_pool_update(const.UDP, const.LB_ALGORITHM_SOURCE_IP) |
| 1199 |
|
| 1200 |
@decorators.idempotent_id('7c770af5-782e-453c-bd2e-41ec90b37907') |
| 1201 |
def test_HTTP_SIP_pool_update(self): |
| 1202 |
self._test_pool_update(const.HTTP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1203 |
|
| 1204 |
@decorators.idempotent_id('72cee49d-36d5-4b54-8883-8fe7be9fd0f0') |
| 1205 |
def test_HTTPS_SIP_pool_update(self): |
| 1206 |
self._test_pool_update(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1207 |
|
| 1208 |
@decorators.idempotent_id('f269293c-b6fa-4fe2-82a6-57fc8ef89260') |
| 1209 |
def test_PROXY_SIP_pool_update(self): |
| 1210 |
self._test_pool_update(const.PROXY, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1211 |
|
| 1212 |
@decorators.idempotent_id('f5445a86-247f-4075-8b71-e4e5415d0bed') |
| 1213 |
def test_TCP_SIP_pool_update(self): |
| 1214 |
self._test_pool_update(const.TCP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1215 |
|
| 1216 |
@decorators.idempotent_id('d9e1aeee-21c3-4b0f-9685-834768597607') |
| 1217 |
def test_UDP_SIP_pool_update(self): |
| 1218 |
self._test_pool_update(const.UDP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1219 |
|
| 1220 |
|
| 1221 |
@decorators.idempotent_id('8677a512-77e1-4af3-96f7-8a3d66725e08') |
| 1222 |
def test_HTTP_RR_app_cookie_pool_update(self): |
| 1223 |
self._test_pool_update( |
| 1224 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1225 |
session_persistence=const.SESSION_PERSISTENCE_APP_COOKIE) |
| 1226 |
|
| 1227 |
@decorators.idempotent_id('4d3b3a4a-a652-4dca-9a49-b14471ce5309') |
| 1228 |
def test_HTTP_RR_http_cookie_pool_update(self): |
| 1229 |
self._test_pool_update( |
| 1230 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1231 |
session_persistence=const.SESSION_PERSISTENCE_HTTP_COOKIE) |
| 1232 |
|
| 1233 |
@decorators.idempotent_id('2e7bbf67-ed32-4a3c-b5ae-1aff8b07bacc') |
| 1234 |
def test_HTTP_RR_source_IP_pool_update(self): |
| 1235 |
self._test_pool_update( |
| 1236 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1237 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 1238 |
|
| 1239 |
@decorators.idempotent_id('28b90650-a612-4b10-981f-d3dd6a366e4f') |
| 1240 |
def test_UDP_RR_source_IP_pool_update(self): |
| 1241 |
self._test_pool_update( |
| 1242 |
const.UDP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1243 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 1244 |
|
| 1245 |
def _test_pool_update(self, pool_protocol, algorithm, |
| 1246 |
session_persistence=None): |
| 1247 |
"""Tests pool update and show APIs. |
| 1248 |
|
| 1249 |
* Create a fully populated pool. |
| 1250 |
* Show pool details. |
| 1251 |
* Validate the show reflects the initial values. |
| 1252 |
* Validates that other accounts cannot update the pool. |
| 1253 |
* Update the pool details. |
| 1254 |
* Show pool details. |
| 1255 |
* Validate the show reflects the updated values. |
| 1256 |
""" |
| 1257 |
if (algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 1258 |
self.mem_listener_client.is_version_supported( |
| 1259 |
self.api_version, '2.13')): |
| 1260 |
raise testtools.TestCase.skipException( |
| 1261 |
'Skipping this test as load balancing algorithm ' |
| 1262 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 1263 |
|
| 1264 |
pool_name = data_utils.rand_name("lb_member_pool1-update") |
| 1265 |
pool_description = data_utils.arbitrary_string(size=255) |
| 1266 |
pool_sp_cookie_name = 'my_cookie' |
| 1267 |
pool_kwargs = { |
| 1268 |
const.NAME: pool_name, |
| 1269 |
const.DESCRIPTION: pool_description, |
| 1270 |
const.ADMIN_STATE_UP: False, |
| 1271 |
const.PROTOCOL: pool_protocol, |
| 1272 |
const.LB_ALGORITHM: algorithm, |
| 1273 |
const.LOADBALANCER_ID: self.lb_id, |
| 1274 |
} |
| 1275 |
|
| 1276 |
if self.mem_lb_client.is_version_supported(self.api_version, '2.5'): |
| 1277 |
pool_tags = ["Hello", "World"] |
| 1278 |
pool_kwargs.update({ |
| 1279 |
const.TAGS: pool_tags |
| 1280 |
}) |
| 1281 |
|
| 1282 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1283 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1284 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1285 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 1286 |
} |
| 1287 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1288 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1289 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 1290 |
} |
| 1291 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1292 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1293 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 1294 |
} |
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
|
| 1299 |
try: |
| 1300 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 1301 |
except exceptions.NotImplemented as e: |
| 1302 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 1303 |
raise |
| 1304 |
message = ("The configured provider driver '{driver}' " |
| 1305 |
"does not support a feature required for this " |
| 1306 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 1307 |
if hasattr(e, 'resp_body'): |
| 1308 |
message = e.resp_body.get('faultstring', message) |
| 1309 |
raise testtools.TestCase.skipException(message) |
| 1310 |
|
| 1311 |
self.addCleanup( |
| 1312 |
self.mem_pool_client.cleanup_pool, |
| 1313 |
pool[const.ID], |
| 1314 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1315 |
|
| 1316 |
waiters.wait_for_status( |
| 1317 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1318 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1319 |
CONF.load_balancer.build_interval, |
| 1320 |
CONF.load_balancer.build_timeout) |
| 1321 |
pool = waiters.wait_for_status( |
| 1322 |
self.mem_pool_client.show_pool, |
| 1323 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 1324 |
const.ACTIVE, |
| 1325 |
CONF.load_balancer.build_interval, |
| 1326 |
CONF.load_balancer.build_timeout) |
| 1327 |
|
| 1328 |
self.assertEqual(pool_name, pool[const.NAME]) |
| 1329 |
self.assertEqual(pool_description, pool[const.DESCRIPTION]) |
| 1330 |
self.assertFalse(pool[const.ADMIN_STATE_UP]) |
| 1331 |
parser.parse(pool[const.CREATED_AT]) |
| 1332 |
parser.parse(pool[const.UPDATED_AT]) |
| 1333 |
UUID(pool[const.ID]) |
| 1334 |
|
| 1335 |
self.assertEqual(const.OFFLINE, pool[const.OPERATING_STATUS]) |
| 1336 |
self.assertEqual(pool_protocol, pool[const.PROTOCOL]) |
| 1337 |
self.assertEqual(1, len(pool[const.LOADBALANCERS])) |
| 1338 |
self.assertEqual(self.lb_id, pool[const.LOADBALANCERS][0][const.ID]) |
| 1339 |
self.assertEmpty(pool[const.LISTENERS]) |
| 1340 |
self.assertEqual(algorithm, pool[const.LB_ALGORITHM]) |
| 1341 |
|
| 1342 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1343 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1344 |
self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1345 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1346 |
self.assertEqual(pool_sp_cookie_name, |
| 1347 |
pool[const.SESSION_PERSISTENCE][ |
| 1348 |
const.COOKIE_NAME]) |
| 1349 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1350 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1351 |
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE, |
| 1352 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1353 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1354 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1355 |
self.assertEqual(const.SESSION_PERSISTENCE_SOURCE_IP, |
| 1356 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 1361 |
'os_roles_lb_member'] |
| 1362 |
self.check_update_RBAC_enforcement( |
| 1363 |
'PoolClient', 'update_pool', |
| 1364 |
expected_allowed, None, None, pool[const.ID], |
| 1365 |
admin_state_up=True) |
| 1366 |
|
| 1367 |
|
| 1368 |
pool_check = self.mem_pool_client.show_pool( |
| 1369 |
pool[const.ID]) |
| 1370 |
self.assertEqual(const.ACTIVE, |
| 1371 |
pool_check[const.PROVISIONING_STATUS]) |
| 1372 |
self.assertFalse(pool_check[const.ADMIN_STATE_UP]) |
| 1373 |
|
| 1374 |
if self.mem_lb_client.is_version_supported(self.api_version, '2.5'): |
| 1375 |
self.assertCountEqual(pool_kwargs[const.TAGS], |
| 1376 |
pool[const.TAGS]) |
| 1377 |
|
| 1378 |
new_name = data_utils.rand_name("lb_member_pool1-UPDATED") |
| 1379 |
new_description = data_utils.arbitrary_string(size=255, |
| 1380 |
base_text='new') |
| 1381 |
|
| 1382 |
|
| 1383 |
pool_update_kwargs = { |
| 1384 |
const.NAME: new_name, |
| 1385 |
const.DESCRIPTION: new_description, |
| 1386 |
const.ADMIN_STATE_UP: True, |
| 1387 |
const.LB_ALGORITHM: algorithm, |
| 1388 |
} |
| 1389 |
|
| 1390 |
if self.mem_lb_client.is_version_supported(self.api_version, '2.5'): |
| 1391 |
new_tags = ["Hola", "Mundo"] |
| 1392 |
pool_update_kwargs.update({ |
| 1393 |
const.TAGS: new_tags |
| 1394 |
}) |
| 1395 |
|
| 1396 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1397 |
pool_update_kwargs[const.SESSION_PERSISTENCE] = { |
| 1398 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 1399 |
} |
| 1400 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1401 |
pool_update_kwargs[const.SESSION_PERSISTENCE] = { |
| 1402 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1403 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 1404 |
} |
| 1405 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1406 |
|
| 1407 |
|
| 1408 |
pool_update_kwargs[const.SESSION_PERSISTENCE] = { |
| 1409 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 1410 |
} |
| 1411 |
|
| 1412 |
pool = self.mem_pool_client.update_pool( |
| 1413 |
pool[const.ID], **pool_update_kwargs) |
| 1414 |
|
| 1415 |
waiters.wait_for_status( |
| 1416 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1417 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1418 |
CONF.load_balancer.build_interval, |
| 1419 |
CONF.load_balancer.build_timeout) |
| 1420 |
pool = waiters.wait_for_status( |
| 1421 |
self.mem_pool_client.show_pool, |
| 1422 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 1423 |
const.ACTIVE, |
| 1424 |
CONF.load_balancer.build_interval, |
| 1425 |
CONF.load_balancer.build_timeout) |
| 1426 |
|
| 1427 |
self.assertEqual(new_name, pool[const.NAME]) |
| 1428 |
self.assertEqual(new_description, pool[const.DESCRIPTION]) |
| 1429 |
self.assertTrue(pool[const.ADMIN_STATE_UP]) |
| 1430 |
self.assertEqual(algorithm, pool[const.LB_ALGORITHM]) |
| 1431 |
|
| 1432 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1433 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1434 |
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE, |
| 1435 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1436 |
self.assertIsNone( |
| 1437 |
pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME)) |
| 1438 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1439 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1440 |
self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1441 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1442 |
self.assertEqual(pool_sp_cookie_name, |
| 1443 |
pool[const.SESSION_PERSISTENCE][ |
| 1444 |
const.COOKIE_NAME]) |
| 1445 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1446 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1447 |
self.assertEqual(const.SESSION_PERSISTENCE_SOURCE_IP, |
| 1448 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 1449 |
self.assertIsNone( |
| 1450 |
pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME)) |
| 1451 |
|
| 1452 |
if self.mem_lb_client.is_version_supported(self.api_version, '2.5'): |
| 1453 |
self.assertCountEqual(pool_update_kwargs[const.TAGS], |
| 1454 |
pool[const.TAGS]) |
| 1455 |
|
| 1456 |
|
| 1457 |
if session_persistence is not None: |
| 1458 |
pool_update_kwargs = { |
| 1459 |
const.SESSION_PERSISTENCE: None, |
| 1460 |
} |
| 1461 |
pool = self.mem_pool_client.update_pool( |
| 1462 |
pool[const.ID], **pool_update_kwargs) |
| 1463 |
|
| 1464 |
waiters.wait_for_status( |
| 1465 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1466 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1467 |
CONF.load_balancer.build_interval, |
| 1468 |
CONF.load_balancer.build_timeout) |
| 1469 |
pool = waiters.wait_for_status( |
| 1470 |
self.mem_pool_client.show_pool, |
| 1471 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 1472 |
const.ACTIVE, |
| 1473 |
CONF.load_balancer.build_interval, |
| 1474 |
CONF.load_balancer.build_timeout) |
| 1475 |
if session_persistence is not None: |
| 1476 |
self.assertIsNone(pool.get(const.SESSION_PERSISTENCE)) |
| 1477 |
|
| 1478 |
@decorators.idempotent_id('008088c8-696e-47ba-bc18-75827fe5956b') |
| 1479 |
def test_HTTP_LC_pool_delete(self): |
| 1480 |
self._test_pool_delete(const.HTTP, |
| 1481 |
const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1482 |
|
| 1483 |
@decorators.idempotent_id('c4b2dad0-378f-4f85-a1f3-597de609b0f3') |
| 1484 |
def test_HTTPS_LC_pool_delete(self): |
| 1485 |
self._test_pool_delete(const.HTTPS, |
| 1486 |
const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1487 |
|
| 1488 |
@decorators.idempotent_id('d906c63e-6090-422c-9627-e5a971e1665c') |
| 1489 |
def test_PROXY_LC_pool_delete(self): |
| 1490 |
self._test_pool_delete(const.PROXY, |
| 1491 |
const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1492 |
|
| 1493 |
@decorators.idempotent_id('3bfd2d96-813b-48af-86e0-97361873a68a') |
| 1494 |
def test_TCP_LC_pool_delete(self): |
| 1495 |
self._test_pool_delete(const.TCP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1496 |
|
| 1497 |
@decorators.idempotent_id('ea58bede-1934-480b-86fc-665b872fc946') |
| 1498 |
def test_UDP_LC_pool_delete(self): |
| 1499 |
self._test_pool_delete(const.UDP, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1500 |
|
| 1501 |
@decorators.idempotent_id('35ed3800-7a4a-47a6-9b94-c1033fff1112') |
| 1502 |
def test_HTTP_RR_pool_delete(self): |
| 1503 |
self._test_pool_delete(const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1504 |
|
| 1505 |
@decorators.idempotent_id('c305126b-3ead-4ea8-a886-77d355c0d4a2') |
| 1506 |
def test_HTTPS_RR_pool_delete(self): |
| 1507 |
self._test_pool_delete(const.HTTPS, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1508 |
|
| 1509 |
@decorators.idempotent_id('729be91c-82c5-4b4e-9feb-08a1c786488b') |
| 1510 |
def test_PROXY_RR_pool_delete(self): |
| 1511 |
self._test_pool_delete(const.PROXY, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1512 |
|
| 1513 |
@decorators.idempotent_id('a455dea2-19ce-435c-90ae-e143fe84245e') |
| 1514 |
def test_TCP_RR_pool_delete(self): |
| 1515 |
self._test_pool_delete(const.TCP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1516 |
|
| 1517 |
@decorators.idempotent_id('63559694-6b38-4bad-9f10-3675131b28c0') |
| 1518 |
def test_UDP_RR_pool_delete(self): |
| 1519 |
self._test_pool_delete(const.UDP, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1520 |
|
| 1521 |
@decorators.idempotent_id('06bec76b-8fbf-4be8-9350-92590ac48606') |
| 1522 |
def test_HTTP_SI_pool_delete(self): |
| 1523 |
self._test_pool_delete(const.HTTP, const.LB_ALGORITHM_SOURCE_IP) |
| 1524 |
|
| 1525 |
@decorators.idempotent_id('4b21149e-64f8-4e5f-8f71-020abbd0d0eb') |
| 1526 |
def test_HTTPS_SI_pool_delete(self): |
| 1527 |
self._test_pool_delete(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP) |
| 1528 |
|
| 1529 |
@decorators.idempotent_id('277fba8f-d72b-47f0-9723-5e013f53fb7a') |
| 1530 |
def test_PROXY_SI_pool_delete(self): |
| 1531 |
self._test_pool_delete(const.PROXY, const.LB_ALGORITHM_SOURCE_IP) |
| 1532 |
|
| 1533 |
@decorators.idempotent_id('8411295f-aec0-40ab-a25d-a4677c711d98') |
| 1534 |
def test_TCP_SI_pool_delete(self): |
| 1535 |
self._test_pool_delete(const.TCP, const.LB_ALGORITHM_SOURCE_IP) |
| 1536 |
|
| 1537 |
@decorators.idempotent_id('33322f21-12cc-4f2e-b406-0c11b05a1c6e') |
| 1538 |
def test_UDP_SI_pool_delete(self): |
| 1539 |
self._test_pool_delete(const.UDP, const.LB_ALGORITHM_SOURCE_IP) |
| 1540 |
|
| 1541 |
@decorators.idempotent_id('9b40351e-1140-4b98-974c-46bd1a19763d') |
| 1542 |
def test_HTTP_SIP_pool_delete(self): |
| 1543 |
self._test_pool_delete(const.HTTP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1544 |
|
| 1545 |
@decorators.idempotent_id('391a4ed7-be97-4231-8198-5c2802bc6e30') |
| 1546 |
def test_HTTPS_SIP_pool_delete(self): |
| 1547 |
self._test_pool_delete(const.HTTPS, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1548 |
|
| 1549 |
@decorators.idempotent_id('1f6b6b9c-96c6-420b-bc51-8568c081a1ee') |
| 1550 |
def test_PROXY_SIP_pool_delete(self): |
| 1551 |
self._test_pool_delete(const.PROXY, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1552 |
|
| 1553 |
@decorators.idempotent_id('fe54f133-865a-4613-9cf0-0469c780f53e') |
| 1554 |
def test_TCP_SIP_pool_delete(self): |
| 1555 |
self._test_pool_delete(const.TCP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1556 |
|
| 1557 |
@decorators.idempotent_id('7cac0520-c7ea-49cb-8b38-0e309af2ea53') |
| 1558 |
def test_UDP_SIP_pool_delete(self): |
| 1559 |
self._test_pool_delete(const.UDP, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1560 |
|
| 1561 |
|
| 1562 |
@decorators.idempotent_id('f9aa5a8c-4e2a-4029-8581-2980f1d111cf') |
| 1563 |
def test_HTTP_RR_app_cookie_pool_delete(self): |
| 1564 |
self._test_pool_delete( |
| 1565 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1566 |
session_persistence=const.SESSION_PERSISTENCE_APP_COOKIE) |
| 1567 |
|
| 1568 |
@decorators.idempotent_id('12a31fb5-85fc-4ec8-9475-079dc06f358b') |
| 1569 |
def test_HTTP_RR_http_cookie_pool_delete(self): |
| 1570 |
self._test_pool_delete( |
| 1571 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1572 |
session_persistence=const.SESSION_PERSISTENCE_HTTP_COOKIE) |
| 1573 |
|
| 1574 |
@decorators.idempotent_id('07528fe6-12a6-4fca-8819-9980e9d3db84') |
| 1575 |
def test_HTTP_RR_source_IP_pool_delete(self): |
| 1576 |
self._test_pool_delete( |
| 1577 |
const.HTTP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1578 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 1579 |
|
| 1580 |
@decorators.idempotent_id('cc69c0d0-9191-4faf-a154-e33df880f44e') |
| 1581 |
def test_UDP_RR_source_IP_pool_delete(self): |
| 1582 |
self._test_pool_delete( |
| 1583 |
const.UDP, const.LB_ALGORITHM_ROUND_ROBIN, |
| 1584 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 1585 |
|
| 1586 |
def _test_pool_delete(self, pool_protocol, algorithm, |
| 1587 |
session_persistence=None): |
| 1588 |
"""Tests pool create and delete APIs. |
| 1589 |
|
| 1590 |
* Creates a pool. |
| 1591 |
* Validates that other accounts cannot delete the pool |
| 1592 |
* Deletes the pool. |
| 1593 |
* Validates the pool is in the DELETED state. |
| 1594 |
""" |
| 1595 |
if (algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 1596 |
self.mem_listener_client.is_version_supported( |
| 1597 |
self.api_version, '2.13')): |
| 1598 |
raise testtools.TestCase.skipException( |
| 1599 |
'Skipping this test as load balancing algorithm ' |
| 1600 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 1601 |
|
| 1602 |
pool_name = data_utils.rand_name("lb_member_pool1-delete") |
| 1603 |
pool_sp_cookie_name = 'my_cookie' |
| 1604 |
pool_kwargs = { |
| 1605 |
const.NAME: pool_name, |
| 1606 |
const.PROTOCOL: pool_protocol, |
| 1607 |
const.LB_ALGORITHM: algorithm, |
| 1608 |
const.LOADBALANCER_ID: self.lb_id, |
| 1609 |
} |
| 1610 |
|
| 1611 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 1612 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1613 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 1614 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 1615 |
} |
| 1616 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 1617 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1618 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 1619 |
} |
| 1620 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 1621 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 1622 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 1623 |
} |
| 1624 |
|
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
try: |
| 1629 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 1630 |
except exceptions.NotImplemented as e: |
| 1631 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 1632 |
raise |
| 1633 |
message = ("The configured provider driver '{driver}' " |
| 1634 |
"does not support a feature required for this " |
| 1635 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 1636 |
if hasattr(e, 'resp_body'): |
| 1637 |
message = e.resp_body.get('faultstring', message) |
| 1638 |
raise testtools.TestCase.skipException(message) |
| 1639 |
|
| 1640 |
self.addCleanup( |
| 1641 |
self.mem_pool_client.cleanup_pool, |
| 1642 |
pool[const.ID], |
| 1643 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1644 |
|
| 1645 |
waiters.wait_for_status( |
| 1646 |
self.mem_lb_client.show_loadbalancer, |
| 1647 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1648 |
const.ACTIVE, |
| 1649 |
CONF.load_balancer.build_interval, |
| 1650 |
CONF.load_balancer.build_timeout) |
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
expected_allowed = ['os_admin', 'os_roles_lb_admin', |
| 1655 |
'os_roles_lb_member'] |
| 1656 |
self.check_delete_RBAC_enforcement( |
| 1657 |
'PoolClient', 'delete_pool', |
| 1658 |
expected_allowed, None, None, pool[const.ID]) |
| 1659 |
|
| 1660 |
self.mem_pool_client.delete_pool(pool[const.ID]) |
| 1661 |
|
| 1662 |
waiters.wait_for_deleted_status_or_not_found( |
| 1663 |
self.mem_pool_client.show_pool, pool[const.ID], |
| 1664 |
const.PROVISIONING_STATUS, |
| 1665 |
CONF.load_balancer.check_interval, |
| 1666 |
CONF.load_balancer.check_timeout) |
| 1667 |
|
| 1668 |
waiters.wait_for_status( |
| 1669 |
self.mem_lb_client.show_loadbalancer, |
| 1670 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1671 |
const.ACTIVE, |
| 1672 |
CONF.load_balancer.check_interval, |
| 1673 |
CONF.load_balancer.check_timeout) |