| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
import testtools |
| 16 |
from uuid import UUID |
| 17 |
|
| 18 |
from dateutil import parser |
| 19 |
from tempest import config |
| 20 |
from tempest.lib.common.utils import data_utils |
| 21 |
from tempest.lib import decorators |
| 22 |
from tempest.lib import exceptions |
| 23 |
|
| 24 |
from octavia_tempest_plugin.common import constants as const |
| 25 |
from octavia_tempest_plugin.tests import test_base |
| 26 |
from octavia_tempest_plugin.tests import waiters |
| 27 |
|
| 28 |
CONF = config.CONF |
| 29 |
|
| 30 |
|
| 31 |
class PoolScenarioTest(test_base.LoadBalancerBaseTest): |
| 32 |
|
| 33 |
@classmethod |
| 34 |
def resource_setup(cls): |
| 35 |
"""Setup resources needed by the tests.""" |
| 36 |
super(PoolScenarioTest, cls).resource_setup() |
| 37 |
|
| 38 |
lb_name = data_utils.rand_name("lb_member_lb1_pool") |
| 39 |
lb_kwargs = {const.PROVIDER: CONF.load_balancer.provider, |
| 40 |
const.NAME: lb_name} |
| 41 |
|
| 42 |
cls._setup_lb_network_kwargs(lb_kwargs) |
| 43 |
|
| 44 |
lb = cls.mem_lb_client.create_loadbalancer(**lb_kwargs) |
| 45 |
cls.lb_id = lb[const.ID] |
| 46 |
cls.addClassResourceCleanup( |
| 47 |
cls.mem_lb_client.cleanup_loadbalancer, |
| 48 |
cls.lb_id, cascade=True) |
| 49 |
|
| 50 |
waiters.wait_for_status(cls.mem_lb_client.show_loadbalancer, |
| 51 |
cls.lb_id, const.PROVISIONING_STATUS, |
| 52 |
const.ACTIVE, |
| 53 |
CONF.load_balancer.lb_build_interval, |
| 54 |
CONF.load_balancer.lb_build_timeout) |
| 55 |
|
| 56 |
|
| 57 |
@decorators.idempotent_id('f30bd185-ca13-45c1-8a2f-f4179e7f0c3a') |
| 58 |
def test_HTTP_LC_pool_standalone_CRUD(self): |
| 59 |
self._test_pool_CRUD(listener_protocol=None, |
| 60 |
pool_protocol=const.HTTP, protocol_port=10, |
| 61 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 62 |
|
| 63 |
@decorators.idempotent_id('d8c428b0-dee4-4374-8286-31e52aeb7fe5') |
| 64 |
def test_HTTP_LC_pool_with_listener_CRUD(self): |
| 65 |
self._test_pool_CRUD(listener_protocol=const.HTTP, |
| 66 |
pool_protocol=const.HTTP, protocol_port=11, |
| 67 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 68 |
|
| 69 |
@decorators.idempotent_id('82d8e035-4068-4bad-a87b-e4907bf6d464') |
| 70 |
def test_HTTPS_LC_pool_standalone_CRUD(self): |
| 71 |
self._test_pool_CRUD(listener_protocol=None, |
| 72 |
pool_protocol=const.HTTPS, protocol_port=12, |
| 73 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 74 |
|
| 75 |
@decorators.idempotent_id('726beb03-de8c-43cd-ba5f-e7d6faf627a3') |
| 76 |
def test_HTTPS_LC_pool_with_listener_CRUD(self): |
| 77 |
self._test_pool_CRUD(listener_protocol=const.HTTPS, |
| 78 |
pool_protocol=const.HTTPS, protocol_port=13, |
| 79 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 80 |
|
| 81 |
@decorators.idempotent_id('b3cef24e-343a-4e77-833b-422158d54673') |
| 82 |
def test_PROXY_LC_pool_standalone_CRUD(self): |
| 83 |
self._test_pool_CRUD(listener_protocol=None, |
| 84 |
pool_protocol=const.PROXY, protocol_port=14, |
| 85 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 86 |
|
| 87 |
@decorators.idempotent_id('f1edfb45-a9d3-4150-8bc9-4fc3427c6346') |
| 88 |
def test_PROXY_LC_pool_with_listener_CRUD(self): |
| 89 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 90 |
pool_protocol=const.PROXY, protocol_port=15, |
| 91 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 92 |
|
| 93 |
@decorators.idempotent_id('d6d067c3-ec63-4b5d-a364-acc7493ae3b8') |
| 94 |
def test_TCP_LC_pool_standalone_CRUD(self): |
| 95 |
self._test_pool_CRUD(listener_protocol=None, |
| 96 |
pool_protocol=const.TCP, protocol_port=16, |
| 97 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 98 |
|
| 99 |
@decorators.idempotent_id('a159c345-9463-4c01-b571-086c789bd7d5') |
| 100 |
def test_TCP_LC_pool_with_listener_CRUD(self): |
| 101 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 102 |
pool_protocol=const.TCP, protocol_port=17, |
| 103 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 104 |
|
| 105 |
@decorators.idempotent_id('6fea6a39-19eb-4a0e-b507-82ecc57c1dc5') |
| 106 |
def test_UDP_LC_pool_standalone_CRUD(self): |
| 107 |
self._test_pool_CRUD(listener_protocol=None, |
| 108 |
pool_protocol=const.UDP, protocol_port=18, |
| 109 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 110 |
|
| 111 |
@decorators.idempotent_id('6ce12d8c-ad59-4e48-8de1-d26926735457') |
| 112 |
def test_UDP_LC_pool_with_listener_CRUD(self): |
| 113 |
self._test_pool_CRUD(listener_protocol=const.UDP, |
| 114 |
pool_protocol=const.UDP, protocol_port=19, |
| 115 |
algorithm=const.LB_ALGORITHM_LEAST_CONNECTIONS) |
| 116 |
|
| 117 |
|
| 118 |
@decorators.idempotent_id('dfa120bf-81b9-4f22-bb5e-7df660c18173') |
| 119 |
def test_HTTP_RR_pool_standalone_CRUD(self): |
| 120 |
self._test_pool_CRUD(listener_protocol=None, |
| 121 |
pool_protocol=const.HTTP, protocol_port=20, |
| 122 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 123 |
|
| 124 |
@decorators.idempotent_id('087da8ab-79c7-48ba-871c-5769185cea3e') |
| 125 |
def test_HTTP_RR_pool_with_listener_CRUD(self): |
| 126 |
self._test_pool_CRUD(listener_protocol=const.HTTP, |
| 127 |
pool_protocol=const.HTTP, protocol_port=21, |
| 128 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 129 |
|
| 130 |
@decorators.idempotent_id('6179a5d1-6425-4144-a437-b0d260b7b883') |
| 131 |
def test_HTTPS_RR_pool_standalone_CRUD(self): |
| 132 |
self._test_pool_CRUD(listener_protocol=None, |
| 133 |
pool_protocol=const.HTTPS, protocol_port=22, |
| 134 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 135 |
|
| 136 |
@decorators.idempotent_id('1b4585b4-c521-48e8-a69a-8a1d729a2949') |
| 137 |
def test_HTTPS_RR_pool_with_listener_CRUD(self): |
| 138 |
self._test_pool_CRUD(listener_protocol=const.HTTPS, |
| 139 |
pool_protocol=const.HTTPS, protocol_port=23, |
| 140 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 141 |
|
| 142 |
@decorators.idempotent_id('6b9f4f01-cb78-409a-b9fe-cbbeb27d0c5f') |
| 143 |
def test_PROXY_RR_pool_standalone_CRUD(self): |
| 144 |
self._test_pool_CRUD(listener_protocol=None, |
| 145 |
pool_protocol=const.PROXY, protocol_port=24, |
| 146 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 147 |
|
| 148 |
@decorators.idempotent_id('0228ea63-dff5-4dfb-b48a-193e8509caa8') |
| 149 |
def test_PROXY_RR_pool_with_listener_CRUD(self): |
| 150 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 151 |
pool_protocol=const.PROXY, protocol_port=25, |
| 152 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 153 |
|
| 154 |
@decorators.idempotent_id('71088923-cfdf-4821-a6a8-c7c9045b624d') |
| 155 |
def test_TCP_RR_pool_standalone_CRUD(self): |
| 156 |
self._test_pool_CRUD(listener_protocol=None, |
| 157 |
pool_protocol=const.TCP, protocol_port=26, |
| 158 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 159 |
|
| 160 |
@decorators.idempotent_id('4b663772-5c6b-49a3-b592-49d91bd71ff1') |
| 161 |
def test_TCP_RR_pool_with_listener_CRUD(self): |
| 162 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 163 |
pool_protocol=const.TCP, protocol_port=27, |
| 164 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 165 |
|
| 166 |
@decorators.idempotent_id('45aefaa0-c909-4861-91c6-517ea10285a5') |
| 167 |
def test_UDP_RR_pool_standalone_CRUD(self): |
| 168 |
self._test_pool_CRUD(listener_protocol=None, |
| 169 |
pool_protocol=const.UDP, protocol_port=28, |
| 170 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 171 |
|
| 172 |
@decorators.idempotent_id('cff21560-52be-439f-a41f-789d365db567') |
| 173 |
def test_UDP_RR_pool_with_listener_CRUD(self): |
| 174 |
self._test_pool_CRUD(listener_protocol=const.UDP, |
| 175 |
pool_protocol=const.UDP, protocol_port=29, |
| 176 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN) |
| 177 |
|
| 178 |
|
| 179 |
@decorators.idempotent_id('4ef47185-ef22-4396-8c9c-b98b9b476605') |
| 180 |
def test_HTTP_SI_pool_standalone_CRUD(self): |
| 181 |
self._test_pool_CRUD(listener_protocol=None, |
| 182 |
pool_protocol=const.HTTP, protocol_port=30, |
| 183 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 184 |
|
| 185 |
@decorators.idempotent_id('13a5caba-42a5-4b8c-a389-74d630a91687') |
| 186 |
def test_HTTP_SI_pool_with_listener_CRUD(self): |
| 187 |
self._test_pool_CRUD(listener_protocol=const.HTTP, |
| 188 |
pool_protocol=const.HTTP, protocol_port=31, |
| 189 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 190 |
|
| 191 |
@decorators.idempotent_id('5ff7732a-7481-4c03-8efc-5ee794feb11a') |
| 192 |
def test_HTTPS_SI_pool_standalone_CRUD(self): |
| 193 |
self._test_pool_CRUD(listener_protocol=None, |
| 194 |
pool_protocol=const.HTTPS, protocol_port=32, |
| 195 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 196 |
|
| 197 |
@decorators.idempotent_id('30f3d93c-cc22-4821-8805-d5c41023eccd') |
| 198 |
def test_HTTPS_SI_pool_with_listener_CRUD(self): |
| 199 |
self._test_pool_CRUD(listener_protocol=const.HTTPS, |
| 200 |
pool_protocol=const.HTTPS, protocol_port=33, |
| 201 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 202 |
|
| 203 |
@decorators.idempotent_id('7cbb01b8-196b-4ac3-9fec-a41abf867850') |
| 204 |
def test_PROXY_SI_pool_standalone_CRUD(self): |
| 205 |
self._test_pool_CRUD(listener_protocol=None, |
| 206 |
pool_protocol=const.PROXY, protocol_port=34, |
| 207 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 208 |
|
| 209 |
@decorators.idempotent_id('29327103-4949-4a77-a748-87ab725237b7') |
| 210 |
def test_PROXY_SI_pool_with_listener_CRUD(self): |
| 211 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 212 |
pool_protocol=const.PROXY, protocol_port=35, |
| 213 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 214 |
|
| 215 |
@decorators.idempotent_id('6a4dd425-d7d9-40dd-b451-feb4b3c551cc') |
| 216 |
def test_TCP_SI_pool_standalone_CRUD(self): |
| 217 |
self._test_pool_CRUD(listener_protocol=None, |
| 218 |
pool_protocol=const.TCP, protocol_port=36, |
| 219 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 220 |
|
| 221 |
@decorators.idempotent_id('4391d6a5-bb1c-4ff0-9f74-7b8c43a0b150') |
| 222 |
def test_TCP_SI_pool_with_listener_CRUD(self): |
| 223 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 224 |
pool_protocol=const.TCP, protocol_port=37, |
| 225 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 226 |
|
| 227 |
@decorators.idempotent_id('211a688c-f495-4f32-a297-c64d240b5de0') |
| 228 |
def test_UDP_SI_pool_standalone_CRUD(self): |
| 229 |
self._test_pool_CRUD(listener_protocol=None, |
| 230 |
pool_protocol=const.UDP, protocol_port=38, |
| 231 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 232 |
|
| 233 |
@decorators.idempotent_id('b19f1285-dbf2-4ac9-9199-3c3693148133') |
| 234 |
def test_UDP_SI_pool_with_listener_CRUD(self): |
| 235 |
self._test_pool_CRUD(listener_protocol=const.UDP, |
| 236 |
pool_protocol=const.UDP, protocol_port=39, |
| 237 |
algorithm=const.LB_ALGORITHM_SOURCE_IP) |
| 238 |
|
| 239 |
|
| 240 |
@decorators.idempotent_id('fee61d34-e272-42f5-92e2-69b515c6cded') |
| 241 |
def test_HTTP_SIP_pool_standalone_CRUD(self): |
| 242 |
self._test_pool_CRUD(listener_protocol=None, |
| 243 |
pool_protocol=const.HTTP, protocol_port=40, |
| 244 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 245 |
|
| 246 |
@decorators.idempotent_id('d99948da-649d-493c-a74d-72e532df0605') |
| 247 |
def test_HTTP_SIP_pool_with_listener_CRUD(self): |
| 248 |
self._test_pool_CRUD(listener_protocol=const.HTTP, |
| 249 |
pool_protocol=const.HTTP, protocol_port=41, |
| 250 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 251 |
|
| 252 |
@decorators.idempotent_id('b3c68f89-634e-4279-9546-9f2d2eac4bfa') |
| 253 |
def test_HTTPS_SIP_pool_standalone_CRUD(self): |
| 254 |
self._test_pool_CRUD(listener_protocol=None, |
| 255 |
pool_protocol=const.HTTPS, protocol_port=42, |
| 256 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 257 |
|
| 258 |
@decorators.idempotent_id('4327f636-50c3-411c-b90e-0b907bdaffc5') |
| 259 |
def test_HTTPS_SIP_pool_with_listener_CRUD(self): |
| 260 |
self._test_pool_CRUD(listener_protocol=const.HTTPS, |
| 261 |
pool_protocol=const.HTTPS, protocol_port=43, |
| 262 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 263 |
|
| 264 |
@decorators.idempotent_id('95a93e91-6ac0-40d5-999c-84a8b68c14f4') |
| 265 |
def test_PROXY_SIP_pool_standalone_CRUD(self): |
| 266 |
self._test_pool_CRUD(listener_protocol=None, |
| 267 |
pool_protocol=const.PROXY, protocol_port=44, |
| 268 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 269 |
|
| 270 |
@decorators.idempotent_id('13893ac9-150f-4605-be68-6bdf65e2bb12') |
| 271 |
def test_PROXY_SIP_pool_with_listener_CRUD(self): |
| 272 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 273 |
pool_protocol=const.PROXY, protocol_port=45, |
| 274 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 275 |
|
| 276 |
@decorators.idempotent_id('d045ea39-b6dd-4171-bb90-2b9970e25303') |
| 277 |
def test_TCP_SIP_pool_standalone_CRUD(self): |
| 278 |
self._test_pool_CRUD(listener_protocol=None, |
| 279 |
pool_protocol=const.TCP, protocol_port=46, |
| 280 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 281 |
|
| 282 |
@decorators.idempotent_id('ec22ab54-8e0a-4472-8f70-78c34f28dc36') |
| 283 |
def test_TCP_SIP_pool_with_listener_CRUD(self): |
| 284 |
self._test_pool_CRUD(listener_protocol=const.TCP, |
| 285 |
pool_protocol=const.TCP, protocol_port=47, |
| 286 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 287 |
|
| 288 |
@decorators.idempotent_id('0e0f0299-8c5e-4d7c-a99e-85db43b45446') |
| 289 |
def test_UDP_SIP_pool_standalone_CRUD(self): |
| 290 |
self._test_pool_CRUD(listener_protocol=None, |
| 291 |
pool_protocol=const.UDP, protocol_port=48, |
| 292 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 293 |
|
| 294 |
@decorators.idempotent_id('66d50010-13ca-4588-ae36-61bb783d556e') |
| 295 |
def test_UDP_SIP_pool_with_listener_CRUD(self): |
| 296 |
self._test_pool_CRUD(listener_protocol=const.UDP, |
| 297 |
pool_protocol=const.UDP, protocol_port=49, |
| 298 |
algorithm=const.LB_ALGORITHM_SOURCE_IP_PORT) |
| 299 |
|
| 300 |
|
| 301 |
@decorators.idempotent_id('d6b8119b-40e9-487d-a037-9972a1e688e8') |
| 302 |
def test_HTTP_RR_app_cookie_pool_with_listener_CRUD(self): |
| 303 |
self._test_pool_CRUD( |
| 304 |
listener_protocol=const.HTTP, |
| 305 |
pool_protocol=const.HTTP, protocol_port=50, |
| 306 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 307 |
session_persistence=const.SESSION_PERSISTENCE_APP_COOKIE) |
| 308 |
|
| 309 |
@decorators.idempotent_id('a67f2276-6469-48d4-bf7e-ddf6d8694dba') |
| 310 |
def test_HTTP_RR_http_cookie_pool_with_listener_CRUD(self): |
| 311 |
self._test_pool_CRUD( |
| 312 |
listener_protocol=const.HTTP, |
| 313 |
pool_protocol=const.HTTP, protocol_port=51, |
| 314 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 315 |
session_persistence=const.SESSION_PERSISTENCE_HTTP_COOKIE) |
| 316 |
|
| 317 |
@decorators.idempotent_id('c248e3d8-43d9-4fd4-93af-845747c9b939') |
| 318 |
def test_HTTP_RR_source_IP_pool_with_listener_CRUD(self): |
| 319 |
self._test_pool_CRUD( |
| 320 |
listener_protocol=const.HTTP, |
| 321 |
pool_protocol=const.HTTP, protocol_port=52, |
| 322 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 323 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 324 |
|
| 325 |
@decorators.idempotent_id('dc7f0ed5-f94c-4498-9dca-5dbc08e7162f') |
| 326 |
def test_UDP_RR_source_ip_pool_with_listener_CRUD(self): |
| 327 |
self._test_pool_CRUD( |
| 328 |
listener_protocol=const.UDP, |
| 329 |
pool_protocol=const.UDP, protocol_port=53, |
| 330 |
algorithm=const.LB_ALGORITHM_ROUND_ROBIN, |
| 331 |
session_persistence=const.SESSION_PERSISTENCE_SOURCE_IP) |
| 332 |
|
| 333 |
def _test_pool_CRUD(self, listener_protocol, pool_protocol, protocol_port, |
| 334 |
algorithm, session_persistence=None): |
| 335 |
"""Tests pool create, read, update, delete |
| 336 |
|
| 337 |
* Create a fully populated pool. |
| 338 |
* Show pool details. |
| 339 |
* Update the pool. |
| 340 |
* Delete the pool. |
| 341 |
""" |
| 342 |
if (algorithm == const.LB_ALGORITHM_SOURCE_IP_PORT and not |
| 343 |
self.mem_listener_client.is_version_supported( |
| 344 |
self.api_version, '2.13')): |
| 345 |
raise testtools.TestCase.skipException( |
| 346 |
'Skipping this test as load balancing algorithm ' |
| 347 |
'SOURCE_IP_PORT requires API version 2.13 or newer.') |
| 348 |
|
| 349 |
|
| 350 |
if listener_protocol is not None: |
| 351 |
listener_name = data_utils.rand_name("lb_member_listener1_pool") |
| 352 |
listener_kwargs = { |
| 353 |
const.NAME: listener_name, |
| 354 |
const.PROTOCOL: listener_protocol, |
| 355 |
const.PROTOCOL_PORT: protocol_port, |
| 356 |
const.LOADBALANCER_ID: self.lb_id, |
| 357 |
} |
| 358 |
listener = self.mem_listener_client.create_listener( |
| 359 |
**listener_kwargs) |
| 360 |
listener_id = listener[const.ID] |
| 361 |
|
| 362 |
self.addCleanup( |
| 363 |
self.mem_listener_client.cleanup_listener, |
| 364 |
listener_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 |
|
| 374 |
pool_name = data_utils.rand_name("lb_member_pool1-CRUD") |
| 375 |
pool_description = data_utils.arbitrary_string(size=255) |
| 376 |
pool_sp_cookie_name = 'my_cookie' |
| 377 |
pool_kwargs = { |
| 378 |
const.NAME: pool_name, |
| 379 |
const.DESCRIPTION: pool_description, |
| 380 |
const.ADMIN_STATE_UP: False, |
| 381 |
const.PROTOCOL: pool_protocol, |
| 382 |
const.LB_ALGORITHM: algorithm, |
| 383 |
} |
| 384 |
|
| 385 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 386 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 387 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 388 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 389 |
} |
| 390 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 391 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 392 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 393 |
} |
| 394 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 395 |
pool_kwargs[const.SESSION_PERSISTENCE] = { |
| 396 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 397 |
} |
| 398 |
|
| 399 |
if listener_protocol is not None: |
| 400 |
pool_kwargs[const.LISTENER_ID] = listener_id |
| 401 |
else: |
| 402 |
pool_kwargs[const.LOADBALANCER_ID] = self.lb_id |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
try: |
| 408 |
pool = self.mem_pool_client.create_pool(**pool_kwargs) |
| 409 |
except exceptions.NotImplemented as e: |
| 410 |
if algorithm != const.LB_ALGORITHM_SOURCE_IP_PORT: |
| 411 |
raise |
| 412 |
message = ("The configured provider driver '{driver}' " |
| 413 |
"does not support a feature required for this " |
| 414 |
"test.".format(driver=CONF.load_balancer.provider)) |
| 415 |
if hasattr(e, 'resp_body'): |
| 416 |
message = e.resp_body.get('faultstring', message) |
| 417 |
raise testtools.TestCase.skipException(message) |
| 418 |
|
| 419 |
self.addCleanup( |
| 420 |
self.mem_pool_client.cleanup_pool, |
| 421 |
pool[const.ID], |
| 422 |
lb_client=self.mem_lb_client, lb_id=self.lb_id) |
| 423 |
|
| 424 |
waiters.wait_for_status( |
| 425 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 426 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 427 |
CONF.load_balancer.build_interval, |
| 428 |
CONF.load_balancer.build_timeout) |
| 429 |
pool = waiters.wait_for_status( |
| 430 |
self.mem_pool_client.show_pool, |
| 431 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 432 |
const.ACTIVE, |
| 433 |
CONF.load_balancer.build_interval, |
| 434 |
CONF.load_balancer.build_timeout) |
| 435 |
|
| 436 |
self.assertEqual(pool_name, pool[const.NAME]) |
| 437 |
self.assertEqual(pool_description, pool[const.DESCRIPTION]) |
| 438 |
self.assertFalse(pool[const.ADMIN_STATE_UP]) |
| 439 |
parser.parse(pool[const.CREATED_AT]) |
| 440 |
parser.parse(pool[const.UPDATED_AT]) |
| 441 |
UUID(pool[const.ID]) |
| 442 |
self.assertEqual(pool_protocol, pool[const.PROTOCOL]) |
| 443 |
self.assertEqual(1, len(pool[const.LOADBALANCERS])) |
| 444 |
self.assertEqual(self.lb_id, pool[const.LOADBALANCERS][0][const.ID]) |
| 445 |
if listener_protocol is not None: |
| 446 |
self.assertEqual(1, len(pool[const.LISTENERS])) |
| 447 |
self.assertEqual(listener_id, pool[const.LISTENERS][0][const.ID]) |
| 448 |
else: |
| 449 |
self.assertEmpty(pool[const.LISTENERS]) |
| 450 |
self.assertEqual(const.OFFLINE, pool[const.OPERATING_STATUS]) |
| 451 |
self.assertEqual(algorithm, pool[const.LB_ALGORITHM]) |
| 452 |
|
| 453 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 454 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 455 |
self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE, |
| 456 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 457 |
self.assertEqual(pool_sp_cookie_name, |
| 458 |
pool[const.SESSION_PERSISTENCE][ |
| 459 |
const.COOKIE_NAME]) |
| 460 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 461 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 462 |
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE, |
| 463 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 464 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 465 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 466 |
self.assertEqual(const.SESSION_PERSISTENCE_SOURCE_IP, |
| 467 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 468 |
|
| 469 |
|
| 470 |
new_name = data_utils.rand_name("lb_member_pool1-update") |
| 471 |
new_description = data_utils.arbitrary_string(size=255, |
| 472 |
base_text='new') |
| 473 |
pool_update_kwargs = { |
| 474 |
const.NAME: new_name, |
| 475 |
const.DESCRIPTION: new_description, |
| 476 |
const.ADMIN_STATE_UP: True, |
| 477 |
} |
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
pool_update_kwargs[const.LB_ALGORITHM] = algorithm |
| 482 |
|
| 483 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 484 |
pool_update_kwargs[const.SESSION_PERSISTENCE] = { |
| 485 |
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE |
| 486 |
} |
| 487 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 488 |
pool_update_kwargs[const.SESSION_PERSISTENCE] = { |
| 489 |
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE, |
| 490 |
const.COOKIE_NAME: pool_sp_cookie_name |
| 491 |
} |
| 492 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 493 |
|
| 494 |
|
| 495 |
pool_update_kwargs[const.SESSION_PERSISTENCE] = { |
| 496 |
const.TYPE: const.SESSION_PERSISTENCE_SOURCE_IP |
| 497 |
} |
| 498 |
|
| 499 |
pool = self.mem_pool_client.update_pool( |
| 500 |
pool[const.ID], **pool_update_kwargs) |
| 501 |
|
| 502 |
waiters.wait_for_status( |
| 503 |
self.mem_lb_client.show_loadbalancer, self.lb_id, |
| 504 |
const.PROVISIONING_STATUS, const.ACTIVE, |
| 505 |
CONF.load_balancer.build_interval, |
| 506 |
CONF.load_balancer.build_timeout) |
| 507 |
pool = waiters.wait_for_status( |
| 508 |
self.mem_pool_client.show_pool, |
| 509 |
pool[const.ID], const.PROVISIONING_STATUS, |
| 510 |
const.ACTIVE, |
| 511 |
CONF.load_balancer.build_interval, |
| 512 |
CONF.load_balancer.build_timeout) |
| 513 |
|
| 514 |
self.assertEqual(new_name, pool[const.NAME]) |
| 515 |
self.assertEqual(new_description, pool[const.DESCRIPTION]) |
| 516 |
self.assertTrue(pool[const.ADMIN_STATE_UP]) |
| 517 |
self.assertEqual(algorithm, pool[const.LB_ALGORITHM]) |
| 518 |
if listener_protocol is not None: |
| 519 |
pool = waiters.wait_for_status( |
| 520 |
self.mem_pool_client.show_pool, |
| 521 |
pool[const.ID], const.OPERATING_STATUS, |
| 522 |
const.ONLINE, |
| 523 |
CONF.load_balancer.build_interval, |
| 524 |
CONF.load_balancer.build_timeout) |
| 525 |
|
| 526 |
if session_persistence == const.SESSION_PERSISTENCE_APP_COOKIE: |
| 527 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 528 |
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE, |
| 529 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 530 |
self.assertIsNone( |
| 531 |
pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME)) |
| 532 |
elif session_persistence == const.SESSION_PERSISTENCE_HTTP_COOKIE: |
| 533 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 534 |
self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE, |
| 535 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 536 |
self.assertEqual(pool_sp_cookie_name, |
| 537 |
pool[const.SESSION_PERSISTENCE][ |
| 538 |
const.COOKIE_NAME]) |
| 539 |
elif session_persistence == const.SESSION_PERSISTENCE_SOURCE_IP: |
| 540 |
self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE)) |
| 541 |
self.assertEqual(const.SESSION_PERSISTENCE_SOURCE_IP, |
| 542 |
pool[const.SESSION_PERSISTENCE][const.TYPE]) |
| 543 |
self.assertIsNone( |
| 544 |
pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME)) |
| 545 |
|
| 546 |
|
| 547 |
waiters.wait_for_status( |
| 548 |
self.mem_lb_client.show_loadbalancer, |
| 549 |
self.lb_id, const.PROVISIONING_STATUS, |
| 550 |
const.ACTIVE, |
| 551 |
CONF.load_balancer.check_interval, |
| 552 |
CONF.load_balancer.check_timeout) |
| 553 |
|
| 554 |
self.mem_pool_client.delete_pool(pool[const.ID]) |
| 555 |
|
| 556 |
waiters.wait_for_deleted_status_or_not_found( |
| 557 |
self.mem_pool_client.show_pool, pool[const.ID], |
| 558 |
const.PROVISIONING_STATUS, |
| 559 |
CONF.load_balancer.check_interval, |
| 560 |
CONF.load_balancer.check_timeout) |
| 561 |
|
| 562 |
waiters.wait_for_status( |
| 563 |
self.mem_lb_client.show_loadbalancer, |
| 564 |
self.lb_id, const.PROVISIONING_STATUS, |
| 565 |
const.ACTIVE, |
| 566 |
CONF.load_balancer.check_interval, |
| 567 |
CONF.load_balancer.check_timeout) |