Support skipping APP_COOKIE and HTTP_COOKIE
Not all provider drivers may support APP_COOKIE/HTTP_COOKIE,
so this patch modifies the test to reflect the same.
Change-Id: Ifea51c1f927947588ac2ed82f25fa35ee56c98f7
diff --git a/octavia_tempest_plugin/config.py b/octavia_tempest_plugin/config.py
index 11dc59f..ffc60ca 100644
--- a/octavia_tempest_plugin/config.py
+++ b/octavia_tempest_plugin/config.py
@@ -196,4 +196,8 @@
default=False,
help="Wether spare pool is available with amphora provider "
"driver or not."),
+ cfg.BoolOpt('session_persistence_enabled',
+ default=True,
+ help="Whether session persistence is supported with the "
+ "provider driver."),
]
diff --git a/octavia_tempest_plugin/tests/api/v2/test_pool.py b/octavia_tempest_plugin/tests/api/v2/test_pool.py
index a63bddb..8273b48 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_pool.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_pool.py
@@ -41,9 +41,9 @@
const.NAME: lb_name}
cls._setup_lb_network_kwargs(lb_kwargs)
cls.protocol = const.HTTP
- lb_feature_enabled = CONF.loadbalancer_feature_enabled
- if not lb_feature_enabled.l7_protocol_enabled:
- cls.protocol = lb_feature_enabled.l4_protocol
+ cls.lb_feature_enabled = CONF.loadbalancer_feature_enabled
+ if not cls.lb_feature_enabled.l7_protocol_enabled:
+ cls.protocol = cls.lb_feature_enabled.l4_protocol
lb = cls.mem_lb_client.create_loadbalancer(**lb_kwargs)
cls.lb_id = lb[const.ID]
@@ -103,11 +103,13 @@
const.ADMIN_STATE_UP: True,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
+ }
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_kwargs[const.SESSION_PERSISTENCE] = {
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
const.COOKIE_NAME: pool_sp_cookie_name,
- },
- }
+ }
+
if has_listener:
pool_kwargs[const.LISTENER_ID] = self.listener_id
else:
@@ -170,11 +172,13 @@
self.assertEmpty(pool[const.LISTENERS])
self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
pool[const.LB_ALGORITHM])
- self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
- self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
- pool[const.SESSION_PERSISTENCE][const.TYPE])
- self.assertEqual(pool_sp_cookie_name,
- pool[const.SESSION_PERSISTENCE][const.COOKIE_NAME])
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
+ self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
+ pool[const.SESSION_PERSISTENCE][const.TYPE])
+ self.assertEqual(pool_sp_cookie_name,
+ pool[const.SESSION_PERSISTENCE][
+ const.COOKIE_NAME])
@decorators.idempotent_id('6959a32e-fb34-4f3e-be68-8880c6450016')
def test_pool_list(self):
@@ -216,12 +220,13 @@
const.ADMIN_STATE_UP: True,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
- const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
- const.COOKIE_NAME: pool1_sp_cookie_name,
- },
const.LOADBALANCER_ID: lb_id,
}
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool1_kwargs[const.SESSION_PERSISTENCE] = {
+ const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
+ const.COOKIE_NAME: pool1_sp_cookie_name,
+ }
pool1 = self.mem_pool_client.create_pool(
**pool1_kwargs)
self.addCleanup(
@@ -253,12 +258,13 @@
const.ADMIN_STATE_UP: True,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
- const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
- const.COOKIE_NAME: pool2_sp_cookie_name,
- },
const.LOADBALANCER_ID: lb_id,
}
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool2_kwargs[const.SESSION_PERSISTENCE] = {
+ const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
+ const.COOKIE_NAME: pool2_sp_cookie_name,
+ }
pool2 = self.mem_pool_client.create_pool(
**pool2_kwargs)
self.addCleanup(
@@ -430,12 +436,13 @@
const.ADMIN_STATE_UP: True,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
- const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
- const.COOKIE_NAME: pool_sp_cookie_name,
- },
const.LOADBALANCER_ID: self.lb_id,
}
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_kwargs[const.SESSION_PERSISTENCE] = {
+ const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
+ const.COOKIE_NAME: pool_sp_cookie_name,
+ }
pool = self.mem_pool_client.create_pool(**pool_kwargs)
self.addClassResourceCleanup(
@@ -469,11 +476,13 @@
self.assertEmpty(pool[const.LISTENERS])
self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
pool[const.LB_ALGORITHM])
- self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
- self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
- pool[const.SESSION_PERSISTENCE][const.TYPE])
- self.assertEqual(pool_sp_cookie_name,
- pool[const.SESSION_PERSISTENCE][const.COOKIE_NAME])
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
+ self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
+ pool[const.SESSION_PERSISTENCE][const.TYPE])
+ self.assertEqual(pool_sp_cookie_name,
+ pool[const.SESSION_PERSISTENCE][
+ const.COOKIE_NAME])
# Test that a user with lb_admin role can see the pool
if CONF.load_balancer.RBAC_test_type == const.ADVANCED:
@@ -524,13 +533,13 @@
const.ADMIN_STATE_UP: False,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
- const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
- const.COOKIE_NAME: pool_sp_cookie_name,
- },
const.LOADBALANCER_ID: self.lb_id,
}
-
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_kwargs[const.SESSION_PERSISTENCE] = {
+ const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
+ const.COOKIE_NAME: pool_sp_cookie_name,
+ }
pool = self.mem_pool_client.create_pool(**pool_kwargs)
self.addClassResourceCleanup(
self.mem_pool_client.cleanup_pool,
@@ -563,11 +572,13 @@
self.assertEmpty(pool[const.LISTENERS])
self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
pool[const.LB_ALGORITHM])
- self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
- self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
- pool[const.SESSION_PERSISTENCE][const.TYPE])
- self.assertEqual(pool_sp_cookie_name,
- pool[const.SESSION_PERSISTENCE][const.COOKIE_NAME])
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
+ self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
+ pool[const.SESSION_PERSISTENCE][const.TYPE])
+ self.assertEqual(pool_sp_cookie_name,
+ pool[const.SESSION_PERSISTENCE][
+ const.COOKIE_NAME])
# Test that a user, without the load balancer member role, cannot
# use this command
@@ -607,10 +618,11 @@
const.DESCRIPTION: new_description,
const.ADMIN_STATE_UP: True,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
- const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE,
- },
}
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_update_kwargs[const.SESSION_PERSISTENCE] = {
+ const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE,
+ }
pool = self.mem_pool_client.update_pool(
pool[const.ID], **pool_update_kwargs)
@@ -631,16 +643,18 @@
self.assertTrue(pool[const.ADMIN_STATE_UP])
self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
pool[const.LB_ALGORITHM])
- self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
- self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE,
- pool[const.SESSION_PERSISTENCE][const.TYPE])
- self.assertIsNone(
- pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME))
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
+ self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE,
+ pool[const.SESSION_PERSISTENCE][const.TYPE])
+ self.assertIsNone(
+ pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME))
# Also test removing a Session Persistence
- pool_update_kwargs = {
- const.SESSION_PERSISTENCE: None,
- }
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_update_kwargs = {
+ const.SESSION_PERSISTENCE: None,
+ }
pool = self.mem_pool_client.update_pool(
pool[const.ID], **pool_update_kwargs)
@@ -655,7 +669,8 @@
const.ACTIVE,
CONF.load_balancer.build_interval,
CONF.load_balancer.build_timeout)
- self.assertIsNone(pool.get(const.SESSION_PERSISTENCE))
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNone(pool.get(const.SESSION_PERSISTENCE))
@decorators.idempotent_id('35ed3800-7a4a-47a6-9b94-c1033fff1112')
def test_pool_delete(self):
@@ -672,12 +687,13 @@
const.NAME: pool_name,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
- const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
- const.COOKIE_NAME: pool_sp_cookie_name,
- },
const.LOADBALANCER_ID: self.lb_id,
}
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_kwargs[const.SESSION_PERSISTENCE] = {
+ const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
+ const.COOKIE_NAME: pool_sp_cookie_name,
+ }
pool = self.mem_pool_client.create_pool(**pool_kwargs)
self.addClassResourceCleanup(
self.mem_pool_client.cleanup_pool,
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_pool.py b/octavia_tempest_plugin/tests/scenario/v2/test_pool.py
index d1090c7..e6cd8c1 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_pool.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_pool.py
@@ -101,11 +101,12 @@
const.ADMIN_STATE_UP: False,
const.PROTOCOL: self.protocol,
const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
- const.SESSION_PERSISTENCE: {
+ }
+ if self.lb_feature_enabled.session_persistence_enabled:
+ pool_kwargs[const.SESSION_PERSISTENCE] = {
const.TYPE: const.SESSION_PERSISTENCE_APP_COOKIE,
const.COOKIE_NAME: pool_sp_cookie_name,
- },
- }
+ }
if has_listener:
pool_kwargs[const.LISTENER_ID] = self.listener_id
else:
@@ -147,11 +148,13 @@
self.assertEmpty(pool[const.LISTENERS])
self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
pool[const.LB_ALGORITHM])
- self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
- self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
- pool[const.SESSION_PERSISTENCE][const.TYPE])
- self.assertEqual(pool_sp_cookie_name,
- pool[const.SESSION_PERSISTENCE][const.COOKIE_NAME])
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
+ self.assertEqual(const.SESSION_PERSISTENCE_APP_COOKIE,
+ pool[const.SESSION_PERSISTENCE][const.TYPE])
+ self.assertEqual(pool_sp_cookie_name,
+ pool[const.SESSION_PERSISTENCE][
+ const.COOKIE_NAME])
# Pool update
new_name = data_utils.rand_name("lb_member_pool1-update")
@@ -167,7 +170,8 @@
pool_update_kwargs[const.LB_ALGORITHM] = \
const.LB_ALGORITHM_LEAST_CONNECTIONS
- if self.protocol == const.HTTP:
+ if self.protocol == const.HTTP and (
+ self.lb_feature_enabled.session_persistence_enabled):
pool_update_kwargs[const.SESSION_PERSISTENCE] = {
const.TYPE: const.SESSION_PERSISTENCE_HTTP_COOKIE}
pool = self.mem_pool_client.update_pool(
@@ -191,12 +195,12 @@
if self.lb_feature_enabled.pool_algorithms_enabled:
self.assertEqual(const.LB_ALGORITHM_LEAST_CONNECTIONS,
pool[const.LB_ALGORITHM])
- self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
- if self.protocol == const.HTTP:
+ if self.lb_feature_enabled.session_persistence_enabled:
+ self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
self.assertEqual(const.SESSION_PERSISTENCE_HTTP_COOKIE,
pool[const.SESSION_PERSISTENCE][const.TYPE])
- self.assertIsNone(
- pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME))
+ self.assertIsNone(
+ pool[const.SESSION_PERSISTENCE].get(const.COOKIE_NAME))
# Pool delete
waiters.wait_for_status(