/usr/lib/python2.7/dist-packages/neutron_lbaas/tests/tempest/v2/api/test_health_monitors_non_admin.py is in python-neutron-lbaas 2:8.0.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 | # Copyright 2015, 2016 Rackspace
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as ex
from tempest import test
from neutron_lbaas.tests.tempest.v2.api import base
class TestHealthMonitors(base.BaseTestCase):
"""
Tests the following operations in the Neutron-LBaaS API using the
REST client for Health Monitors:
list pools
create pool
get pool
update pool
delete pool
"""
@classmethod
def resource_setup(cls):
super(TestHealthMonitors, cls).resource_setup()
if not test.is_extension_enabled('lbaas', 'network'):
msg = "lbaas extension not enabled."
raise cls.skipException(msg)
network_name = data_utils.rand_name('network-')
cls.network = cls.create_network(network_name)
cls.subnet = cls.create_subnet(cls.network)
cls.load_balancer = cls._create_load_balancer(
tenant_id=cls.subnet.get('tenant_id'),
vip_subnet_id=cls.subnet.get('id'))
cls.listener = cls._create_listener(
loadbalancer_id=cls.load_balancer.get('id'),
protocol='HTTP', protocol_port=80)
cls.pool = cls._create_pool(
protocol='HTTP', lb_algorithm='ROUND_ROBIN',
listener_id=cls.listener.get('id'))
cls.create_basic_hm_kwargs = {'type': 'HTTP', 'delay': 3,
'max_retries': 10, 'timeout': 5,
'pool_id': cls.pool.get('id')}
@test.attr(type='smoke')
def test_list_health_monitors_empty(self):
hm_list = self.health_monitors_client.list_health_monitors()
self.assertEmpty(hm_list)
@test.attr(type='smoke')
def test_list_health_monitors_one(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm_list = self.health_monitors_client.list_health_monitors()
self.assertIn(hm, hm_list)
@test.attr(type='smoke')
def test_list_health_monitors_two(self):
hm1 = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_listener = self._create_listener(
loadbalancer_id=self.load_balancer.get('id'),
protocol='HTTP', protocol_port=88)
self.addCleanup(self._delete_listener, new_listener.get('id'))
new_pool = self._create_pool(
protocol='HTTP', lb_algorithm='ROUND_ROBIN',
listener_id=new_listener.get('id'))
self.addCleanup(self._delete_pool, new_pool.get('id'))
hm2 = self._create_health_monitor(
type='HTTPS',
max_retries=3,
delay=1,
timeout=2,
pool_id=new_pool.get('id'))
hm_list = self.health_monitors_client.list_health_monitors()
self.assertEqual(2, len(hm_list))
self.assertIn(hm1, hm_list)
self.assertIn(hm2, hm_list)
@test.attr(type='smoke')
def test_get_health_monitor(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm_test = self.health_monitors_client.get_health_monitor(hm.get('id'))
self.assertEqual(hm, hm_test)
@test.attr(type='smoke')
def test_create_health_monitor(self):
new_hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm = self.health_monitors_client.get_health_monitor(new_hm.get('id'))
self.assertEqual(new_hm, hm)
@test.attr(type='smoke')
def test_create_health_monitor_missing_attribute(self):
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10,
pool_id=self.pool.get('id'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_required_field_type(self):
"""Test if a non_admin user can create a health monitor with type
missing
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_required_field_delay(self):
"""Test if a non_admin user can create a health monitor with delay
missing
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_required_field_timeout(self):
"""Test if a non_admin user can create a health monitor with timeout
missing
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10,
pool_id=self.pool.get('id'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_required_field_max_retries(self):
"""Test if a non_admin user can create a health monitor with max_retries
missing
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_required_field_pool_id(self):
"""Test if a non_admin user can create a health monitor with pool_id
missing
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5)
@test.attr(type='smoke')
def test_create_health_monitor_missing_admin_state_up(self):
"""Test if a non_admin user can create a health monitor with
admin_state_up missing
"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm_test = self.health_monitors_client.get_health_monitor(hm.get('id'))
self.assertEqual(hm, hm_test)
self.assertTrue(hm_test.get('admin_state_up'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_http_method(self):
"""Test if a non_admin user can create a health monitor with
http_method missing
"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm_test = self.health_monitors_client.get_health_monitor(hm.get('id'))
self.assertEqual(hm, hm_test)
self.assertEqual('GET', hm_test.get('http_method'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_url_path(self):
"""Test if a non_admin user can create a health monitor with
url_path missing
"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm_test = self.health_monitors_client.get_health_monitor(hm.get('id'))
self.assertEqual(hm, hm_test)
self.assertEqual('/', hm_test.get('url_path'))
@test.attr(type='smoke')
def test_create_health_monitor_missing_expected_codes(self):
"""Test if a non_admin user can create a health monitor with
expected_codes missing
"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
hm_test = self.health_monitors_client.get_health_monitor(hm.get('id'))
self.assertEqual(hm, hm_test)
self.assertEqual('200', hm_test.get('expected_codes'))
@test.attr(type='negative')
def test_create_health_monitor_invalid_tenant_id(self):
"""Test create health monitor with invalid tenant_id"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
tenant_id='blah',
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_invalid_type(self):
"""Test create health monitor with invalid type"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='blah', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_invalid_delay(self):
"""Test create health monitor with invalid delay"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay='blah', max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_invalid_max_retries(self):
"""Test create health monitor with invalid max_retries"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries='blah', timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_invalid_timeout(self):
"""Test create health monitor with invalid timeout"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout='blah',
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_invalid_pool_id(self):
"""Test create health monitor with invalid pool id"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id='blah')
@test.attr(type='negative')
def test_create_health_monitor_invalid_admin_state_up(self):
"""Test if a non_admin user can create a health monitor with invalid
admin_state_up
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), admin_state_up='blah'
)
@test.attr(type='negative')
def test_create_health_monitor_invalid_expected_codes(self):
"""Test if a non_admin user can create a health monitor with invalid
expected_codes
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), expected_codes='blah'
)
@test.attr(type='negative')
def test_create_health_monitor_invalid_url_path(self):
"""Test if a non_admin user can create a health monitor with invalid
url_path
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), url_path='blah'
)
@test.attr(type='negative')
def test_create_health_monitor_invalid_http_method(self):
"""Test if a non_admin user can create a health monitor with invalid
http_method
"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), http_method='blah')
@test.attr(type='negative')
def test_create_health_monitor_empty_type(self):
"""Test create health monitor with empty type"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_empty_delay(self):
"""Test create health monitor with empty delay"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay='', max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_empty_timeout(self):
"""Test create health monitor with empty timeout"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout='',
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_empty_max_retries(self):
"""Test create health monitor with empty max_retries"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries='', timeout=5,
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_empty_max_pool_id(self):
"""Test create health monitor with empty pool_id"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id='')
@test.attr(type='negative')
def test_create_health_monitor_empty_max_admin_state_up(self):
"""Test create health monitor with empty admin_state_up"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), admin_state_up='')
@test.attr(type='negative')
def test_create_health_monitor_empty_max_http_method(self):
"""Test create health monitor with empty http_method"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), http_method='')
@test.attr(type='negative')
def test_create_health_monitor_empty_max_url_path(self):
"""Test create health monitor with empty url_path"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), url_path='')
@test.attr(type='negative')
def test_create_health_monitor_empty_expected_codes(self):
"""Test create health monitor with empty expected_codes"""
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10, timeout=5,
pool_id=self.pool.get('id'), expected_codes='')
@test.attr(type='negative')
def test_create_health_monitor_invalid_attribute(self):
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries='twenty one',
pool_id=self.pool.get('id'))
@test.attr(type='negative')
def test_create_health_monitor_extra_attribute(self):
self.assertRaises(ex.BadRequest, self._create_health_monitor,
type='HTTP', delay=3, max_retries=10,
pool_id=self.pool.get('id'), subnet_id=10)
@test.attr(type='smoke')
def test_update_health_monitor(self):
hm = self._create_health_monitor(type='HTTP', delay=3, max_retries=10,
timeout=5,
pool_id=self.pool.get('id'))
max_retries = 1
new_hm = self._update_health_monitor(
hm.get('id'), max_retries=max_retries)
self.assertEqual(max_retries, new_hm.get('max_retries'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_admin_state_up(self):
"""Test update health monitor with missing admin state field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertTrue(new_hm.get('admin_state_up'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_delay(self):
"""Test update health monitor with missing delay field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertEqual(hm.get('delay'), new_hm.get('delay'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_timeout(self):
"""Test update health monitor with missing timeout field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertEqual(hm.get('timeout'), new_hm.get('timeout'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_max_retries(self):
"""Test update health monitor with missing max retries field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertEqual(hm.get('max_retries'), new_hm.get('max_retries'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_http_method(self):
"""Test update health monitor with missing http_method field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertEqual(hm.get('http_method'), new_hm.get('http_method'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_url_path(self):
"""Test update health monitor with missing url_path field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertEqual(hm.get('url_path'), new_hm.get('url_path'))
@test.attr(type='smoke')
def test_update_health_monitor_missing_expected_codes(self):
"""Test update health monitor with missing expected_codes field"""
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
new_hm = self._update_health_monitor(hm.get('id'))
self.assertEqual(hm.get('expected_codes'),
new_hm.get('expected_codes'))
@test.attr(type='negative')
def test_update_health_monitor_invalid_attribute(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), max_retries='blue')
@test.attr(type='negative')
def test_update_health_monitor_invalid_admin_state_up(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), admin_state_up='blah')
@test.attr(type='negative')
def test_update_health_monitor_invalid_delay(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), delay='blah')
@test.attr(type='negative')
def test_update_health_monitor_invalid_timeout(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), timeout='blah')
@test.attr(type='negative')
def test_update_health_monitor_invalid_max_retries(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), max_retries='blah')
@test.attr(type='negative')
def test_update_health_monitor_invalid_http_method(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), http_method='blah')
@test.attr(type='negative')
def test_update_health_monitor_invalid_url_path(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), url_path='blah')
@test.attr(type='negative')
def test_update_health_monitor_invalid_expected_codes(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), expected_codes='blah')
@test.attr(type='negative')
def test_update_health_monitor_empty_admin_state_up(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), admin_state_up='')
@test.attr(type='negative')
def test_update_health_monitor_empty_delay(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), empty_delay='')
@test.attr(type='negative')
def test_update_health_monitor_empty_timeout(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), timeout='')
@test.attr(type='negative')
def test_update_health_monitor_empty_max_retries(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), max_retries='')
@test.attr(type='negative')
def test_update_health_monitor_empty_empty_http_method(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), http_method='')
@test.attr(type='negative')
def test_update_health_monitor_empty_url_path(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), http_method='')
@test.attr(type='negative')
def test_update_health_monitor_empty_expected_codes(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), expected_codes='')
@test.attr(type='smoke')
def test_update_health_monitor_extra_attribute(self):
hm = self._create_health_monitor(**self.create_basic_hm_kwargs)
self.assertRaises(ex.BadRequest,
self._update_health_monitor,
hm.get('id'), protocol='UDP')
@test.attr(type='smoke')
def test_delete_health_monitor(self):
hm = self._create_health_monitor(cleanup=False, type='HTTP', delay=3,
max_retries=10, timeout=5,
pool_id=self.pool.get('id'))
self._delete_health_monitor(hm.get('id'))
self.assertRaises(ex.NotFound,
self.health_monitors_client.get_health_monitor,
hm.get('id'))
|