Run tests with algorithm supported by provider driver

This patch adds map of supported algorithms by
provider drivers. For a first iteration lets select
the first from supported algorithms to be used as
a default and run the tests with it.

In addition this patch splits check_members_balanced()
into subfunctions related to the algorithm
that is validated.

Story: 2006264
Task: 35972

Change-Id: Id055763f35b487da539eddfe802c543a11246503
diff --git a/octavia_tempest_plugin/common/constants.py b/octavia_tempest_plugin/common/constants.py
index 44bf3e5..d0d6a18 100644
--- a/octavia_tempest_plugin/common/constants.py
+++ b/octavia_tempest_plugin/common/constants.py
@@ -58,6 +58,17 @@
 LB_ALGORITHM_ROUND_ROBIN = 'ROUND_ROBIN'
 LB_ALGORITHM_LEAST_CONNECTIONS = 'LEAST_CONNECTIONS'
 LB_ALGORITHM_SOURCE_IP = 'SOURCE_IP'
+LB_ALGORITHM_SOURCE_IP_PORT = 'SOURCE_IP_PORT'
+SUPPORTED_LB_ALGORITHMS_AMPHORA = [
+    LB_ALGORITHM_ROUND_ROBIN,
+    LB_ALGORITHM_LEAST_CONNECTIONS,
+    LB_ALGORITHM_SOURCE_IP]
+SUPPORTED_LB_ALGORITHMS = {
+    'default': SUPPORTED_LB_ALGORITHMS_AMPHORA,
+    'octavia': SUPPORTED_LB_ALGORITHMS_AMPHORA,
+    'amphorav2': SUPPORTED_LB_ALGORITHMS_AMPHORA,
+    'amphora': SUPPORTED_LB_ALGORITHMS_AMPHORA,
+    'ovn': [LB_ALGORITHM_SOURCE_IP_PORT]}
 SESSION_PERSISTENCE = 'session_persistence'
 LISTENER_ID = 'listener_id'
 LOADBALANCERS = 'loadbalancers'
diff --git a/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py b/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py
index 8399f67..2599bee 100644
--- a/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py
+++ b/octavia_tempest_plugin/tests/act_stdby_scenario/v2/test_active_standby_iptables.py
@@ -116,7 +116,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LISTENER_ID: cls.listener_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/api/v2/test_healthmonitor.py b/octavia_tempest_plugin/tests/api/v2/test_healthmonitor.py
index 5f560c4..1feb9d9 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_healthmonitor.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_healthmonitor.py
@@ -77,7 +77,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
@@ -180,7 +180,7 @@
         pool1_kwargs = {
             const.NAME: pool1_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
@@ -200,7 +200,7 @@
         pool2_kwargs = {
             const.NAME: pool2_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
@@ -220,7 +220,7 @@
         pool3_kwargs = {
             const.NAME: pool3_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
@@ -469,7 +469,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
@@ -577,7 +577,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
@@ -734,7 +734,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
 
diff --git a/octavia_tempest_plugin/tests/api/v2/test_l7policy.py b/octavia_tempest_plugin/tests/api/v2/test_l7policy.py
index ee559af..b1bccc2 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_l7policy.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_l7policy.py
@@ -87,7 +87,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LOADBALANCER_ID: cls.lb_id,
         }
 
diff --git a/octavia_tempest_plugin/tests/api/v2/test_l7rule.py b/octavia_tempest_plugin/tests/api/v2/test_l7rule.py
index 7fed40c..aaad8a0 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_l7rule.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_l7rule.py
@@ -86,7 +86,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LISTENER_ID: cls.listener_id,
         }
 
diff --git a/octavia_tempest_plugin/tests/api/v2/test_member.py b/octavia_tempest_plugin/tests/api/v2/test_member.py
index a84e121..a279495 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_member.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_member.py
@@ -82,7 +82,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: cls.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LISTENER_ID: cls.listener_id,
         }
 
@@ -226,7 +226,7 @@
         pool = self.mem_pool_client.create_pool(
             name=pool_name, loadbalancer_id=self.lb_id,
             protocol=self.protocol,
-            lb_algorithm=const.LB_ALGORITHM_ROUND_ROBIN)
+            lb_algorithm=self.lb_algorithm)
         pool_id = pool[const.ID]
         self.addCleanup(
             self.mem_pool_client.cleanup_pool, pool_id,
@@ -736,7 +736,7 @@
         pool = self.mem_pool_client.create_pool(
             name=pool_name, loadbalancer_id=self.lb_id,
             protocol=self.protocol,
-            lb_algorithm=const.LB_ALGORITHM_ROUND_ROBIN)
+            lb_algorithm=self.lb_algorithm)
         pool_id = pool[const.ID]
         self.addClassResourceCleanup(
             self.mem_pool_client.cleanup_pool, pool_id,
diff --git a/octavia_tempest_plugin/tests/api/v2/test_pool.py b/octavia_tempest_plugin/tests/api/v2/test_pool.py
index 8273b48..fd3053d 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_pool.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_pool.py
@@ -102,7 +102,7 @@
             const.DESCRIPTION: pool_description,
             const.ADMIN_STATE_UP: True,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
             pool_kwargs[const.SESSION_PERSISTENCE] = {
@@ -170,7 +170,7 @@
                              pool[const.LISTENERS][0][const.ID])
         else:
             self.assertEmpty(pool[const.LISTENERS])
-        self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
+        self.assertEqual(self.lb_algorithm,
                          pool[const.LB_ALGORITHM])
         if self.lb_feature_enabled.session_persistence_enabled:
             self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
@@ -219,7 +219,7 @@
             const.DESCRIPTION: pool1_desc,
             const.ADMIN_STATE_UP: True,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: lb_id,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
@@ -257,7 +257,7 @@
             const.DESCRIPTION: pool2_desc,
             const.ADMIN_STATE_UP: True,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: lb_id,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
@@ -294,7 +294,7 @@
             const.DESCRIPTION: pool3_desc,
             const.ADMIN_STATE_UP: False,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             # No session persistence, just so there's one test for that
             const.LOADBALANCER_ID: lb_id,
         }
@@ -435,7 +435,7 @@
             const.DESCRIPTION: pool_description,
             const.ADMIN_STATE_UP: True,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
@@ -474,7 +474,7 @@
         self.assertEqual(1, len(pool[const.LOADBALANCERS]))
         self.assertEqual(self.lb_id, pool[const.LOADBALANCERS][0][const.ID])
         self.assertEmpty(pool[const.LISTENERS])
-        self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
+        self.assertEqual(self.lb_algorithm,
                          pool[const.LB_ALGORITHM])
         if self.lb_feature_enabled.session_persistence_enabled:
             self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
@@ -532,7 +532,7 @@
             const.DESCRIPTION: pool_description,
             const.ADMIN_STATE_UP: False,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
@@ -570,7 +570,7 @@
         self.assertEqual(1, len(pool[const.LOADBALANCERS]))
         self.assertEqual(self.lb_id, pool[const.LOADBALANCERS][0][const.ID])
         self.assertEmpty(pool[const.LISTENERS])
-        self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
+        self.assertEqual(self.lb_algorithm,
                          pool[const.LB_ALGORITHM])
         if self.lb_feature_enabled.session_persistence_enabled:
             self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
@@ -617,7 +617,7 @@
             const.NAME: new_name,
             const.DESCRIPTION: new_description,
             const.ADMIN_STATE_UP: True,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
             pool_update_kwargs[const.SESSION_PERSISTENCE] = {
@@ -641,7 +641,7 @@
         self.assertEqual(new_name, pool[const.NAME])
         self.assertEqual(new_description, pool[const.DESCRIPTION])
         self.assertTrue(pool[const.ADMIN_STATE_UP])
-        self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
+        self.assertEqual(self.lb_algorithm,
                          pool[const.LB_ALGORITHM])
         if self.lb_feature_enabled.session_persistence_enabled:
             self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
@@ -686,7 +686,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
diff --git a/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py b/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py
index 0fe1d81..8db166e 100644
--- a/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py
+++ b/octavia_tempest_plugin/tests/barbican_scenario/v2/test_tls_barbican.py
@@ -176,7 +176,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LOADBALANCER_ID: cls.lb_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_healthmonitor.py b/octavia_tempest_plugin/tests/scenario/v2/test_healthmonitor.py
index e3b4036..fa39c01 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_healthmonitor.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_healthmonitor.py
@@ -61,7 +61,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LOADBALANCER_ID: cls.lb_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py b/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py
index 690ea8f..1bf1322 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_ipv6_traffic_ops.py
@@ -93,7 +93,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LISTENER_ID: cls.listener_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_l7policy.py b/octavia_tempest_plugin/tests/scenario/v2/test_l7policy.py
index a38066c..46ce984 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_l7policy.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_l7policy.py
@@ -84,7 +84,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LOADBALANCER_ID: cls.lb_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_listener.py b/octavia_tempest_plugin/tests/scenario/v2/test_listener.py
index c504ea2..bb3df64 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_listener.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_listener.py
@@ -60,7 +60,7 @@
         pool1_kwargs = {
             const.NAME: pool1_name,
             const.PROTOCOL: cls.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LOADBALANCER_ID: cls.lb_id,
         }
         pool1 = cls.mem_pool_client.create_pool(**pool1_kwargs)
@@ -80,7 +80,7 @@
         pool2_kwargs = {
             const.NAME: pool2_name,
             const.PROTOCOL: cls.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LOADBALANCER_ID: cls.lb_id,
         }
         pool2 = cls.mem_pool_client.create_pool(**pool2_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_member.py b/octavia_tempest_plugin/tests/scenario/v2/test_member.py
index 488a7fd..4d55e07 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_member.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_member.py
@@ -79,7 +79,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LISTENER_ID: cls.listener_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_pool.py b/octavia_tempest_plugin/tests/scenario/v2/test_pool.py
index e6cd8c1..7a97b84 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_pool.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_pool.py
@@ -100,7 +100,7 @@
             const.DESCRIPTION: pool_description,
             const.ADMIN_STATE_UP: False,
             const.PROTOCOL: self.protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
         }
         if self.lb_feature_enabled.session_persistence_enabled:
             pool_kwargs[const.SESSION_PERSISTENCE] = {
@@ -146,7 +146,7 @@
                              pool[const.LISTENERS][0][const.ID])
         else:
             self.assertEmpty(pool[const.LISTENERS])
-        self.assertEqual(const.LB_ALGORITHM_ROUND_ROBIN,
+        self.assertEqual(self.lb_algorithm,
                          pool[const.LB_ALGORITHM])
         if self.lb_feature_enabled.session_persistence_enabled:
             self.assertIsNotNone(pool.get(const.SESSION_PERSISTENCE))
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_traffic_ops.py b/octavia_tempest_plugin/tests/scenario/v2/test_traffic_ops.py
index c3610d5..dc43a95 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_traffic_ops.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_traffic_ops.py
@@ -102,7 +102,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: protocol,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: cls.lb_algorithm,
             const.LISTENER_ID: cls.listener_id,
         }
         pool = cls.mem_pool_client.create_pool(**pool_kwargs)
@@ -413,7 +413,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LOADBALANCER_ID: self.lb_id,
         }
         pool = self.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/spare_pool_scenario/v2/test_spare_pool.py b/octavia_tempest_plugin/tests/spare_pool_scenario/v2/test_spare_pool.py
index 80c886b..e7fbd34 100644
--- a/octavia_tempest_plugin/tests/spare_pool_scenario/v2/test_spare_pool.py
+++ b/octavia_tempest_plugin/tests/spare_pool_scenario/v2/test_spare_pool.py
@@ -129,7 +129,7 @@
         pool_kwargs = {
             const.NAME: pool_name,
             const.PROTOCOL: const.HTTP,
-            const.LB_ALGORITHM: const.LB_ALGORITHM_ROUND_ROBIN,
+            const.LB_ALGORITHM: self.lb_algorithm,
             const.LISTENER_ID: self.listener_id,
         }
         pool = self.mem_pool_client.create_pool(**pool_kwargs)
diff --git a/octavia_tempest_plugin/tests/test_base.py b/octavia_tempest_plugin/tests/test_base.py
index 5033ade..f913ea9 100644
--- a/octavia_tempest_plugin/tests/test_base.py
+++ b/octavia_tempest_plugin/tests/test_base.py
@@ -145,6 +145,15 @@
                 "Configuration value test_network_override must be "
                 "specified if test_subnet_override is used.")
 
+        # Get loadbalancing algorithms supported by provider driver.
+        try:
+            algorithms = const.SUPPORTED_LB_ALGORITHMS[
+                CONF.load_balancer.provider]
+        except KeyError:
+            algorithms = const.SUPPORTED_LB_ALGORITHMS['default']
+        # Set default algorithm as first from the list.
+        cls.lb_algorithm = algorithms[0]
+
         show_subnet = cls.lb_mem_subnet_client.show_subnet
         if CONF.load_balancer.test_with_noop:
             cls.lb_member_vip_net = {'id': uuidutils.generate_uuid()}
@@ -860,41 +869,75 @@
                   'period. Failing test.')
         raise Exception()
 
-    def check_members_balanced(self, vip_address, traffic_member_count=2,
-                               protocol='http', verify=True, protocol_port=80):
-        handler = requests
-        if CONF.load_balancer.test_reuse_connection:
-            handler = requests.Session()
+    def _send_lb_request(self, handler, protocol, vip_address,
+                         verify, protocol_port, num=20):
         response_counts = {}
-
-        if ipaddress.ip_address(vip_address).version == 6:
-            vip_address = '[{}]'.format(vip_address)
-
-        self._wait_for_lb_functional(vip_address, protocol, verify)
-
         # Send a number requests to lb vip
-        for i in range(20):
+        for i in range(num):
             try:
                 r = handler.get('{0}://{1}:{2}'.format(protocol, vip_address,
                                                        protocol_port),
                                 timeout=2, verify=verify)
-
                 if r.content in response_counts:
                     response_counts[r.content] += 1
                 else:
                     response_counts[r.content] = 1
-
             except Exception:
                 LOG.exception('Failed to send request to loadbalancer vip')
                 raise Exception('Failed to connect to lb')
-
         LOG.debug('Loadbalancer response totals: %s', response_counts)
+        return response_counts
+
+    def _check_members_balanced_round_robin(
+            self, vip_address, traffic_member_count=2, protocol='http',
+            verify=True, protocol_port=80):
+
+        handler = requests.Session()
+        response_counts = self._send_lb_request(
+            handler, protocol, vip_address,
+            verify, protocol_port)
+
         # Ensure the correct number of members
         self.assertEqual(traffic_member_count, len(response_counts))
 
         # Ensure both members got the same number of responses
         self.assertEqual(1, len(set(response_counts.values())))
 
+    def _check_members_balanced_source_ip_port(
+            self, vip_address, traffic_member_count=2, protocol='http',
+            verify=True, protocol_port=80):
+
+        handler = requests
+        response_counts = self._send_lb_request(
+            handler, protocol, vip_address,
+            verify, protocol_port)
+        # Ensure the correct number of members
+        self.assertEqual(traffic_member_count, len(response_counts))
+
+        if CONF.load_balancer.test_reuse_connection:
+            handler = requests.Session()
+            response_counts = self._send_lb_request(
+                handler, protocol, vip_address,
+                verify, protocol_port)
+            # Ensure only one member answered
+            self.assertEqual(1, len(response_counts))
+
+    def check_members_balanced(self, vip_address, traffic_member_count=2,
+                               protocol='http', verify=True, protocol_port=80):
+
+        if ipaddress.ip_address(vip_address).version == 6:
+            vip_address = '[{}]'.format(vip_address)
+        self._wait_for_lb_functional(vip_address, protocol, verify)
+
+        validate_func = '_check_members_balanced_%s' % self.lb_algorithm
+        validate_func = getattr(self, validate_func.lower())
+        validate_func(
+            vip_address=vip_address,
+            traffic_member_count=traffic_member_count,
+            protocol=protocol,
+            verify=verify,
+            protocol_port=protocol_port)
+
     def assertConsistentResponse(self, response, url, method='GET', repeat=10,
                                  redirect=False, timeout=2, **kwargs):
         """Assert that a request to URL gets the expected response.