Add an option to reuse connections

While using requests.session TCP connections are
reused. OVN Load Balancing algorithm uses hash with source port
to route clients requests. In that terms if connection is reused
the load is not spread across members. This patch adds an option
to disable reusing connections.

Change-Id: I61a202a2c1a6d15d714464d519de39f5f2acb2a6
Story: 2006264
Task: 35992
diff --git a/octavia_tempest_plugin/config.py b/octavia_tempest_plugin/config.py
index 5e09ba1..14007d1 100644
--- a/octavia_tempest_plugin/config.py
+++ b/octavia_tempest_plugin/config.py
@@ -184,6 +184,9 @@
     cfg.StrOpt('availability_zone',
                default=None,
                help='Availability zone to use for creating servers.'),
+    cfg.BoolOpt('test_reuse_connection', default=True,
+                help='Reuse TCP connections while testing LB with '
+                     'HTTP members (keep-alive).'),
 ]
 
 lb_feature_enabled_group = cfg.OptGroup(name='loadbalancer-feature-enabled',
diff --git a/octavia_tempest_plugin/tests/test_base.py b/octavia_tempest_plugin/tests/test_base.py
index 0e8a909..c8f7954 100644
--- a/octavia_tempest_plugin/tests/test_base.py
+++ b/octavia_tempest_plugin/tests/test_base.py
@@ -862,7 +862,9 @@
 
     def check_members_balanced(self, vip_address, traffic_member_count=2,
                                protocol='http', verify=True):
-        session = requests.Session()
+        handler = requests
+        if CONF.load_balancer.test_reuse_connection:
+            handler = requests.Session()
         response_counts = {}
 
         if ipaddress.ip_address(vip_address).version == 6:
@@ -873,7 +875,7 @@
         # Send a number requests to lb vip
         for i in range(20):
             try:
-                r = session.get('{0}://{1}'.format(protocol, vip_address),
+                r = handler.get('{0}://{1}'.format(protocol, vip_address),
                                 timeout=2, verify=verify)
 
                 if r.content in response_counts: