| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
import datetime |
| 16 |
import ipaddress |
| 17 |
import shlex |
| 18 |
import socket |
| 19 |
import testtools |
| 20 |
import time |
| 21 |
|
| 22 |
from oslo_log import log as logging |
| 23 |
from oslo_utils import uuidutils |
| 24 |
from tempest import config |
| 25 |
from tempest.lib.common.utils import data_utils |
| 26 |
from tempest.lib import decorators |
| 27 |
from tempest.lib import exceptions |
| 28 |
|
| 29 |
from octavia_tempest_plugin.common import constants as const |
| 30 |
from octavia_tempest_plugin.common.decorators import retry_on_port_in_use |
| 31 |
from octavia_tempest_plugin.tests import test_base |
| 32 |
from octavia_tempest_plugin.tests import waiters |
| 33 |
|
| 34 |
CONF = config.CONF |
| 35 |
LOG = logging.getLogger(__name__) |
| 36 |
|
| 37 |
|
| 38 |
class TrafficOperationsScenarioTest(test_base.LoadBalancerBaseTestWithCompute): |
| 39 |
|
| 40 |
@classmethod |
| 41 |
def skip_checks(cls): |
| 42 |
super().skip_checks() |
| 43 |
|
| 44 |
if not CONF.validation.run_validation: |
| 45 |
raise cls.skipException('Traffic tests will not work without ' |
| 46 |
'run_validation enabled.') |
| 47 |
|
| 48 |
if CONF.load_balancer.test_with_noop: |
| 49 |
raise cls.skipException('Traffic tests will not work in noop ' |
| 50 |
'mode.') |
| 51 |
|
| 52 |
@classmethod |
| 53 |
def resource_setup(cls): |
| 54 |
"""Setup resources needed by the tests.""" |
| 55 |
super(TrafficOperationsScenarioTest, cls).resource_setup() |
| 56 |
|
| 57 |
lb_name = data_utils.rand_name("lb_member_lb1_operations") |
| 58 |
lb_kwargs = {const.PROVIDER: CONF.load_balancer.provider, |
| 59 |
const.NAME: lb_name} |
| 60 |
|
| 61 |
|
| 62 |
ip_version = 4 |
| 63 |
cls._setup_lb_network_kwargs(lb_kwargs, ip_version) |
| 64 |
|
| 65 |
lb = cls.mem_lb_client.create_loadbalancer(**lb_kwargs) |
| 66 |
cls.lb_id = lb[const.ID] |
| 67 |
cls.addClassResourceCleanup( |
| 68 |
cls.mem_lb_client.cleanup_loadbalancer, |
| 69 |
cls.lb_id, cascade=True) |
| 70 |
|
| 71 |
waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer, |
| 72 |
cls.lb_id, const.PROVISIONING_STATUS, |
| 73 |
const.ACTIVE, |
| 74 |
CONF.load_balancer.lb_build_interval, |
| 75 |
CONF.load_balancer.lb_build_timeout) |
| 76 |
|
| 77 |
if CONF.validation.connect_method == 'floating': |
| 78 |
port_id = lb[const.VIP_PORT_ID] |
| 79 |
result = cls.lb_mem_float_ip_client.create_floatingip( |
| 80 |
floating_network_id=CONF.network.public_network_id, |
| 81 |
port_id=port_id) |
| 82 |
floating_ip = result['floatingip'] |
| 83 |
LOG.info('lb1_floating_ip: %s', floating_ip) |
| 84 |
cls.addClassResourceCleanup( |
| 85 |
waiters.wait_for_not_found, |
| 86 |
cls.lb_mem_float_ip_client.delete_floatingip, |
| 87 |
cls.lb_mem_float_ip_client.show_floatingip, |
| 88 |
floatingip_id=floating_ip['id']) |
| 89 |
cls.lb_vip_address = floating_ip['floating_ip_address'] |
| 90 |
else: |
| 91 |
cls.lb_vip_address = lb[const.VIP_ADDRESS] |
| 92 |
|
| 93 |
@classmethod |
| 94 |
def _listener_pool_create(cls, protocol, protocol_port, |
| 95 |
pool_algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 96 |
insert_headers_dic=None): |
| 97 |
if (protocol == const.UDP and |
| 98 |
not cls.mem_listener_client.is_version_supported( |
| 99 |
cls.api_version, '2.1')): |
| 100 |
return |
| 101 |
if (pool_algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 102 |
cls.mem_listener_client.is_version_supported( |
| 103 |
cls.api_version, '2.13')): |
| 104 |
raise testtools.TestCase.skipException( |
| 105 |
'Skipping this test as load balancing algorithm ' |
| 106 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 107 |
|
| 108 |
listener_name = data_utils.rand_name("lb_member_listener1_operations") |
| 109 |
listener_kwargs = { |
| 110 |
const.NAME: listener_name, |
| 111 |
const.PROTOCOL: protocol, |
| 112 |
const.PROTOCOL_PORT: protocol_port, |
| 113 |
const.LOADBALANCER_ID: cls.lb_id, |
| 114 |
|
| 115 |
|
| 116 |
const.CONNECTION_LIMIT: 200, |
| 117 |
} |
| 118 |
|
| 119 |
if insert_headers_dic: |
| 120 |
listener_kwargs[const.INSERT_HEADERS] = insert_headers_dic |
| 121 |
|
| 122 |
listener = cls.mem_listener_client.create_listener(**listener_kwargs) |
| 123 |
|
| 124 |
cls.addClassResourceCleanup( |
| 125 |
cls.mem_listener_client.cleanup_listener, |
| 126 |
listener[const.ID], |
| 127 |
lb_client=cls.mem_lb_client, lb_id=cls.lb_id) |
| 128 |
|
| 129 |
waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer, |
| 130 |
cls.lb_id, const.PROVISIONING_STATUS, |
| 131 |
const.ACTIVE, |
| 132 |
CONF.load_balancer.build_interval, |
| 133 |
CONF.load_balancer.build_timeout) |
| 134 |
|
| 135 |
pool_name = data_utils.rand_name("lb_member_pool1_operations") |
| 136 |
pool_kwargs = { |
| 137 |
const.NAME: pool_name, |
| 138 |
const.PROTOCOL: protocol, |
| 139 |
const.LB_ALGORITHM: pool_algorithm, |
| 140 |
const.LISTENER_ID: listener[const.ID], |
| 141 |
} |
| 142 |
pool = cls.mem_pool_client.create_pool(**pool_kwargs) |
| 143 |
|
| 144 |
cls.addClassResourceCleanup( |
| 145 |
cls.mem_pool_client.cleanup_pool, |
| 146 |
pool[const.ID], |
| 147 |
lb_client=cls.mem_lb_client, lb_id=cls.lb_id) |
| 148 |
|
| 149 |
waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer, |
| 150 |
cls.lb_id, const.PROVISIONING_STATUS, |
| 151 |
const.ACTIVE, |
| 152 |
CONF.load_balancer.build_interval, |
| 153 |
CONF.load_balancer.build_timeout) |
| 154 |
|
| 155 |
return listener[const.ID], pool[const.ID] |
| 156 |
|
| 157 |
def _test_basic_traffic( |
| 158 |
self, protocol, protocol_port, pool_id, persistent=True, |
| 159 |
traffic_member_count=2, source_port=None, delay=None): |
| 160 |
"""Tests sending traffic through a loadbalancer |
| 161 |
|
| 162 |
* Set up members on a loadbalancer. |
| 163 |
* Test traffic to ensure it is balanced properly. |
| 164 |
""" |
| 165 |
|
| 166 |
member1_name = data_utils.rand_name("lb_member_member1-traffic") |
| 167 |
member1_kwargs = { |
| 168 |
const.POOL_ID: pool_id, |
| 169 |
const.NAME: member1_name, |
| 170 |
const.ADMIN_STATE_UP: True, |
| 171 |
const.ADDRESS: self.webserver1_ip, |
| 172 |
const.PROTOCOL_PORT: 80, |
| 173 |
} |
| 174 |
if self.lb_member_1_subnet: |
| 175 |
member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 176 |
|
| 177 |
member1 = self.mem_member_client.create_member(**member1_kwargs) |
| 178 |
self.addCleanup( |
| 179 |
self.mem_member_client.cleanup_member, |
| 180 |
member1[const.ID], pool_id=pool_id, |
| 181 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 182 |
waiters.wait_for_status( |
| 183 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 184 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 185 |
CONF.load_balancer.check_interval, |
| 186 |
CONF.load_balancer.check_timeout) |
| 187 |
|
| 188 |
|
| 189 |
member2_name = data_utils.rand_name("lb_member_member2-traffic") |
| 190 |
member2_kwargs = { |
| 191 |
const.POOL_ID: pool_id, |
| 192 |
const.NAME: member2_name, |
| 193 |
const.ADMIN_STATE_UP: True, |
| 194 |
const.ADDRESS: self.webserver2_ip, |
| 195 |
const.PROTOCOL_PORT: 80, |
| 196 |
} |
| 197 |
if self.lb_member_2_subnet: |
| 198 |
member2_kwargs[const.SUBNET_ID] = self.lb_member_2_subnet[const.ID] |
| 199 |
|
| 200 |
member2 = self.mem_member_client.create_member(**member2_kwargs) |
| 201 |
self.addCleanup( |
| 202 |
self.mem_member_client.cleanup_member, |
| 203 |
member2[const.ID], pool_id=pool_id, |
| 204 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 205 |
waiters.wait_for_status( |
| 206 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 207 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 208 |
CONF.load_balancer.check_interval, |
| 209 |
CONF.load_balancer.check_timeout) |
| 210 |
|
| 211 |
|
| 212 |
self.check_members_balanced( |
| 213 |
self.lb_vip_address, protocol_port=protocol_port, |
| 214 |
persistent=persistent, protocol=protocol, |
| 215 |
traffic_member_count=traffic_member_count, source_port=source_port, |
| 216 |
delay=delay) |
| 217 |
|
| 218 |
def _pool_add_healthmonitor(self, pool_id, protocol): |
| 219 |
hm_name = data_utils.rand_name("lb_member_hm1-hm-traffic") |
| 220 |
if protocol != const.HTTP: |
| 221 |
if protocol == const.UDP: |
| 222 |
hm_type = const.HEALTH_MONITOR_UDP_CONNECT |
| 223 |
elif protocol == const.TCP: |
| 224 |
hm_type = const.HEALTH_MONITOR_TCP |
| 225 |
|
| 226 |
hm_kwargs = { |
| 227 |
const.POOL_ID: pool_id, |
| 228 |
const.NAME: hm_name, |
| 229 |
const.TYPE: hm_type, |
| 230 |
const.DELAY: 3, |
| 231 |
const.TIMEOUT: 2, |
| 232 |
const.MAX_RETRIES: 2, |
| 233 |
const.MAX_RETRIES_DOWN: 2, |
| 234 |
const.ADMIN_STATE_UP: True, |
| 235 |
} |
| 236 |
else: |
| 237 |
hm_kwargs = { |
| 238 |
const.POOL_ID: pool_id, |
| 239 |
const.NAME: hm_name, |
| 240 |
const.TYPE: const.HEALTH_MONITOR_HTTP, |
| 241 |
const.DELAY: 2, |
| 242 |
const.TIMEOUT: 2, |
| 243 |
const.MAX_RETRIES: 2, |
| 244 |
const.MAX_RETRIES_DOWN: 2, |
| 245 |
const.HTTP_METHOD: const.GET, |
| 246 |
const.URL_PATH: '/', |
| 247 |
const.EXPECTED_CODES: '200', |
| 248 |
const.ADMIN_STATE_UP: True, |
| 249 |
} |
| 250 |
hm = self.mem_healthmonitor_client.create_healthmonitor(**hm_kwargs) |
| 251 |
self.addCleanup( |
| 252 |
self.mem_healthmonitor_client.cleanup_healthmonitor, |
| 253 |
hm[const.ID], lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 254 |
waiters.wait_for_status( |
| 255 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 256 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 257 |
CONF.load_balancer.build_interval, |
| 258 |
CONF.load_balancer.build_timeout) |
| 259 |
hm = waiters.wait_for_status( |
| 260 |
self.mem_healthmonitor_client.show_healthmonitor, |
| 261 |
hm[const.ID], const.PROVISIONING_STATUS, |
| 262 |
const.ACTIVE, |
| 263 |
CONF.load_balancer.build_interval, |
| 264 |
CONF.load_balancer.build_timeout) |
| 265 |
return hm |
| 266 |
|
| 267 |
@decorators.attr(type=['smoke', 'slow']) |
| 268 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 269 |
'Traffic tests will not work in noop mode.') |
| 270 |
@decorators.idempotent_id('6751135d-e15a-4e22-89f4-bfcc3408d424') |
| 271 |
def test_basic_http_traffic(self): |
| 272 |
pool_id = self._listener_pool_create(const.HTTP, 80)[1] |
| 273 |
self._test_basic_traffic(const.HTTP, 80, pool_id) |
| 274 |
|
| 275 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 276 |
'Traffic tests will not work in noop mode.') |
| 277 |
@decorators.idempotent_id('332a08e0-eff1-4c19-b46c-bf87148a6d84') |
| 278 |
def test_basic_tcp_traffic(self): |
| 279 |
pool_id = self._listener_pool_create(const.TCP, 81)[1] |
| 280 |
self._test_basic_traffic(const.TCP, 81, pool_id, |
| 281 |
persistent=False) |
| 282 |
|
| 283 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 284 |
'Traffic tests will not work in noop mode.') |
| 285 |
@decorators.idempotent_id('1e459663-2315-4067-bb47-c8a72f4928f0') |
| 286 |
def test_basic_udp_traffic(self): |
| 287 |
if not self.mem_listener_client.is_version_supported( |
| 288 |
self.api_version, '2.1'): |
| 289 |
raise self.skipException('UDP listener support is only available ' |
| 290 |
'in Octavia API version 2.1 or newer') |
| 291 |
pool_id = self._listener_pool_create(const.UDP, 8080)[1] |
| 292 |
self._test_basic_traffic(const.UDP, 8080, pool_id) |
| 293 |
|
| 294 |
def _test_healthmonitor_traffic(self, protocol, protocol_port, |
| 295 |
pool_id, persistent=True): |
| 296 |
"""Tests traffic is correctly routed based on healthmonitor status |
| 297 |
|
| 298 |
* Create three members: |
| 299 |
* One should be working, and ONLINE with a healthmonitor (passing) |
| 300 |
* One should be working, and ERROR with a healthmonitor (failing) |
| 301 |
* One should be disabled, and OFFLINE with a healthmonitor |
| 302 |
* Verify members are in their correct respective operating statuses. |
| 303 |
* Verify that traffic is balanced evenly between the working members. |
| 304 |
* Create a fully populated healthmonitor. |
| 305 |
* Verify members are in their correct respective operating statuses. |
| 306 |
* Verify that traffic is balanced *unevenly*. |
| 307 |
* Delete the healthmonitor. |
| 308 |
* Verify members are in their correct respective operating statuses. |
| 309 |
* Verify that traffic is balanced evenly between the working members. |
| 310 |
""" |
| 311 |
|
| 312 |
member1_name = data_utils.rand_name("lb_member_member1-hm-traffic") |
| 313 |
member1_kwargs = { |
| 314 |
const.POOL_ID: pool_id, |
| 315 |
const.NAME: member1_name, |
| 316 |
const.ADMIN_STATE_UP: True, |
| 317 |
const.ADDRESS: self.webserver1_ip, |
| 318 |
const.PROTOCOL_PORT: 80, |
| 319 |
} |
| 320 |
if self.lb_member_1_subnet: |
| 321 |
member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 322 |
|
| 323 |
member1 = self.mem_member_client.create_member(**member1_kwargs) |
| 324 |
member1_id = member1[const.ID] |
| 325 |
self.addCleanup( |
| 326 |
self.mem_member_client.cleanup_member, |
| 327 |
member1_id, pool_id=pool_id, |
| 328 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 329 |
waiters.wait_for_status( |
| 330 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 331 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 332 |
CONF.load_balancer.check_interval, |
| 333 |
CONF.load_balancer.check_timeout) |
| 334 |
|
| 335 |
|
| 336 |
member2_name = data_utils.rand_name("lb_member_member2-hm-traffic") |
| 337 |
member2_kwargs = { |
| 338 |
const.POOL_ID: pool_id, |
| 339 |
const.NAME: member2_name, |
| 340 |
const.ADMIN_STATE_UP: True, |
| 341 |
const.ADDRESS: self.webserver2_ip, |
| 342 |
const.PROTOCOL_PORT: 80, |
| 343 |
const.MONITOR_PORT: 9999, |
| 344 |
} |
| 345 |
if self.lb_member_2_subnet: |
| 346 |
member2_kwargs[const.SUBNET_ID] = self.lb_member_2_subnet[const.ID] |
| 347 |
|
| 348 |
member2 = self.mem_member_client.create_member(**member2_kwargs) |
| 349 |
member2_id = member2[const.ID] |
| 350 |
self.addCleanup( |
| 351 |
self.mem_member_client.cleanup_member, |
| 352 |
member2_id, pool_id=pool_id, |
| 353 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 354 |
waiters.wait_for_status( |
| 355 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 356 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 357 |
CONF.load_balancer.check_interval, |
| 358 |
CONF.load_balancer.check_timeout) |
| 359 |
|
| 360 |
|
| 361 |
member3_name = data_utils.rand_name("lb_member_member3-hm-traffic") |
| 362 |
member3_kwargs = { |
| 363 |
const.POOL_ID: pool_id, |
| 364 |
const.NAME: member3_name, |
| 365 |
const.ADMIN_STATE_UP: False, |
| 366 |
const.ADDRESS: '192.0.2.1', |
| 367 |
const.PROTOCOL_PORT: 80, |
| 368 |
} |
| 369 |
|
| 370 |
member3 = self.mem_member_client.create_member(**member3_kwargs) |
| 371 |
member3_id = member3[const.ID] |
| 372 |
self.addCleanup( |
| 373 |
self.mem_member_client.cleanup_member, |
| 374 |
member3_id, pool_id=pool_id, |
| 375 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 376 |
waiters.wait_for_status( |
| 377 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 378 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 379 |
CONF.load_balancer.check_interval, |
| 380 |
CONF.load_balancer.check_timeout) |
| 381 |
|
| 382 |
|
| 383 |
waiters.wait_for_status( |
| 384 |
self.mem_member_client.show_member, |
| 385 |
member1_id, const.OPERATING_STATUS, |
| 386 |
const.NO_MONITOR, |
| 387 |
CONF.load_balancer.build_interval, |
| 388 |
CONF.load_balancer.build_timeout, |
| 389 |
pool_id=pool_id) |
| 390 |
waiters.wait_for_status( |
| 391 |
self.mem_member_client.show_member, |
| 392 |
member2_id, const.OPERATING_STATUS, |
| 393 |
const.NO_MONITOR, |
| 394 |
CONF.load_balancer.build_interval, |
| 395 |
CONF.load_balancer.build_timeout, |
| 396 |
pool_id=pool_id) |
| 397 |
waiters.wait_for_status( |
| 398 |
self.mem_member_client.show_member, |
| 399 |
member3_id, const.OPERATING_STATUS, |
| 400 |
const.OFFLINE, |
| 401 |
CONF.load_balancer.build_interval, |
| 402 |
CONF.load_balancer.build_timeout, |
| 403 |
pool_id=pool_id) |
| 404 |
|
| 405 |
|
| 406 |
self.check_members_balanced(self.lb_vip_address, |
| 407 |
protocol_port=protocol_port, |
| 408 |
protocol=protocol, persistent=persistent) |
| 409 |
|
| 410 |
|
| 411 |
hm = self._pool_add_healthmonitor(pool_id, protocol) |
| 412 |
|
| 413 |
|
| 414 |
waiters.wait_for_status( |
| 415 |
self.mem_member_client.show_member, |
| 416 |
member1_id, const.OPERATING_STATUS, |
| 417 |
const.ONLINE, |
| 418 |
CONF.load_balancer.build_interval, |
| 419 |
CONF.load_balancer.build_timeout, |
| 420 |
error_ok=True, |
| 421 |
pool_id=pool_id) |
| 422 |
waiters.wait_for_status( |
| 423 |
self.mem_member_client.show_member, |
| 424 |
member2_id, const.OPERATING_STATUS, |
| 425 |
const.ERROR, |
| 426 |
CONF.load_balancer.build_interval, |
| 427 |
CONF.load_balancer.build_timeout, |
| 428 |
pool_id=pool_id) |
| 429 |
waiters.wait_for_status( |
| 430 |
self.mem_member_client.show_member, |
| 431 |
member3_id, const.OPERATING_STATUS, |
| 432 |
const.OFFLINE, |
| 433 |
CONF.load_balancer.build_interval, |
| 434 |
CONF.load_balancer.build_timeout, |
| 435 |
pool_id=pool_id) |
| 436 |
|
| 437 |
|
| 438 |
self.check_members_balanced(self.lb_vip_address, |
| 439 |
protocol_port=protocol_port, |
| 440 |
protocol=protocol, |
| 441 |
traffic_member_count=1, |
| 442 |
persistent=persistent) |
| 443 |
|
| 444 |
|
| 445 |
self.mem_healthmonitor_client.delete_healthmonitor(hm[const.ID]) |
| 446 |
|
| 447 |
waiters.wait_for_deleted_status_or_not_found( |
| 448 |
self.mem_healthmonitor_client.show_healthmonitor, hm[const.ID], |
| 449 |
const.PROVISIONING_STATUS, |
| 450 |
CONF.load_balancer.check_interval, |
| 451 |
CONF.load_balancer.check_timeout) |
| 452 |
|
| 453 |
|
| 454 |
waiters.wait_for_status( |
| 455 |
self.mem_member_client.show_member, |
| 456 |
member1_id, const.OPERATING_STATUS, |
| 457 |
const.NO_MONITOR, |
| 458 |
CONF.load_balancer.build_interval, |
| 459 |
CONF.load_balancer.build_timeout, |
| 460 |
pool_id=pool_id) |
| 461 |
waiters.wait_for_status( |
| 462 |
self.mem_member_client.show_member, |
| 463 |
member2_id, const.OPERATING_STATUS, |
| 464 |
const.NO_MONITOR, |
| 465 |
CONF.load_balancer.build_interval, |
| 466 |
CONF.load_balancer.build_timeout, |
| 467 |
pool_id=pool_id) |
| 468 |
waiters.wait_for_status( |
| 469 |
self.mem_member_client.show_member, |
| 470 |
member3_id, const.OPERATING_STATUS, |
| 471 |
const.OFFLINE, |
| 472 |
CONF.load_balancer.build_interval, |
| 473 |
CONF.load_balancer.build_timeout, |
| 474 |
pool_id=pool_id) |
| 475 |
|
| 476 |
|
| 477 |
self.check_members_balanced(self.lb_vip_address, |
| 478 |
protocol_port=protocol_port, |
| 479 |
protocol=protocol, persistent=persistent) |
| 480 |
|
| 481 |
@decorators.idempotent_id('a16f8eb4-a77c-4b0e-8b1b-91c237039713') |
| 482 |
def test_healthmonitor_http_traffic(self): |
| 483 |
pool_id = self._listener_pool_create(const.HTTP, 82)[1] |
| 484 |
self._test_healthmonitor_traffic(const.HTTP, 82, pool_id) |
| 485 |
|
| 486 |
@decorators.idempotent_id('22f00c34-343b-4aa9-90be-4567ecf85772') |
| 487 |
def test_healthmonitor_tcp_traffic(self): |
| 488 |
pool_id = self._listener_pool_create(const.TCP, 83)[1] |
| 489 |
self._test_healthmonitor_traffic(const.TCP, 83, pool_id, |
| 490 |
persistent=False) |
| 491 |
|
| 492 |
@decorators.idempotent_id('80b86513-1a76-4e42-91c9-cb23c879e536') |
| 493 |
def test_healthmonitor_udp_traffic(self): |
| 494 |
if not self.mem_listener_client.is_version_supported( |
| 495 |
self.api_version, '2.1'): |
| 496 |
raise self.skipException('UDP listener support is only available ' |
| 497 |
'in Octavia API version 2.1 or newer') |
| 498 |
|
| 499 |
pool_id = self._listener_pool_create(const.UDP, 8081)[1] |
| 500 |
self._test_healthmonitor_traffic(const.UDP, 8081, pool_id) |
| 501 |
|
| 502 |
@decorators.idempotent_id('3558186d-6dcd-4d9d-b7f7-adc190b66149') |
| 503 |
def test_http_l7policies_and_l7rules(self): |
| 504 |
"""Tests sending traffic through a loadbalancer with l7rules |
| 505 |
|
| 506 |
* Create an extra pool. |
| 507 |
* Put one member on the default pool, and one on the second pool. |
| 508 |
* Create a policy/rule to redirect to the second pool. |
| 509 |
* Create a policy/rule to redirect to the identity URI. |
| 510 |
* Create a policy/rule to reject connections. |
| 511 |
* Test traffic to ensure it goes to the correct place. |
| 512 |
""" |
| 513 |
LISTENER_PORT = 84 |
| 514 |
listener_id, pool_id = self._listener_pool_create(const.HTTP, |
| 515 |
LISTENER_PORT) |
| 516 |
protocol = const.HTTP |
| 517 |
|
| 518 |
|
| 519 |
pool_name = data_utils.rand_name("lb_member_pool2_l7redirect") |
| 520 |
pool_kwargs = { |
| 521 |
const.NAME: pool_name, |
| 522 |
const.PROTOCOL: protocol, |
| 523 |
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN, |
| 524 |
const.LOADBALANCER_ID: self.lb_id, |
| 525 |
} |
| 526 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 527 |
pool2_id = pool[const.ID] |
| 528 |
self.addCleanup( |
| 529 |
self.mem_pool_client.cleanup_pool, |
| 530 |
pool2_id, |
| 531 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 532 |
|
| 533 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 534 |
self.lb_id, const.PROVISIONING_STATUS, |
| 535 |
const.ACTIVE, |
| 536 |
CONF.load_balancer.build_interval, |
| 537 |
CONF.load_balancer.build_timeout) |
| 538 |
|
| 539 |
|
| 540 |
member1_name = data_utils.rand_name("lb_member_member1-l7redirect") |
| 541 |
member1_kwargs = { |
| 542 |
const.POOL_ID: pool_id, |
| 543 |
const.NAME: member1_name, |
| 544 |
const.ADMIN_STATE_UP: True, |
| 545 |
const.ADDRESS: self.webserver1_ip, |
| 546 |
const.PROTOCOL_PORT: 80, |
| 547 |
} |
| 548 |
if self.lb_member_1_subnet: |
| 549 |
member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 550 |
|
| 551 |
member1 = self.mem_member_client.create_member( |
| 552 |
**member1_kwargs) |
| 553 |
self.addCleanup( |
| 554 |
self.mem_member_client.cleanup_member, |
| 555 |
member1[const.ID], pool_id=pool_id, |
| 556 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 557 |
waiters.wait_for_status( |
| 558 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 559 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 560 |
CONF.load_balancer.check_interval, |
| 561 |
CONF.load_balancer.check_timeout) |
| 562 |
|
| 563 |
|
| 564 |
member2_name = data_utils.rand_name("lb_member_member2-l7redirect") |
| 565 |
member2_kwargs = { |
| 566 |
const.POOL_ID: pool2_id, |
| 567 |
const.NAME: member2_name, |
| 568 |
const.ADMIN_STATE_UP: True, |
| 569 |
const.ADDRESS: self.webserver2_ip, |
| 570 |
const.PROTOCOL_PORT: 80, |
| 571 |
} |
| 572 |
if self.lb_member_2_subnet: |
| 573 |
member2_kwargs[const.SUBNET_ID] = self.lb_member_2_subnet[const.ID] |
| 574 |
|
| 575 |
member2 = self.mem_member_client.create_member( |
| 576 |
**member2_kwargs) |
| 577 |
self.addCleanup( |
| 578 |
self.mem_member_client.cleanup_member, |
| 579 |
member2[const.ID], pool_id=pool_id, |
| 580 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 581 |
waiters.wait_for_status( |
| 582 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 583 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 584 |
CONF.load_balancer.check_interval, |
| 585 |
CONF.load_balancer.check_timeout) |
| 586 |
|
| 587 |
|
| 588 |
l7policy1_name = data_utils.rand_name("lb_member_l7policy1-l7redirect") |
| 589 |
l7policy1_description = data_utils.arbitrary_string(size=255) |
| 590 |
l7policy1_kwargs = { |
| 591 |
const.LISTENER_ID: listener_id, |
| 592 |
const.NAME: l7policy1_name, |
| 593 |
const.DESCRIPTION: l7policy1_description, |
| 594 |
const.ADMIN_STATE_UP: True, |
| 595 |
const.POSITION: 1, |
| 596 |
const.ACTION: const.REDIRECT_TO_POOL, |
| 597 |
const.REDIRECT_POOL_ID: pool2_id, |
| 598 |
} |
| 599 |
l7policy1 = self.mem_l7policy_client.create_l7policy( |
| 600 |
**l7policy1_kwargs) |
| 601 |
self.addCleanup( |
| 602 |
self.mem_l7policy_client.cleanup_l7policy, |
| 603 |
l7policy1[const.ID], |
| 604 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 605 |
waiters.wait_for_status( |
| 606 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 607 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 608 |
CONF.load_balancer.build_interval, |
| 609 |
CONF.load_balancer.build_timeout) |
| 610 |
|
| 611 |
|
| 612 |
l7rule1_kwargs = { |
| 613 |
const.L7POLICY_ID: l7policy1[const.ID], |
| 614 |
const.ADMIN_STATE_UP: True, |
| 615 |
const.TYPE: const.PATH, |
| 616 |
const.VALUE: '/slow', |
| 617 |
const.COMPARE_TYPE: const.STARTS_WITH, |
| 618 |
const.INVERT: False, |
| 619 |
} |
| 620 |
|
| 621 |
l7rule1 = self.mem_l7rule_client.create_l7rule(**l7rule1_kwargs) |
| 622 |
self.addCleanup( |
| 623 |
self.mem_l7rule_client.cleanup_l7rule, |
| 624 |
l7rule1[const.ID], l7policy_id=l7rule1_kwargs[const.L7POLICY_ID], |
| 625 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 626 |
waiters.wait_for_status( |
| 627 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 628 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 629 |
CONF.load_balancer.build_interval, |
| 630 |
CONF.load_balancer.build_timeout) |
| 631 |
|
| 632 |
|
| 633 |
l7policy2_name = data_utils.rand_name("lb_member_l7policy2-l7redirect") |
| 634 |
l7policy2_description = data_utils.arbitrary_string(size=255) |
| 635 |
l7policy2_kwargs = { |
| 636 |
const.LISTENER_ID: listener_id, |
| 637 |
const.NAME: l7policy2_name, |
| 638 |
const.DESCRIPTION: l7policy2_description, |
| 639 |
const.ADMIN_STATE_UP: True, |
| 640 |
const.POSITION: 1, |
| 641 |
const.ACTION: const.REDIRECT_TO_URL, |
| 642 |
const.REDIRECT_URL: CONF.identity.uri_v3, |
| 643 |
} |
| 644 |
l7policy2 = self.mem_l7policy_client.create_l7policy( |
| 645 |
**l7policy2_kwargs) |
| 646 |
self.addCleanup( |
| 647 |
self.mem_l7policy_client.cleanup_l7policy, |
| 648 |
l7policy2[const.ID], |
| 649 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 650 |
waiters.wait_for_status( |
| 651 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 652 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 653 |
CONF.load_balancer.build_interval, |
| 654 |
CONF.load_balancer.build_timeout) |
| 655 |
|
| 656 |
|
| 657 |
l7rule2_kwargs = { |
| 658 |
const.L7POLICY_ID: l7policy2[const.ID], |
| 659 |
const.ADMIN_STATE_UP: True, |
| 660 |
const.TYPE: const.PATH, |
| 661 |
const.VALUE: '/turtles', |
| 662 |
const.COMPARE_TYPE: const.EQUAL_TO, |
| 663 |
const.INVERT: False, |
| 664 |
} |
| 665 |
|
| 666 |
l7rule2 = self.mem_l7rule_client.create_l7rule(**l7rule2_kwargs) |
| 667 |
self.addCleanup( |
| 668 |
self.mem_l7rule_client.cleanup_l7rule, |
| 669 |
l7rule2[const.ID], l7policy_id=l7rule2_kwargs[const.L7POLICY_ID], |
| 670 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 671 |
waiters.wait_for_status( |
| 672 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 673 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 674 |
CONF.load_balancer.build_interval, |
| 675 |
CONF.load_balancer.build_timeout) |
| 676 |
|
| 677 |
|
| 678 |
l7policy3_name = data_utils.rand_name("lb_member_l7policy3-l7redirect") |
| 679 |
l7policy3_description = data_utils.arbitrary_string(size=255) |
| 680 |
l7policy3_kwargs = { |
| 681 |
const.LISTENER_ID: listener_id, |
| 682 |
const.NAME: l7policy3_name, |
| 683 |
const.DESCRIPTION: l7policy3_description, |
| 684 |
const.ADMIN_STATE_UP: True, |
| 685 |
const.POSITION: 1, |
| 686 |
const.ACTION: const.REJECT, |
| 687 |
} |
| 688 |
l7policy3 = self.mem_l7policy_client.create_l7policy( |
| 689 |
**l7policy3_kwargs) |
| 690 |
self.addCleanup( |
| 691 |
self.mem_l7policy_client.cleanup_l7policy, |
| 692 |
l7policy3[const.ID], |
| 693 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 694 |
waiters.wait_for_status( |
| 695 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 696 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 697 |
CONF.load_balancer.build_interval, |
| 698 |
CONF.load_balancer.build_timeout) |
| 699 |
|
| 700 |
|
| 701 |
l7rule3_kwargs = { |
| 702 |
const.L7POLICY_ID: l7policy3[const.ID], |
| 703 |
const.ADMIN_STATE_UP: True, |
| 704 |
const.TYPE: const.HEADER, |
| 705 |
const.KEY: 'reject', |
| 706 |
const.VALUE: 'true', |
| 707 |
const.COMPARE_TYPE: const.EQUAL_TO, |
| 708 |
const.INVERT: False, |
| 709 |
} |
| 710 |
|
| 711 |
l7rule3 = self.mem_l7rule_client.create_l7rule(**l7rule3_kwargs) |
| 712 |
self.addCleanup( |
| 713 |
self.mem_l7rule_client.cleanup_l7rule, |
| 714 |
l7rule3[const.ID], l7policy_id=l7rule3_kwargs[const.L7POLICY_ID], |
| 715 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 716 |
waiters.wait_for_status( |
| 717 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 718 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 719 |
CONF.load_balancer.build_interval, |
| 720 |
CONF.load_balancer.build_timeout) |
| 721 |
|
| 722 |
|
| 723 |
url_for_member1 = 'http://{}:{}/'.format(self.lb_vip_address, |
| 724 |
LISTENER_PORT) |
| 725 |
self.assertConsistentResponse((200, self.webserver1_response), |
| 726 |
url_for_member1) |
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
url_for_member2 = 'http://{}:{}/slow?delay=1s'.format( |
| 731 |
self.lb_vip_address, LISTENER_PORT) |
| 732 |
self.assertConsistentResponse((200, self.webserver2_response), |
| 733 |
url_for_member2, timeout=3) |
| 734 |
|
| 735 |
|
| 736 |
url_for_identity = 'http://{}:{}/turtles'.format(self.lb_vip_address, |
| 737 |
LISTENER_PORT) |
| 738 |
self.assertConsistentResponse((302, CONF.identity.uri_v3), |
| 739 |
url_for_identity, |
| 740 |
redirect=True) |
| 741 |
|
| 742 |
|
| 743 |
self.assertConsistentResponse((403, None), |
| 744 |
url_for_member1, |
| 745 |
headers={'reject': 'true'}) |
| 746 |
|
| 747 |
def _test_mixed_ipv4_ipv6_members_traffic(self, protocol, protocol_port, |
| 748 |
pool_id, persistent=True): |
| 749 |
"""Tests traffic through a loadbalancer with IPv4 and IPv6 members. |
| 750 |
|
| 751 |
* Set up members on a loadbalancer. |
| 752 |
* Test traffic to ensure it is balanced properly. |
| 753 |
""" |
| 754 |
|
| 755 |
|
| 756 |
member1_name = data_utils.rand_name("lb_member_member1-traffic") |
| 757 |
member1_kwargs = { |
| 758 |
const.POOL_ID: pool_id, |
| 759 |
const.NAME: member1_name, |
| 760 |
const.ADMIN_STATE_UP: True, |
| 761 |
const.ADDRESS: self.webserver1_ip, |
| 762 |
const.PROTOCOL_PORT: 80, |
| 763 |
} |
| 764 |
if self.lb_member_1_subnet: |
| 765 |
member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 766 |
|
| 767 |
member1 = self.mem_member_client.create_member( |
| 768 |
**member1_kwargs) |
| 769 |
self.addCleanup( |
| 770 |
self.mem_member_client.cleanup_member, |
| 771 |
member1[const.ID], pool_id=pool_id, |
| 772 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 773 |
waiters.wait_for_status( |
| 774 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 775 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 776 |
CONF.load_balancer.check_interval, |
| 777 |
CONF.load_balancer.check_timeout) |
| 778 |
|
| 779 |
|
| 780 |
member2_name = data_utils.rand_name("lb_member_member2-traffic") |
| 781 |
member2_kwargs = { |
| 782 |
const.POOL_ID: pool_id, |
| 783 |
const.NAME: member2_name, |
| 784 |
const.ADMIN_STATE_UP: True, |
| 785 |
const.ADDRESS: self.webserver2_ipv6, |
| 786 |
const.PROTOCOL_PORT: 80, |
| 787 |
} |
| 788 |
if self.lb_member_2_ipv6_subnet: |
| 789 |
member2_kwargs[const.SUBNET_ID] = ( |
| 790 |
self.lb_member_2_ipv6_subnet[const.ID]) |
| 791 |
|
| 792 |
member2 = self.mem_member_client.create_member( |
| 793 |
**member2_kwargs) |
| 794 |
self.addCleanup( |
| 795 |
self.mem_member_client.cleanup_member, |
| 796 |
member2[const.ID], pool_id=pool_id, |
| 797 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 798 |
waiters.wait_for_status( |
| 799 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 800 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 801 |
CONF.load_balancer.check_interval, |
| 802 |
CONF.load_balancer.check_timeout) |
| 803 |
|
| 804 |
|
| 805 |
self.check_members_balanced(self.lb_vip_address, |
| 806 |
protocol_port=protocol_port, |
| 807 |
protocol=protocol, persistent=persistent) |
| 808 |
|
| 809 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 810 |
'Traffic tests will not work in noop mode.') |
| 811 |
@testtools.skipUnless(CONF.load_balancer.test_with_ipv6, |
| 812 |
'Mixed IPv4/IPv6 member test requires IPv6.') |
| 813 |
@decorators.idempotent_id('20b6b671-0101-4bed-a249-9af6ee3aa6d9') |
| 814 |
def test_mixed_ipv4_ipv6_members_http_traffic(self): |
| 815 |
pool_id = self._listener_pool_create(const.HTTP, 85)[1] |
| 816 |
self._test_mixed_ipv4_ipv6_members_traffic(const.HTTP, 85, pool_id) |
| 817 |
|
| 818 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 819 |
'Traffic tests will not work in noop mode.') |
| 820 |
@testtools.skipUnless(CONF.load_balancer.test_with_ipv6, |
| 821 |
'Mixed IPv4/IPv6 member test requires IPv6.') |
| 822 |
@decorators.idempotent_id('c442ae84-0abc-4470-8c7e-14a07e92a6fa') |
| 823 |
def test_mixed_ipv4_ipv6_members_tcp_traffic(self): |
| 824 |
pool_id = self._listener_pool_create(const.TCP, 86)[1] |
| 825 |
self._test_mixed_ipv4_ipv6_members_traffic(const.TCP, 86, |
| 826 |
pool_id, persistent=False) |
| 827 |
|
| 828 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 829 |
'Traffic tests will not work in noop mode.') |
| 830 |
@testtools.skipUnless(CONF.load_balancer.test_with_ipv6, |
| 831 |
'Mixed IPv4/IPv6 member test requires IPv6.') |
| 832 |
@decorators.idempotent_id('56823616-34e1-4e17-beb9-15dd6b1593af') |
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
@decorators.skip_because( |
| 837 |
bug='2003329', |
| 838 |
bug_type='storyboard', |
| 839 |
condition=CONF.load_balancer.provider in const.AMPHORA_PROVIDERS) |
| 840 |
def test_mixed_ipv4_ipv6_members_udp_traffic(self): |
| 841 |
if not self.mem_listener_client.is_version_supported( |
| 842 |
self.api_version, '2.1'): |
| 843 |
raise self.skipException('UDP listener support is only available ' |
| 844 |
'in Octavia API version 2.1 or newer') |
| 845 |
pool_id = self._listener_pool_create(const.UDP, 8082)[1] |
| 846 |
self._test_mixed_ipv4_ipv6_members_traffic(const.UDP, 8082, pool_id) |
| 847 |
|
| 848 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 849 |
'Traffic tests will not work in noop mode.') |
| 850 |
@decorators.idempotent_id('a58063fb-b9e8-4cfc-8a8c-7b2e9e884e7a') |
| 851 |
def test_least_connections_http_traffic(self): |
| 852 |
pool_id = self._listener_pool_create( |
| 853 |
const.HTTP, 87, |
| 854 |
pool_algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS)[1] |
| 855 |
self._test_basic_traffic(const.HTTP, 87, pool_id) |
| 856 |
|
| 857 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 858 |
'Traffic tests will not work in noop mode.') |
| 859 |
@decorators.idempotent_id('e1056709-6a1a-4a15-80c2-5cbb8279f924') |
| 860 |
def test_least_connections_tcp_traffic(self): |
| 861 |
pool_id = self._listener_pool_create( |
| 862 |
const.TCP, 88, |
| 863 |
pool_algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS)[1] |
| 864 |
self._test_basic_traffic(const.TCP, 88, pool_id, |
| 865 |
persistent=False, delay=0.2) |
| 866 |
|
| 867 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 868 |
'Traffic tests will not work in noop mode.') |
| 869 |
@decorators.idempotent_id('b5285410-507c-4629-90d4-6161540033d9') |
| 870 |
def test_least_connections_udp_traffic(self): |
| 871 |
if not self.mem_listener_client.is_version_supported( |
| 872 |
self.api_version, '2.1'): |
| 873 |
raise self.skipException('UDP listener support is only available ' |
| 874 |
'in Octavia API version 2.1 or newer') |
| 875 |
pool_id = self._listener_pool_create( |
| 876 |
const.UDP, 8083, |
| 877 |
pool_algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS)[1] |
| 878 |
self._test_basic_traffic(const.UDP, 8083, pool_id) |
| 879 |
|
| 880 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 881 |
'Traffic tests will not work in noop mode.') |
| 882 |
@decorators.idempotent_id('881cc3e9-a011-4043-b0e3-a6185f736053') |
| 883 |
def test_source_ip_http_traffic(self): |
| 884 |
pool_id = self._listener_pool_create( |
| 885 |
const.HTTP, 89, |
| 886 |
pool_algorithm=const.LB_ALGORITHM_SOURCE_IP)[1] |
| 887 |
self._test_basic_traffic(const.HTTP, 89, pool_id, |
| 888 |
traffic_member_count=1, persistent=False) |
| 889 |
|
| 890 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 891 |
'Traffic tests will not work in noop mode.') |
| 892 |
@decorators.idempotent_id('4568db0e-4243-4191-a822-9d327a55fa64') |
| 893 |
def test_source_ip_tcp_traffic(self): |
| 894 |
pool_id = self._listener_pool_create( |
| 895 |
const.TCP, 90, pool_algorithm=const.LB_ALGORITHM_SOURCE_IP)[1] |
| 896 |
self._test_basic_traffic(const.TCP, 90, pool_id, |
| 897 |
traffic_member_count=1, persistent=False) |
| 898 |
|
| 899 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 900 |
'Traffic tests will not work in noop mode.') |
| 901 |
@decorators.idempotent_id('be9e6ef2-7840-47d7-9315-cdb1e897b202') |
| 902 |
def test_source_ip_udp_traffic(self): |
| 903 |
if not self.mem_listener_client.is_version_supported( |
| 904 |
self.api_version, '2.1'): |
| 905 |
raise self.skipException('UDP listener support is only available ' |
| 906 |
'in Octavia API version 2.1 or newer') |
| 907 |
pool_id = self._listener_pool_create( |
| 908 |
const.UDP, 8084, |
| 909 |
pool_algorithm=const.LB_ALGORITHM_SOURCE_IP)[1] |
| 910 |
self._test_basic_traffic(const.UDP, 8084, pool_id, |
| 911 |
traffic_member_count=1, persistent=False) |
| 912 |
|
| 913 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 914 |
'Traffic tests will not work in noop mode.') |
| 915 |
@decorators.idempotent_id('a446585b-5651-40ce-a4db-cb2ab4d37c03') |
| 916 |
@retry_on_port_in_use(start_port=60091) |
| 917 |
def test_source_ip_port_http_traffic(self, port): |
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
try: |
| 922 |
pool_id = self._listener_pool_create( |
| 923 |
const.HTTP, port, |
| 924 |
pool_algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT)[1] |
| 925 |
self._test_basic_traffic( |
| 926 |
const.HTTP, port, pool_id, |
| 927 |
traffic_member_count=1, persistent=False, source_port=port) |
| 928 |
except exceptions.NotImplemented as e: |
| 929 |
message = ("The configured provider driver '{driver}' " |
| 930 |
"does not support a feature required for this " |
| 931 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 932 |
if hasattr(e, 'resp_body'): |
| 933 |
message = e.resp_body.get('faultstring', message) |
| 934 |
raise testtools.TestCase.skipException(message) |
| 935 |
|
| 936 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 937 |
'Traffic tests will not work in noop mode.') |
| 938 |
@decorators.idempotent_id('60108f30-d870-487c-ab96-8d8a9b587b94') |
| 939 |
@retry_on_port_in_use(start_port=60092) |
| 940 |
def test_source_ip_port_tcp_traffic(self, port): |
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
try: |
| 945 |
listener_id, pool_id = self._listener_pool_create( |
| 946 |
const.TCP, port, |
| 947 |
pool_algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 948 |
|
| 949 |
|
| 950 |
self._test_basic_traffic( |
| 951 |
const.TCP, port, pool_id, traffic_member_count=1, |
| 952 |
persistent=False, source_port=port, delay=0.2) |
| 953 |
except exceptions.NotImplemented as e: |
| 954 |
message = ("The configured provider driver '{driver}' " |
| 955 |
"does not support a feature required for this " |
| 956 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 957 |
if hasattr(e, 'resp_body'): |
| 958 |
message = e.resp_body.get('faultstring', message) |
| 959 |
raise testtools.TestCase.skipException(message) |
| 960 |
|
| 961 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 962 |
'Traffic tests will not work in noop mode.') |
| 963 |
@decorators.idempotent_id('a67dfa58-6953-4a0f-8a65-3f153b254c98') |
| 964 |
def test_source_ip_port_udp_traffic(self): |
| 965 |
if not self.mem_listener_client.is_version_supported( |
| 966 |
self.api_version, '2.1'): |
| 967 |
raise self.skipException('UDP listener support is only available ' |
| 968 |
'in Octavia API version 2.1 or newer') |
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
try: |
| 973 |
pool_id = self._listener_pool_create( |
| 974 |
const.UDP, 8085, |
| 975 |
pool_algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT)[1] |
| 976 |
self._test_basic_traffic( |
| 977 |
const.UDP, 8085, pool_id, traffic_member_count=1, |
| 978 |
persistent=False, source_port=8085) |
| 979 |
except exceptions.NotImplemented as e: |
| 980 |
message = ("The configured provider driver '{driver}' " |
| 981 |
"does not support a feature required for this " |
| 982 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 983 |
if hasattr(e, 'resp_body'): |
| 984 |
message = e.resp_body.get('faultstring', message) |
| 985 |
raise testtools.TestCase.skipException(message) |
| 986 |
|
| 987 |
@testtools.skipIf(CONF.load_balancer.test_with_noop, |
| 988 |
'Log offload tests will not work in noop mode.') |
| 989 |
@testtools.skipUnless( |
| 990 |
CONF.loadbalancer_feature_enabled.log_offload_enabled, |
| 991 |
'Skipping log offload tests because tempest configuration ' |
| 992 |
'[loadbalancer-feature-enabled] log_offload_enabled is False.') |
| 993 |
@decorators.idempotent_id('571dddd9-f5bd-404e-a799-9df7ac9e2fa9') |
| 994 |
def test_tenant_flow_log(self): |
| 995 |
"""Tests tenant flow log offloading |
| 996 |
|
| 997 |
* Set up a member on a loadbalancer. |
| 998 |
* Sends a request to the load balancer. |
| 999 |
* Validates the flow log record for the request. |
| 1000 |
""" |
| 1001 |
listener_name = data_utils.rand_name("lb_member_listener1_tenant_flow") |
| 1002 |
protocol_port = '8123' |
| 1003 |
listener_kwargs = { |
| 1004 |
const.NAME: listener_name, |
| 1005 |
const.PROTOCOL: const.HTTP, |
| 1006 |
const.PROTOCOL_PORT: protocol_port, |
| 1007 |
const.LOADBALANCER_ID: self.lb_id, |
| 1008 |
} |
| 1009 |
listener = self.mem_listener_client.create_listener(**listener_kwargs) |
| 1010 |
listener_id = listener[const.ID] |
| 1011 |
self.addCleanup( |
| 1012 |
self.mem_listener_client.cleanup_listener, |
| 1013 |
listener_id, |
| 1014 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1015 |
|
| 1016 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1017 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1018 |
const.ACTIVE, |
| 1019 |
CONF.load_balancer.build_interval, |
| 1020 |
CONF.load_balancer.build_timeout) |
| 1021 |
|
| 1022 |
pool_name = data_utils.rand_name("lb_member_pool1_tenant_flow") |
| 1023 |
pool_kwargs = { |
| 1024 |
const.NAME: pool_name, |
| 1025 |
const.PROTOCOL: const.HTTP, |
| 1026 |
const.LB_ALGORITHM: const.LB_ALGORITHM_SOURCE_IP, |
| 1027 |
const.LISTENER_ID: listener_id, |
| 1028 |
} |
| 1029 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 1030 |
pool_id = pool[const.ID] |
| 1031 |
self.addCleanup( |
| 1032 |
self.mem_pool_client.cleanup_pool, |
| 1033 |
pool_id, |
| 1034 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1035 |
|
| 1036 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1037 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1038 |
const.ACTIVE, |
| 1039 |
CONF.load_balancer.build_interval, |
| 1040 |
CONF.load_balancer.build_timeout) |
| 1041 |
|
| 1042 |
|
| 1043 |
member_name = data_utils.rand_name("lb_member_member-tenant_flow") |
| 1044 |
member_kwargs = { |
| 1045 |
const.POOL_ID: pool_id, |
| 1046 |
const.NAME: member_name, |
| 1047 |
const.ADMIN_STATE_UP: True, |
| 1048 |
const.ADDRESS: self.webserver1_ip, |
| 1049 |
const.PROTOCOL_PORT: 80, |
| 1050 |
} |
| 1051 |
if self.lb_member_1_subnet: |
| 1052 |
member_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 1053 |
|
| 1054 |
member = self.mem_member_client.create_member(**member_kwargs) |
| 1055 |
member_id = member[const.ID] |
| 1056 |
self.addCleanup( |
| 1057 |
self.mem_member_client.cleanup_member, |
| 1058 |
member[const.ID], pool_id=pool_id, |
| 1059 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1060 |
waiters.wait_for_status( |
| 1061 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1062 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1063 |
CONF.load_balancer.check_interval, |
| 1064 |
CONF.load_balancer.check_timeout) |
| 1065 |
|
| 1066 |
project_id = self.os_roles_lb_member.credentials.project_id |
| 1067 |
unique_request_id = uuidutils.generate_uuid() |
| 1068 |
LOG.info('Tenant flow logging unique request ID is: %s', |
| 1069 |
unique_request_id) |
| 1070 |
|
| 1071 |
|
| 1072 |
URL = 'http://{0}:{1}/{2}'.format( |
| 1073 |
self.lb_vip_address, protocol_port, unique_request_id) |
| 1074 |
self.validate_URL_response(URL, expected_status_code=200) |
| 1075 |
|
| 1076 |
|
| 1077 |
time.sleep(CONF.load_balancer.check_interval) |
| 1078 |
|
| 1079 |
|
| 1080 |
log_line = None |
| 1081 |
with open(CONF.load_balancer.tenant_flow_log_file) as f: |
| 1082 |
for line in f: |
| 1083 |
if unique_request_id in line: |
| 1084 |
log_line = line |
| 1085 |
break |
| 1086 |
self.assertIsNotNone( |
| 1087 |
log_line, 'Tenant log entry was not found in {0}.'.format( |
| 1088 |
CONF.load_balancer.tenant_flow_log_file)) |
| 1089 |
|
| 1090 |
|
| 1091 |
log_line = log_line[log_line.index(project_id):] |
| 1092 |
|
| 1093 |
|
| 1094 |
fields = shlex.split(log_line) |
| 1095 |
|
| 1096 |
|
| 1097 |
self.assertEqual(project_id, fields[0]) |
| 1098 |
self.assertEqual(self.lb_id, fields[1]) |
| 1099 |
self.assertEqual(listener_id, fields[2]) |
| 1100 |
ipaddress.ip_address(fields[3]) |
| 1101 |
self.assertGreaterEqual(int(fields[4]), 0) |
| 1102 |
self.assertLessEqual(int(fields[4]), 65535) |
| 1103 |
datetime.datetime.strptime(fields[5], |
| 1104 |
'%d/%b/%Y:%H:%M:%S.%f') |
| 1105 |
request_string = 'GET /{0} HTTP/1.1'.format(unique_request_id) |
| 1106 |
self.assertEqual(request_string, fields[6]) |
| 1107 |
self.assertEqual('200', fields[7]) |
| 1108 |
self.assertTrue(fields[8].isdigit()) |
| 1109 |
self.assertTrue(fields[9].isdigit()) |
| 1110 |
self.assertEqual('-', fields[10]) |
| 1111 |
self.assertEqual("", fields[11]) |
| 1112 |
pool_string = '{0}:{1}'.format(pool_id, listener_id) |
| 1113 |
self.assertEqual(pool_string, fields[12]) |
| 1114 |
self.assertEqual(member_id, fields[13]) |
| 1115 |
self.assertTrue(fields[14].isdigit()) |
| 1116 |
self.assertEqual('----', fields[15]) |
| 1117 |
|
| 1118 |
@decorators.idempotent_id('04399db0-04f0-4cb5-bb27-a12bf18bfe08') |
| 1119 |
def test_http_LC_listener_with_allowed_cidrs(self): |
| 1120 |
self._test_listener_with_allowed_cidrs( |
| 1121 |
const.HTTP, 90, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1122 |
|
| 1123 |
@decorators.idempotent_id('3d8d95b6-55e8-4bb9-b474-4ac35abaff22') |
| 1124 |
def test_tcp_LC_listener_with_allowed_cidrs(self): |
| 1125 |
self._test_listener_with_allowed_cidrs( |
| 1126 |
const.TCP, 91, const.LB_ALGORITHM_LEAST_CONNECTIONS, delay=0.2) |
| 1127 |
|
| 1128 |
@decorators.idempotent_id('7456b558-9add-4e0e-988e-06803f8047f7') |
| 1129 |
def test_udp_LC_listener_with_allowed_cidrs(self): |
| 1130 |
self._test_listener_with_allowed_cidrs( |
| 1131 |
const.UDP, 92, const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 1132 |
|
| 1133 |
@decorators.idempotent_id('13b0f2de-9934-457b-8be0-f1bffc6915a0') |
| 1134 |
def test_http_RR_listener_with_allowed_cidrs(self): |
| 1135 |
self._test_listener_with_allowed_cidrs( |
| 1136 |
const.HTTP, 93, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1137 |
|
| 1138 |
@decorators.idempotent_id('8bca1325-f894-494d-95c6-3ea4c3df6a0b') |
| 1139 |
def test_tcp_RR_listener_with_allowed_cidrs(self): |
| 1140 |
self._test_listener_with_allowed_cidrs( |
| 1141 |
const.TCP, 94, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1142 |
|
| 1143 |
@decorators.idempotent_id('93675cc3-e765-464b-9563-e0848dc75330') |
| 1144 |
def test_udp_RR_listener_with_allowed_cidrs(self): |
| 1145 |
self._test_listener_with_allowed_cidrs( |
| 1146 |
const.UDP, 95, const.LB_ALGORITHM_ROUND_ROBIN) |
| 1147 |
|
| 1148 |
@decorators.idempotent_id('fb5f35c1-08c9-43f7-8ed1-0395a3ef4735') |
| 1149 |
def test_http_SI_listener_with_allowed_cidrs(self): |
| 1150 |
self._test_listener_with_allowed_cidrs( |
| 1151 |
const.HTTP, 96, const.LB_ALGORITHM_SOURCE_IP) |
| 1152 |
|
| 1153 |
@decorators.idempotent_id('c0904c88-2479-42e2-974f-55041f30e6c5') |
| 1154 |
def test_tcp_SI_listener_with_allowed_cidrs(self): |
| 1155 |
self._test_listener_with_allowed_cidrs( |
| 1156 |
const.TCP, 97, const.LB_ALGORITHM_SOURCE_IP) |
| 1157 |
|
| 1158 |
@decorators.idempotent_id('4f73bac5-2c98-45f9-8976-724c99e39979') |
| 1159 |
def test_udp_SI_listener_with_allowed_cidrs(self): |
| 1160 |
self._test_listener_with_allowed_cidrs( |
| 1161 |
const.UDP, 98, const.LB_ALGORITHM_SOURCE_IP) |
| 1162 |
|
| 1163 |
@decorators.idempotent_id('d198ddc5-1bcb-4310-a1b0-fa1a6328c4e9') |
| 1164 |
def test_http_SIP_listener_with_allowed_cidrs(self): |
| 1165 |
self._test_listener_with_allowed_cidrs( |
| 1166 |
const.HTTP, 99, const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 1167 |
|
| 1168 |
@decorators.idempotent_id('bbb09dbb-2aad-4281-9383-4bb4ad420ee1') |
| 1169 |
def test_tcp_SIP_listener_with_allowed_cidrs(self): |
| 1170 |
self._test_listener_with_allowed_cidrs( |
| 1171 |
const.TCP, 100, const.LB_ALGORITHM_SOURCE_IP_PORT, delay=0.2) |
| 1172 |
|
| 1173 |
@decorators.idempotent_id('70290a9d-0065-42ad-bb46-884a535d2da2') |
| 1174 |
def test_udp_SIP_listener_with_allowed_cidrs(self): |
| 1175 |
self._test_listener_with_allowed_cidrs( |
| 1176 |
const.UDP, 101, const.LB_ALGORITHM_SOURCE_IP_PORT, delay=0.2) |
| 1177 |
|
| 1178 |
def _test_listener_with_allowed_cidrs(self, protocol, protocol_port, |
| 1179 |
algorithm, delay=None): |
| 1180 |
"""Tests traffic through a loadbalancer with allowed CIDRs set. |
| 1181 |
|
| 1182 |
* Set up listener with allowed CIDRS (allow all) on a loadbalancer. |
| 1183 |
* Set up pool on a loadbalancer |
| 1184 |
* Set up members on a loadbalancer. |
| 1185 |
* Test traffic to ensure it is balanced properly. |
| 1186 |
* Update allowed CIDRs to restrict traffic to a small subnet. |
| 1187 |
* Assert loadbalancer does not respond to client requests. |
| 1188 |
""" |
| 1189 |
|
| 1190 |
if not self.mem_listener_client.is_version_supported( |
| 1191 |
self.api_version, '2.12'): |
| 1192 |
raise self.skipException('Allowed CIDRS in listeners is only ' |
| 1193 |
'available on Octavia API version 2.12 ' |
| 1194 |
'or newer.') |
| 1195 |
|
| 1196 |
listener_name = data_utils.rand_name("lb_member_listener2_cidrs") |
| 1197 |
listener_kwargs = { |
| 1198 |
const.NAME: listener_name, |
| 1199 |
const.PROTOCOL: protocol, |
| 1200 |
const.PROTOCOL_PORT: protocol_port, |
| 1201 |
const.LOADBALANCER_ID: self.lb_id, |
| 1202 |
const.ALLOWED_CIDRS: ['0.0.0.0/0'] |
| 1203 |
} |
| 1204 |
listener = self.mem_listener_client.create_listener(**listener_kwargs) |
| 1205 |
listener_id = listener[const.ID] |
| 1206 |
self.addCleanup( |
| 1207 |
self.mem_listener_client.cleanup_listener, |
| 1208 |
listener_id, |
| 1209 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1210 |
|
| 1211 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1212 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1213 |
const.ACTIVE, |
| 1214 |
CONF.load_balancer.check_interval, |
| 1215 |
CONF.load_balancer.check_timeout) |
| 1216 |
|
| 1217 |
pool_name = data_utils.rand_name("lb_member_pool3_cidrs") |
| 1218 |
pool_kwargs = { |
| 1219 |
const.NAME: pool_name, |
| 1220 |
const.PROTOCOL: protocol, |
| 1221 |
const.LB_ALGORITHM: algorithm, |
| 1222 |
const.LISTENER_ID: listener_id, |
| 1223 |
} |
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
try: |
| 1228 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 1229 |
except exceptions.NotImplemented as e: |
| 1230 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 1231 |
raise |
| 1232 |
message = ("The configured provider driver '{driver}' " |
| 1233 |
"does not support a feature required for this " |
| 1234 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 1235 |
if hasattr(e, 'resp_body'): |
| 1236 |
message = e.resp_body.get('faultstring', message) |
| 1237 |
raise testtools.TestCase.skipException(message) |
| 1238 |
|
| 1239 |
pool_id = pool[const.ID] |
| 1240 |
self.addCleanup( |
| 1241 |
self.mem_pool_client.cleanup_pool, |
| 1242 |
pool_id, |
| 1243 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1244 |
|
| 1245 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1246 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1247 |
const.ACTIVE, |
| 1248 |
CONF.load_balancer.check_interval, |
| 1249 |
CONF.load_balancer.check_timeout) |
| 1250 |
|
| 1251 |
|
| 1252 |
member1_name = data_utils.rand_name("lb_member_member1-cidrs-traffic") |
| 1253 |
member1_kwargs = { |
| 1254 |
const.POOL_ID: pool_id, |
| 1255 |
const.NAME: member1_name, |
| 1256 |
const.ADMIN_STATE_UP: True, |
| 1257 |
const.ADDRESS: self.webserver1_ip, |
| 1258 |
const.PROTOCOL_PORT: 80, |
| 1259 |
} |
| 1260 |
if self.lb_member_1_subnet: |
| 1261 |
member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 1262 |
|
| 1263 |
member1 = self.mem_member_client.create_member( |
| 1264 |
**member1_kwargs) |
| 1265 |
self.addCleanup( |
| 1266 |
self.mem_member_client.cleanup_member, |
| 1267 |
member1[const.ID], pool_id=pool_id, |
| 1268 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1269 |
waiters.wait_for_status( |
| 1270 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1271 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1272 |
CONF.load_balancer.check_interval, |
| 1273 |
CONF.load_balancer.check_timeout) |
| 1274 |
|
| 1275 |
|
| 1276 |
member2_name = data_utils.rand_name("lb_member_member2-cidrs-traffic") |
| 1277 |
member2_kwargs = { |
| 1278 |
const.POOL_ID: pool_id, |
| 1279 |
const.NAME: member2_name, |
| 1280 |
const.ADMIN_STATE_UP: True, |
| 1281 |
const.ADDRESS: self.webserver2_ip, |
| 1282 |
const.PROTOCOL_PORT: 80, |
| 1283 |
} |
| 1284 |
if self.lb_member_2_subnet: |
| 1285 |
member2_kwargs[const.SUBNET_ID] = self.lb_member_2_subnet[const.ID] |
| 1286 |
|
| 1287 |
member2 = self.mem_member_client.create_member(**member2_kwargs) |
| 1288 |
self.addCleanup( |
| 1289 |
self.mem_member_client.cleanup_member, |
| 1290 |
member2[const.ID], pool_id=pool_id, |
| 1291 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1292 |
waiters.wait_for_status( |
| 1293 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1294 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1295 |
CONF.load_balancer.check_interval, |
| 1296 |
CONF.load_balancer.check_timeout) |
| 1297 |
|
| 1298 |
|
| 1299 |
members = 2 |
| 1300 |
if algorithm == const.LB_ALGORITHM_SOURCE_IP: |
| 1301 |
members = 1 |
| 1302 |
self.check_members_balanced( |
| 1303 |
self.lb_vip_address, protocol=protocol, |
| 1304 |
protocol_port=protocol_port, persistent=False, |
| 1305 |
traffic_member_count=members, delay=delay) |
| 1306 |
|
| 1307 |
listener_kwargs = { |
| 1308 |
const.LISTENER_ID: listener_id, |
| 1309 |
const.ALLOWED_CIDRS: ['192.0.1.0/32'] |
| 1310 |
} |
| 1311 |
self.mem_listener_client.update_listener(**listener_kwargs) |
| 1312 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1313 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1314 |
const.ACTIVE, |
| 1315 |
CONF.load_balancer.check_interval, |
| 1316 |
CONF.load_balancer.check_timeout) |
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
def expect_timeout_error(address, protocol, protocol_port): |
| 1322 |
try: |
| 1323 |
self.make_request(address, protocol=protocol, |
| 1324 |
protocol_port=protocol_port) |
| 1325 |
except exceptions.TimeoutException: |
| 1326 |
return True |
| 1327 |
return False |
| 1328 |
|
| 1329 |
waiters.wait_until_true( |
| 1330 |
expect_timeout_error, address=self.lb_vip_address, |
| 1331 |
protocol=protocol, protocol_port=protocol_port) |
| 1332 |
|
| 1333 |
|
| 1334 |
if protocol == const.UDP: |
| 1335 |
url_for_vip = 'udp://{}:{}/'.format(self.lb_vip_address, |
| 1336 |
protocol_port) |
| 1337 |
else: |
| 1338 |
url_for_vip = 'http://{}:{}/'.format(self.lb_vip_address, |
| 1339 |
protocol_port) |
| 1340 |
self.assertConsistentResponse( |
| 1341 |
(None, None), url_for_vip, repeat=3, expect_connection_error=True) |
| 1342 |
|
| 1343 |
@decorators.idempotent_id('d3a28e76-76bc-11eb-a7c3-74e5f9e2a801') |
| 1344 |
def test_insert_headers(self): |
| 1345 |
|
| 1346 |
listener_port = 102 |
| 1347 |
listener_id, pool_id = self._listener_pool_create( |
| 1348 |
const.HTTP, listener_port, insert_headers_dic={ |
| 1349 |
const.X_FORWARDED_FOR: "true"}) |
| 1350 |
self._test_basic_traffic( |
| 1351 |
const.HTTP, listener_port, pool_id) |
| 1352 |
|
| 1353 |
|
| 1354 |
test_url = 'http://{}:{}/request'.format( |
| 1355 |
self.lb_vip_address, listener_port) |
| 1356 |
data = self.validate_URL_response(test_url) |
| 1357 |
LOG.info('Received payload is: %s', data) |
| 1358 |
|
| 1359 |
|
| 1360 |
try: |
| 1361 |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 1362 |
s.connect((self.lb_vip_address, listener_port)) |
| 1363 |
client_source_ip = s.getsockname()[0] |
| 1364 |
s.close() |
| 1365 |
except Exception: |
| 1366 |
LOG.exception('Failed to initiate TCP socket toward LB_VIP') |
| 1367 |
raise Exception('LB_VIP is not available') |
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
def _data_parser(payload, relevant_headers): |
| 1372 |
retrieved_headers = {} |
| 1373 |
for line in payload.split('\n'): |
| 1374 |
try: |
| 1375 |
key, value = line.split(': ', 1) |
| 1376 |
except ValueError: |
| 1377 |
continue |
| 1378 |
if key in relevant_headers: |
| 1379 |
retrieved_headers[key] = value.lower() |
| 1380 |
return retrieved_headers |
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
expected_headers = {const.X_FORWARDED_FOR: client_source_ip} |
| 1385 |
received_headers = _data_parser(data, expected_headers) |
| 1386 |
self.assertEqual(expected_headers, received_headers) |
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
listener_kwargs = { |
| 1391 |
const.LISTENER_ID: listener_id, |
| 1392 |
const.INSERT_HEADERS: { |
| 1393 |
const.X_FORWARDED_PORT: "true", |
| 1394 |
const.X_FORWARDED_PROTO: "true"}} |
| 1395 |
self.mem_listener_client.update_listener(**listener_kwargs) |
| 1396 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1397 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1398 |
const.ACTIVE, |
| 1399 |
CONF.load_balancer.check_interval, |
| 1400 |
CONF.load_balancer.check_timeout) |
| 1401 |
|
| 1402 |
|
| 1403 |
data = self.validate_URL_response(test_url) |
| 1404 |
LOG.info('Received payload is: %s', data) |
| 1405 |
expected_headers = {const.X_FORWARDED_PORT: '{}'.format( |
| 1406 |
listener_port), const.X_FORWARDED_PROTO: const.HTTP.lower()} |
| 1407 |
received_headers = _data_parser(data, expected_headers) |
| 1408 |
self.assertEqual(expected_headers, received_headers) |
| 1409 |
|
| 1410 |
@decorators.idempotent_id('2b05229c-0254-11eb-8610-74e5f9e2a801') |
| 1411 |
def test_tcp_and_udp_traffic_on_same_port(self): |
| 1412 |
common_vip_port = 103 |
| 1413 |
listener_id_udp, pool_id_udp = self._listener_pool_create( |
| 1414 |
const.UDP, common_vip_port) |
| 1415 |
listener_id_tcp, pool_id_tcp = self._listener_pool_create( |
| 1416 |
const.TCP, common_vip_port) |
| 1417 |
self._test_basic_traffic(const.UDP, common_vip_port, pool_id_udp) |
| 1418 |
self._test_basic_traffic(const.TCP, common_vip_port, pool_id_tcp, |
| 1419 |
persistent=False) |
| 1420 |
|
| 1421 |
@decorators.idempotent_id('c79f2cd0-0324-11eb-bc8e-74e5f9e2a801') |
| 1422 |
def test_udp_update_pool_healthmonitor_listener(self): |
| 1423 |
"""Test scenario: |
| 1424 |
|
| 1425 |
* Prerequisites: |
| 1426 |
Create: UDP listener, pool, healtmonitor and validate UDP traffic. |
| 1427 |
* Test scenario: |
| 1428 |
Update pool algorithm to: "source_ip" and start sending UDP traffic. |
| 1429 |
Expected: successfully received UDP packages from LB VIP. |
| 1430 |
* Update healtmonitor with: "delay=20" and start sending UDP traffic. |
| 1431 |
Expected: successfully received UDP packages from LB VIP. |
| 1432 |
* Update listener with: "connection-limit=300" and start sending |
| 1433 |
UDP traffic. |
| 1434 |
Expected: successfully received UDP packages from LB VIP. |
| 1435 |
""" |
| 1436 |
if not self.mem_listener_client.is_version_supported( |
| 1437 |
self.api_version, '2.1'): |
| 1438 |
raise self.skipException('UDP listener support is only available ' |
| 1439 |
'in Octavia API version 2.1 or newer') |
| 1440 |
listener_port = 104 |
| 1441 |
listener_id, pool_id = self._listener_pool_create( |
| 1442 |
const.UDP, listener_port) |
| 1443 |
healthmonitor_id = self._pool_add_healthmonitor( |
| 1444 |
pool_id, protocol=const.UDP)[const.ID] |
| 1445 |
self._test_basic_traffic( |
| 1446 |
const.UDP, listener_port, pool_id) |
| 1447 |
|
| 1448 |
|
| 1449 |
self.mem_pool_client.update_pool( |
| 1450 |
pool_id=pool_id, lb_algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 1451 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1452 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1453 |
const.ACTIVE, |
| 1454 |
CONF.load_balancer.build_interval, |
| 1455 |
CONF.load_balancer.build_timeout) |
| 1456 |
self.assertIsNotNone(self.make_udp_requests_with_retries( |
| 1457 |
vip_address=self.lb_vip_address, dst_port=listener_port, |
| 1458 |
number_of_retries=3), |
| 1459 |
'Failed - all UDP retries to LB VIP has failed') |
| 1460 |
|
| 1461 |
|
| 1462 |
self.mem_healthmonitor_client.update_healthmonitor( |
| 1463 |
healthmonitor_id=healthmonitor_id, delay=5) |
| 1464 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1465 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1466 |
const.ACTIVE, |
| 1467 |
CONF.load_balancer.check_interval, |
| 1468 |
CONF.load_balancer.check_timeout) |
| 1469 |
self.assertIsNotNone(self.make_udp_requests_with_retries( |
| 1470 |
vip_address=self.lb_vip_address, dst_port=listener_port, |
| 1471 |
number_of_retries=3), |
| 1472 |
'Failed - all UDP retries to LB VIP has failed') |
| 1473 |
|
| 1474 |
|
| 1475 |
listener_kwargs = {const.LISTENER_ID: listener_id, |
| 1476 |
const.CONNECTION_LIMIT: 300} |
| 1477 |
self.mem_listener_client.update_listener(**listener_kwargs) |
| 1478 |
waiters.wait_for_status(self.mem_lb_client.show_loadbalancer, |
| 1479 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1480 |
const.ACTIVE, |
| 1481 |
CONF.load_balancer.build_interval, |
| 1482 |
CONF.load_balancer.build_timeout) |
| 1483 |
self.assertIsNotNone(self.make_udp_requests_with_retries( |
| 1484 |
vip_address=self.lb_vip_address, dst_port=listener_port, |
| 1485 |
number_of_retries=3), |
| 1486 |
'Failed - all UDP retries to LB VIP has failed') |
| 1487 |
|
| 1488 |
@decorators.attr(type='slow') |
| 1489 |
@decorators.idempotent_id('cd5aeefa-0e16-11eb-b8dc-74e5f9e2a801') |
| 1490 |
def test_hm_op_status_changed_as_expected_on_update(self): |
| 1491 |
"""Test scenario: |
| 1492 |
|
| 1493 |
* Create HTTP listener, pool and HTTP health monitor. |
| 1494 |
* Update health monitor with various combinations of: |
| 1495 |
HTTP method, expected HTTP status codes and backend URL. |
| 1496 |
Note: see "fault_cases" and "valid_cases" lists in test's code. |
| 1497 |
* Validate that members' operation status is getting into |
| 1498 |
appropriate state after each particular update done within the test. |
| 1499 |
Important: "operation status" value is expected to be changed from |
| 1500 |
ONLINE to ERROR after each update, otherwise we may miss |
| 1501 |
the potential bug. |
| 1502 |
""" |
| 1503 |
listener_port = 105 |
| 1504 |
listener_id, pool_id = self._listener_pool_create( |
| 1505 |
const.TCP, listener_port) |
| 1506 |
hm_id = self._pool_add_healthmonitor( |
| 1507 |
pool_id, protocol=const.HTTP)[const.ID] |
| 1508 |
self._test_basic_traffic( |
| 1509 |
const.HTTP, listener_port, pool_id, persistent=False) |
| 1510 |
mb_ids = [mb[const.ID] for |
| 1511 |
mb in self.mem_member_client.list_members(pool_id)] |
| 1512 |
|
| 1513 |
|
| 1514 |
fault_cases = [ |
| 1515 |
{'mthd': const.POST, 'code': '101-102', 'op_stat': const.ERROR, |
| 1516 |
'url_path': '/request?response_code=103'}, |
| 1517 |
{'mthd': const.DELETE, 'code': '201-204', 'op_stat': const.ERROR, |
| 1518 |
'url_path': '/request?response_code=205'}, |
| 1519 |
{'mthd': const.PUT, 'code': '301-302', 'op_stat': const.ERROR, |
| 1520 |
'url_path': '/request?response_code=303'}, |
| 1521 |
{'mthd': const.HEAD, 'code': '400-404', 'op_stat': const.ERROR, |
| 1522 |
'url_path': '/request?response_code=405'}, |
| 1523 |
{'mthd': const.OPTIONS, 'code': '500-504', 'op_stat': const.ERROR, |
| 1524 |
'url_path': '/request?response_code=505'}, |
| 1525 |
{'mthd': const.PATCH, 'code': '201-204', 'op_stat': const.ERROR, |
| 1526 |
'url_path': '/request?response_code=205'}, |
| 1527 |
{'mthd': const.CONNECT, 'code': '201-204', 'op_stat': const.ERROR, |
| 1528 |
'url_path': '/request?response_code=205'}, |
| 1529 |
{'mthd': const.TRACE, 'code': '201-204', 'op_stat': const.ERROR, |
| 1530 |
'url_path': '/request?response_code=205'}] |
| 1531 |
valid_cases = [ |
| 1532 |
{'mthd': const.GET, 'code': '101-102', 'op_stat': const.ONLINE, |
| 1533 |
'url_path': '/request?response_code=102'}, |
| 1534 |
{'mthd': const.GET, 'code': '201-204', 'op_stat': const.ONLINE, |
| 1535 |
'url_path': '/request?response_code=202'}, |
| 1536 |
{'mthd': const.GET, 'code': '301-302', 'op_stat': const.ONLINE, |
| 1537 |
'url_path': '/request?response_code=302'}, |
| 1538 |
{'mthd': const.GET, 'code': '400-404', 'op_stat': const.ONLINE, |
| 1539 |
'url_path': '/request?response_code=404'}, |
| 1540 |
{'mthd': const.GET, 'code': '500-504', 'op_stat': const.ONLINE, |
| 1541 |
'url_path': '/request?response_code=504'}, |
| 1542 |
{'mthd': const.GET, 'code': '201-204', 'op_stat': const.ONLINE, |
| 1543 |
'url_path': '/request?response_code=204'}, |
| 1544 |
{'mthd': const.GET, 'code': '201-204', 'op_stat': const.ONLINE, |
| 1545 |
'url_path': '/request?response_code=204'}, |
| 1546 |
{'mthd': const.GET, 'code': '201-204', 'op_stat': const.ONLINE, |
| 1547 |
'url_path': '/request?response_code=204'}] |
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
flip_flop = [v for f in zip(valid_cases, fault_cases) for v in f] |
| 1552 |
|
| 1553 |
|
| 1554 |
|
| 1555 |
for ff in flip_flop: |
| 1556 |
LOG.info('Tested test case is: %s', ff) |
| 1557 |
self.mem_healthmonitor_client.update_healthmonitor( |
| 1558 |
hm_id, expected_codes=ff['code'], http_method=ff['mthd'], |
| 1559 |
url_path=ff['url_path']) |
| 1560 |
waiters.wait_for_status( |
| 1561 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1562 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1563 |
CONF.load_balancer.build_interval, |
| 1564 |
CONF.load_balancer.build_timeout) |
| 1565 |
for mb_id in mb_ids: |
| 1566 |
waiters.wait_for_status( |
| 1567 |
self.mem_member_client.show_member, |
| 1568 |
mb_id, const.OPERATING_STATUS, |
| 1569 |
ff['op_stat'], |
| 1570 |
CONF.load_balancer.check_interval, |
| 1571 |
CONF.load_balancer.check_timeout, |
| 1572 |
error_ok=True, pool_id=pool_id) |
| 1573 |
|
| 1574 |
@decorators.idempotent_id('05e99fb3-2b37-478e-889b-77f1c731a471') |
| 1575 |
@testtools.skipUnless( |
| 1576 |
CONF.loadbalancer_feature_enabled.prometheus_listener_enabled, |
| 1577 |
'PROMETHEUS listener tests are disabled in the tempest configuration.') |
| 1578 |
def test_prometheus_listener_metrics_page(self): |
| 1579 |
"""Tests PROMETHEUS listener create and metrics endpoint is available |
| 1580 |
|
| 1581 |
* Create PROMETHEUS listener. |
| 1582 |
* Query the metrics endpoint on the load balancer. |
| 1583 |
""" |
| 1584 |
if not self.mem_listener_client.is_version_supported( |
| 1585 |
self.api_version, '2.25'): |
| 1586 |
raise self.skipException('PROMETHEUS listeners are only available ' |
| 1587 |
'on Octavia API version 2.25 or newer.') |
| 1588 |
|
| 1589 |
|
| 1590 |
listener_name = data_utils.rand_name("lb_member_prometheus_listener") |
| 1591 |
listener_description = data_utils.arbitrary_string(size=255) |
| 1592 |
listener_kwargs = { |
| 1593 |
const.NAME: listener_name, |
| 1594 |
const.DESCRIPTION: listener_description, |
| 1595 |
const.ADMIN_STATE_UP: True, |
| 1596 |
const.PROTOCOL: const.PROMETHEUS, |
| 1597 |
const.PROTOCOL_PORT: 8080, |
| 1598 |
const.LOADBALANCER_ID: self.lb_id, |
| 1599 |
const.CONNECTION_LIMIT: 200, |
| 1600 |
} |
| 1601 |
|
| 1602 |
if self.mem_listener_client.is_version_supported( |
| 1603 |
self.api_version, '2.1'): |
| 1604 |
listener_kwargs.update({ |
| 1605 |
const.TIMEOUT_CLIENT_DATA: 1000, |
| 1606 |
const.TIMEOUT_MEMBER_CONNECT: 1000, |
| 1607 |
const.TIMEOUT_MEMBER_DATA: 1000, |
| 1608 |
const.TIMEOUT_TCP_INSPECT: 50, |
| 1609 |
}) |
| 1610 |
if self.mem_listener_client.is_version_supported( |
| 1611 |
self.api_version, '2.12'): |
| 1612 |
listener_kwargs.update({const.ALLOWED_CIDRS: ['0.0.0.0/0']}) |
| 1613 |
|
| 1614 |
listener = self.mem_listener_client.create_listener(**listener_kwargs) |
| 1615 |
self.addCleanup( |
| 1616 |
self.mem_listener_client.cleanup_listener, |
| 1617 |
listener[const.ID], |
| 1618 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1619 |
|
| 1620 |
waiters.wait_for_status( |
| 1621 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1622 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1623 |
CONF.load_balancer.build_interval, |
| 1624 |
CONF.load_balancer.build_timeout) |
| 1625 |
listener = waiters.wait_for_status( |
| 1626 |
self.mem_listener_client.show_listener, |
| 1627 |
listener[const.ID], const.PROVISIONING_STATUS, |
| 1628 |
const.ACTIVE, |
| 1629 |
CONF.load_balancer.build_interval, |
| 1630 |
CONF.load_balancer.build_timeout) |
| 1631 |
|
| 1632 |
|
| 1633 |
URL = 'http://{0}:{1}/metrics'.format(self.lb_vip_address, '8080') |
| 1634 |
self.validate_URL_response(URL, expected_status_code=200) |
| 1635 |
|
| 1636 |
@decorators.idempotent_id('b2d5cefe-eac0-4eb3-b7c2-54f22578def9') |
| 1637 |
def test_backup_member(self): |
| 1638 |
if not self.mem_member_client.is_version_supported( |
| 1639 |
self.api_version, '2.1'): |
| 1640 |
raise self.skipException('Backup member support is only available ' |
| 1641 |
'in Octavia API version 2.1 or newer') |
| 1642 |
|
| 1643 |
_LISTENER_PORT = 106 |
| 1644 |
|
| 1645 |
pool_id = self._listener_pool_create(const.HTTP, _LISTENER_PORT)[1] |
| 1646 |
|
| 1647 |
|
| 1648 |
hm_name = data_utils.rand_name("lb_member_hm1-backup-not-active") |
| 1649 |
hm_kwargs = { |
| 1650 |
const.POOL_ID: pool_id, |
| 1651 |
const.NAME: hm_name, |
| 1652 |
const.TYPE: const.HEALTH_MONITOR_HTTP, |
| 1653 |
const.DELAY: 1, |
| 1654 |
const.TIMEOUT: 1, |
| 1655 |
const.MAX_RETRIES: 1, |
| 1656 |
const.MAX_RETRIES_DOWN: 1, |
| 1657 |
const.HTTP_METHOD: const.GET, |
| 1658 |
const.URL_PATH: '/', |
| 1659 |
const.EXPECTED_CODES: '200', |
| 1660 |
const.ADMIN_STATE_UP: True, |
| 1661 |
} |
| 1662 |
hm = self.mem_healthmonitor_client.create_healthmonitor(**hm_kwargs) |
| 1663 |
self.addCleanup( |
| 1664 |
self.mem_healthmonitor_client.cleanup_healthmonitor, |
| 1665 |
hm[const.ID], lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1666 |
waiters.wait_for_status( |
| 1667 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1668 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1669 |
CONF.load_balancer.check_interval, |
| 1670 |
CONF.load_balancer.check_timeout) |
| 1671 |
hm = waiters.wait_for_status( |
| 1672 |
self.mem_healthmonitor_client.show_healthmonitor, |
| 1673 |
hm[const.ID], const.PROVISIONING_STATUS, |
| 1674 |
const.ACTIVE, |
| 1675 |
CONF.load_balancer.check_interval, |
| 1676 |
CONF.load_balancer.check_timeout) |
| 1677 |
|
| 1678 |
|
| 1679 |
member1_name = data_utils.rand_name("lb_member_member1-not-backup") |
| 1680 |
member1_kwargs = { |
| 1681 |
const.POOL_ID: pool_id, |
| 1682 |
const.NAME: member1_name, |
| 1683 |
const.ADMIN_STATE_UP: True, |
| 1684 |
const.ADDRESS: self.webserver1_ip, |
| 1685 |
const.PROTOCOL_PORT: 80, |
| 1686 |
} |
| 1687 |
if self.lb_member_1_subnet: |
| 1688 |
member1_kwargs[const.SUBNET_ID] = self.lb_member_1_subnet[const.ID] |
| 1689 |
|
| 1690 |
member1 = self.mem_member_client.create_member(**member1_kwargs) |
| 1691 |
self.addCleanup( |
| 1692 |
self.mem_member_client.cleanup_member, |
| 1693 |
member1[const.ID], pool_id=pool_id, |
| 1694 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1695 |
waiters.wait_for_status( |
| 1696 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1697 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1698 |
CONF.load_balancer.check_interval, |
| 1699 |
CONF.load_balancer.check_timeout) |
| 1700 |
|
| 1701 |
|
| 1702 |
member2_name = data_utils.rand_name("lb_member_member2-backup") |
| 1703 |
member2_kwargs = { |
| 1704 |
const.POOL_ID: pool_id, |
| 1705 |
const.NAME: member2_name, |
| 1706 |
const.ADMIN_STATE_UP: True, |
| 1707 |
const.ADDRESS: self.webserver2_ip, |
| 1708 |
const.PROTOCOL_PORT: 80, |
| 1709 |
const.BACKUP: True, |
| 1710 |
} |
| 1711 |
if self.lb_member_2_subnet: |
| 1712 |
member2_kwargs[const.SUBNET_ID] = self.lb_member_2_subnet[const.ID] |
| 1713 |
|
| 1714 |
member2 = self.mem_member_client.create_member(**member2_kwargs) |
| 1715 |
self.addCleanup( |
| 1716 |
self.mem_member_client.cleanup_member, |
| 1717 |
member2[const.ID], pool_id=pool_id, |
| 1718 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 1719 |
waiters.wait_for_status( |
| 1720 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1721 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1722 |
CONF.load_balancer.check_interval, |
| 1723 |
CONF.load_balancer.check_timeout) |
| 1724 |
|
| 1725 |
url_for_tests = f'http://{self.lb_vip_address}:{_LISTENER_PORT}/' |
| 1726 |
|
| 1727 |
|
| 1728 |
self.assertConsistentResponse((200, self.webserver1_response), |
| 1729 |
url_for_tests) |
| 1730 |
|
| 1731 |
|
| 1732 |
member_update_kwargs = { |
| 1733 |
const.POOL_ID: pool_id, |
| 1734 |
const.ADMIN_STATE_UP: False} |
| 1735 |
|
| 1736 |
self.mem_member_client.update_member( |
| 1737 |
member1[const.ID], **member_update_kwargs) |
| 1738 |
|
| 1739 |
waiters.wait_for_status( |
| 1740 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1741 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1742 |
CONF.load_balancer.check_interval, |
| 1743 |
CONF.load_balancer.check_timeout) |
| 1744 |
waiters.wait_for_status( |
| 1745 |
self.mem_member_client.show_member, |
| 1746 |
member1[const.ID], const.PROVISIONING_STATUS, |
| 1747 |
const.ACTIVE, |
| 1748 |
CONF.load_balancer.check_interval, |
| 1749 |
CONF.load_balancer.check_timeout, |
| 1750 |
pool_id=pool_id) |
| 1751 |
|
| 1752 |
|
| 1753 |
self.assertConsistentResponse((200, self.webserver2_response), |
| 1754 |
url_for_tests) |
| 1755 |
|
| 1756 |
|
| 1757 |
member_update_kwargs = { |
| 1758 |
const.POOL_ID: pool_id, |
| 1759 |
const.ADMIN_STATE_UP: True} |
| 1760 |
|
| 1761 |
self.mem_member_client.update_member( |
| 1762 |
member1[const.ID], **member_update_kwargs) |
| 1763 |
|
| 1764 |
waiters.wait_for_status( |
| 1765 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 1766 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 1767 |
CONF.load_balancer.check_interval, |
| 1768 |
CONF.load_balancer.check_timeout) |
| 1769 |
waiters.wait_for_status( |
| 1770 |
self.mem_member_client.show_member, |
| 1771 |
member1[const.ID], const.PROVISIONING_STATUS, |
| 1772 |
const.ACTIVE, |
| 1773 |
CONF.load_balancer.check_interval, |
| 1774 |
CONF.load_balancer.check_timeout, |
| 1775 |
pool_id=pool_id) |
| 1776 |
|
| 1777 |
|
| 1778 |
self.assertConsistentResponse((200, self.webserver1_response), |
| 1779 |
url_for_tests) |
| 1780 |
|
| 1781 |
|
| 1782 |
self.mem_member_client.delete_member( |
| 1783 |
member1[const.ID], |
| 1784 |
pool_id=pool_id) |
| 1785 |
|
| 1786 |
waiters.wait_for_deleted_status_or_not_found( |
| 1787 |
self.mem_member_client.show_member, member1[const.ID], |
| 1788 |
const.PROVISIONING_STATUS, |
| 1789 |
CONF.load_balancer.check_interval, |
| 1790 |
CONF.load_balancer.check_timeout, |
| 1791 |
pool_id=pool_id) |
| 1792 |
|
| 1793 |
waiters.wait_for_status( |
| 1794 |
self.mem_lb_client.show_loadbalancer, |
| 1795 |
self.lb_id, const.PROVISIONING_STATUS, |
| 1796 |
const.ACTIVE, |
| 1797 |
CONF.load_balancer.check_interval, |
| 1798 |
CONF.load_balancer.check_timeout) |
| 1799 |
|
| 1800 |
|
| 1801 |
self.assertConsistentResponse((200, self.webserver2_response), |
| 1802 |
url_for_tests) |