summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlawek Kaplonski <skaplons@redhat.com>2023-04-28 09:27:14 +0200
committerSlawek Kaplonski <skaplons@redhat.com>2023-04-28 09:58:54 +0000
commitb19b55909dffcdc4ebbbd6d723936f8a188e3e47 (patch)
treebc64a04465ab26a5f69353395a87d4b76df313fa
parentb6004982325cdf8b41fe3c4d8862a06cac9be9b8 (diff)
downloadneutron-b19b55909dffcdc4ebbbd6d723936f8a188e3e47.tar.gz
Don't set and remove immediately DEAD VLAN tag in tests
In fullstack and functional tests where OVSPortFixture is used to create port in OVS bridge, just after port was created by ovs interface driver, DEAD_VLAN tag was removed from the port as it's not needed in tests. But this could cause race condition and instead of removing DEAD_VLAN tag, actually correct tag configured by e.g. neutron_openvswitch_agent was removed and traffic to such port wasn't working at all. To avoid that race, now method which adds setting DEAD_VLAN tag to the port_replace transaction is now mocked so there will be no DEAD VLAN tag set on such port at all. This patch also removes unstable test decorator from the TestDhcpAgentHA.test_multiple_agents_for_network fullstack test as it seems for me that this was the reason why this test was failing pretty often. Closes-Bug: #2000150 Change-Id: I3938c94bbd531fac461e80e791c128821a4f837f
-rw-r--r--neutron/tests/common/net_helpers.py28
-rw-r--r--neutron/tests/fullstack/test_dhcp_agent.py2
2 files changed, 14 insertions, 16 deletions
diff --git a/neutron/tests/common/net_helpers.py b/neutron/tests/common/net_helpers.py
index 89f9042db9..ce8926f4bb 100644
--- a/neutron/tests/common/net_helpers.py
+++ b/neutron/tests/common/net_helpers.py
@@ -24,6 +24,7 @@ import shlex
import signal
import subprocess
import time
+from unittest import mock
import fixtures
import netaddr
@@ -880,20 +881,19 @@ class OVSPortFixture(PortFixture):
interface_config = cfg.ConfigOpts()
config.register_interface_opts(interface_config)
ovs_interface = interface.OVSInterfaceDriver(interface_config)
- ovs_interface.plug_new(
- None,
- self.port_id,
- port_name,
- self.mac,
- bridge=self.bridge.br_name,
- namespace=self.namespace)
- # NOTE(mangelajo): for OVS implementations remove the DEAD VLAN tag
- # on ports that we intend to use as fake vm interfaces, they
- # need to be flat. This is related to lp#1767422
- self.bridge.clear_db_attribute("Port", port_name, "tag")
- # Clear vlan_mode that is added for each new port. lp#1930414
- self.bridge.clear_db_attribute("Port", port_name, "vlan_mode")
- self.bridge.clear_db_attribute("Port", port_name, "trunks")
+ # NOTE(slaweq): for OVS implementation normally there would be DEAD
+ # VLAN tag set for port and we would need to remove it here as it is
+ # needed during the tests. But to avoid setting and removing tag, we
+ # can simply mock _set_port_dead method so port will not be tagged with
+ # DEAD_VLAN tag initially
+ with mock.patch.object(ovs_lib.OVSBridge, '_set_port_dead'):
+ ovs_interface.plug_new(
+ None,
+ self.port_id,
+ port_name,
+ self.mac,
+ bridge=self.bridge.br_name,
+ namespace=self.namespace)
self.addCleanup(self.bridge.delete_port, port_name)
self.port = ip_lib.IPDevice(port_name, self.namespace)
diff --git a/neutron/tests/fullstack/test_dhcp_agent.py b/neutron/tests/fullstack/test_dhcp_agent.py
index e6c05b6bca..6d19a30736 100644
--- a/neutron/tests/fullstack/test_dhcp_agent.py
+++ b/neutron/tests/fullstack/test_dhcp_agent.py
@@ -19,7 +19,6 @@ from oslo_utils import uuidutils
from neutron.agent.linux import ip_lib
from neutron.common import utils as common_utils
-from neutron.tests import base as test_base
from neutron.tests.fullstack.agents import dhcp_agent
from neutron.tests.fullstack import base
from neutron.tests.fullstack.resources import environment
@@ -185,7 +184,6 @@ class TestDhcpAgentHA(BaseDhcpAgentTest):
# check if new vm will get IP from new DHCP agent
self._spawn_vm()
- @test_base.unstable_test('bug 2000150')
def test_multiple_agents_for_network(self):
network_dhcp_agents = self.client.list_dhcp_agent_hosting_networks(
self.network['id'])['agents']