Browse Source

Merge "When session_persistence type NONE set option None"

master
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
765bb04d83
2 changed files with 37 additions and 0 deletions
  1. +3
    -0
      senlin/drivers/os/octavia_v2.py
  2. +34
    -0
      senlin/tests/unit/drivers/test_octavia_v2.py

+ 3
- 0
senlin/drivers/os/octavia_v2.py View File

@ -104,6 +104,9 @@ class OctaviaClient(base.DriverBase):
# Remove cookie_name when type not equal to APP_COOKIE
if session_persistence['type'] != 'APP_COOKIE':
session_persistence.pop('cookie_name', None)
# When type=NONE set session_persistence to None
if session_persistence['type'] == 'NONE':
session_persistence = None
kwargs = {
'lb_algorithm': lb_algorithm,


+ 34
- 0
senlin/tests/unit/drivers/test_octavia_v2.py View File

@ -196,6 +196,40 @@ class TestOctaviaV2Driver(base.SenlinTestCase):
session_persistence=session_persistence_app_cookie,
**kwargs)
def test_pool_create_type_none(self):
lb_algorithm = 'ROUND_ROBIN'
listener_id = 'ID1'
protocol = 'HTTP'
session_persistence = {
'type': 'NONE',
'cookie_name': 'whatever',
}
session_persistence_expected = session_persistence.copy()
session_persistence_expected.pop('cookie_name', None)
pool_obj = mock.Mock()
# All input parameters are provided
kwargs = {
'admin_state_up': True,
'name': 'test-pool',
'description': 'This is a pool',
}
self.conn.load_balancer.create_pool.return_value = pool_obj
# when type=NONE set session_persistence_type_none to None
session_persistence_expected = None
self.assertEqual(pool_obj, self.oc.pool_create(
lb_algorithm, listener_id, protocol,
session_persistence, **kwargs))
# cookie_name is not removed
self.conn.load_balancer.create_pool.assert_called_once_with(
lb_algorithm=lb_algorithm, listener_id=listener_id,
protocol=protocol,
session_persistence=session_persistence_expected,
**kwargs)
def test_pool_delete(self):
pool_id = 'ID1'


Loading…
Cancel
Save