Fix a potential IP address conflict
Previously the tests generated a random IP address (out of 90)
for each load balancer. As these tests run in parallel there was a
chance that two load balancers could be assigned the same address,
causing a conflict and randomly failing a test.
This patch changes the tests to use a neutron assigned address unless
an explicit "use_fixed_ip" flag is set.
The load balancer create API test uses this flag, the others will use
a neutron assigned address.
Change-Id: Ic22efd1df027fd7dd0db14783f2c76069fd51bb5
diff --git a/octavia_tempest_plugin/tests/api/v2/test_load_balancer.py b/octavia_tempest_plugin/tests/api/v2/test_load_balancer.py
index 547a616..19f6044 100644
--- a/octavia_tempest_plugin/tests/api/v2/test_load_balancer.py
+++ b/octavia_tempest_plugin/tests/api/v2/test_load_balancer.py
@@ -69,7 +69,7 @@
# vip_qos_policy_id=lb_qos_policy_id)
const.NAME: lb_name}
- self._setup_lb_network_kwargs(lb_kwargs, ip_version)
+ self._setup_lb_network_kwargs(lb_kwargs, ip_version, use_fixed_ip=True)
# Test that a user without the load balancer role cannot
# create a load balancer
@@ -433,7 +433,7 @@
const.PROVIDER: CONF.load_balancer.provider,
const.NAME: lb_name}
- self._setup_lb_network_kwargs(lb_kwargs, 4)
+ self._setup_lb_network_kwargs(lb_kwargs, 4, use_fixed_ip=True)
lb = self.mem_lb_client.create_loadbalancer(**lb_kwargs)
@@ -531,7 +531,7 @@
# vip_qos_policy_id=lb_qos_policy_id)
const.NAME: lb_name}
- self._setup_lb_network_kwargs(lb_kwargs, 4)
+ self._setup_lb_network_kwargs(lb_kwargs, 4, use_fixed_ip=True)
lb = self.mem_lb_client.create_loadbalancer(**lb_kwargs)
diff --git a/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py b/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py
index 911353a..a10784b 100644
--- a/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py
+++ b/octavia_tempest_plugin/tests/scenario/v2/test_load_balancer.py
@@ -83,8 +83,6 @@
lb[const.VIP_NETWORK_ID])
self.assertIsNotNone(lb[const.VIP_PORT_ID])
if lb_kwargs[const.VIP_SUBNET_ID]:
- self.assertEqual(lb_kwargs[const.VIP_ADDRESS],
- lb[const.VIP_ADDRESS])
self.assertEqual(lb_kwargs[const.VIP_SUBNET_ID],
lb[const.VIP_SUBNET_ID])
diff --git a/octavia_tempest_plugin/tests/test_base.py b/octavia_tempest_plugin/tests/test_base.py
index 0e6eba4..2cc16e0 100644
--- a/octavia_tempest_plugin/tests/test_base.py
+++ b/octavia_tempest_plugin/tests/test_base.py
@@ -360,7 +360,8 @@
cls.lb_member_2_ipv6_subnet['id'])
@classmethod
- def _setup_lb_network_kwargs(cls, lb_kwargs, ip_version=None):
+ def _setup_lb_network_kwargs(cls, lb_kwargs, ip_version=None,
+ use_fixed_ip=False):
if not ip_version:
ip_version = 6 if CONF.load_balancer.test_with_ipv6 else 4
if cls.lb_member_vip_subnet:
@@ -376,7 +377,8 @@
lb_vip_address = str(network[ip_index])
subnet_id = cls.lb_member_vip_ipv6_subnet[const.ID]
lb_kwargs[const.VIP_SUBNET_ID] = subnet_id
- lb_kwargs[const.VIP_ADDRESS] = lb_vip_address
+ if use_fixed_ip:
+ lb_kwargs[const.VIP_ADDRESS] = lb_vip_address
if CONF.load_balancer.test_with_noop:
lb_kwargs[const.VIP_NETWORK_ID] = (
cls.lb_member_vip_net[const.ID])