Test: mock out _check_netfilter_for_bridges in unit tests
_check_netfilter_for_bridges do some calls which are not for unit tests. Specifically the call for sysctl -N net.bridge seems to be broken with a recent kernel upgrade on bionic (see the irc log for this discussion in [1]). Add OS_TEST_TIMEOUT:180 to tox testenv, this can help to debug such issues. During the rootwrap to privsep change some of these mocks were added, (see [2]) so backporting (before Wallaby mostly) can be done with caution. [1]: https://meetings.opendev.org/irclogs/%23openstack-infra/%23openstack-infra.2022-07-20.log.html#t2022-07-20T12:59:32 [2]: https://review.opendev.org/c/openstack/neutron/+/764015/12/neutron/tests/unit/agent/linux/openvswitch_firewall/test_iptables.py Change-Id: Ic366d67770cc6e19a4412eaf2f1ab53780e98ee8 Closes-Bug: #1982206
This commit is contained in:
parent
5848c0dd1c
commit
119b82f1b1
@ -73,14 +73,18 @@ class TestHelper(base.BaseTestCase):
|
||||
self.helper.int_br.get_port_name_list.return_value = [
|
||||
'tap1234', 'qvo-1234', 'tap9876', 'qvo-fghfhfh']
|
||||
self.helper.int_br.db_get_val.return_value = {'foo': 'bar'}
|
||||
self.helper.load_driver_if_needed()
|
||||
self.assertIsNotNone(self.helper.iptables_driver)
|
||||
with mock.patch.object(iptables_firewall.IptablesFirewallDriver,
|
||||
'_check_netfilter_for_bridges'):
|
||||
self.helper.load_driver_if_needed()
|
||||
self.assertIsNotNone(self.helper.iptables_driver)
|
||||
|
||||
def test_get_iptables_driver_instance_has_correct_instance(self):
|
||||
instance = iptables.get_iptables_driver_instance()
|
||||
self.assertIsInstance(
|
||||
instance,
|
||||
iptables_firewall.OVSHybridIptablesFirewallDriver)
|
||||
with mock.patch.object(iptables_firewall.IptablesFirewallDriver,
|
||||
'_check_netfilter_for_bridges'):
|
||||
instance = iptables.get_iptables_driver_instance()
|
||||
self.assertIsInstance(
|
||||
instance,
|
||||
iptables_firewall.OVSHybridIptablesFirewallDriver)
|
||||
|
||||
def test_cleanup_port_last_port_marks_cleaned(self):
|
||||
self.helper.iptables_driver = mock.Mock()
|
||||
|
@ -38,6 +38,7 @@ from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.common import polling
|
||||
from neutron.agent.common import utils
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import iptables_firewall
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
from neutron.api.rpc.callbacks import resources
|
||||
from neutron.objects.ports import Port
|
||||
@ -154,7 +155,9 @@ class TestOvsNeutronAgent(object):
|
||||
'setup_ancillary_bridges',
|
||||
return_value=[]),\
|
||||
mock.patch('neutron.agent.linux.ip_lib.get_device_mac',
|
||||
return_value='00:00:00:00:00:01'),\
|
||||
return_value='00:00:00:00:00:01'), \
|
||||
mock.patch.object(iptables_firewall.IptablesFirewallDriver,
|
||||
'_check_netfilter_for_bridges'), \
|
||||
mock.patch(
|
||||
'neutron.agent.common.ovs_lib.BaseOVS.get_bridges'),\
|
||||
mock.patch('oslo_service.loopingcall.FixedIntervalLoopingCall',
|
||||
|
1
tox.ini
1
tox.ini
@ -10,6 +10,7 @@ setenv = VIRTUAL_ENV={envdir}
|
||||
OS_LOG_CAPTURE={env:OS_LOG_CAPTURE:true}
|
||||
OS_STDOUT_CAPTURE={env:OS_STDOUT_CAPTURE:true}
|
||||
OS_STDERR_CAPTURE={env:OS_STDERR_CAPTURE:true}
|
||||
OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:180}
|
||||
PYTHONWARNINGS=default::DeprecationWarning,ignore::DeprecationWarning:distutils,ignore::DeprecationWarning:site
|
||||
passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY TOX_ENV_SRC_MODULES
|
||||
usedevelop = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user