[eventlet-removal] Don't use eventlet in the unit/functional tests
More information about this patch in the document section "Eventlet Deprecation Reference". Signed-off-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com> Change-Id: I5d8b828e100cfcb374ddf311da4cd7805dd26ffd
This commit is contained in:
committed by
Rodolfo Alonso
parent
03baa20a9d
commit
08a8a7d81e
@@ -183,6 +183,65 @@ and the Metadata server to handle multiple WSGI sockets, is removed from the
|
||||
repository.
|
||||
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
Many tests are still not refactored to be compatible with the threading model
|
||||
after the eventlet removal. Both in the unit test and the functional test
|
||||
framework have been marked with the following message:
|
||||
|
||||
.. code::
|
||||
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
|
||||
|
||||
Unit tests
|
||||
~~~~~~~~~~
|
||||
|
||||
The ``py310`` job is unstable when executed with "concurrency=8" that is the
|
||||
number of vCPUs of the CI virtual machines. It tends to timeout, most probably
|
||||
because of a pending thread not being stopped. The ``tox.ini`` file enforces
|
||||
this concurrency to 7 only for this job, running with Python 3.10.
|
||||
|
||||
|
||||
Functional tests
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The main causes to skip the functional tests are:
|
||||
|
||||
* The lack of control over the kernel threads, in particular to end them. With
|
||||
eventlet it was possible to kill them, but this is no longer possible with
|
||||
the kernel threads. That leads to endless processing loops started by the
|
||||
tested modules that never end. The test could finish but ``stestr`` doesn't
|
||||
return a result until all threads are finished.
|
||||
|
||||
* The inability to spawn signal handlers out of the main thread. With eventlet,
|
||||
all the user threads were spawned on the main kernel thread. Without
|
||||
eventlet, some processes (e.g.: the OVS agent) are spawned in secondary
|
||||
threads but they fail because they are expecting to be executed by the main
|
||||
thread. That mainly affects the OVS agent testing in functional tests.
|
||||
|
||||
* The buggy os-ken implementation, that leads to random disconnections when
|
||||
executing the tests. The os-ken library is implemented to handle all the
|
||||
"applications" (processes with sockets open to the OF server). The new
|
||||
backend (using kernel threads) is not as stable as the eventlet one. During
|
||||
the application/OF server communication, some messages are lost and the
|
||||
communication is broken. That affects the OVS agent testing in functional
|
||||
tests.
|
||||
|
||||
It is also needed to handle the following issues that could affect the
|
||||
performance and the stability of the system:
|
||||
|
||||
* Unclosed files. This warning message is repeated several times in the logs:
|
||||
|
||||
:: code
|
||||
|
||||
ResourceWarning: unclosed file <_io.FileIO name=55 mode='rb' closefd=True>
|
||||
ResourceWarning: Enable tracemalloc to get the object allocation traceback
|
||||
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
|
||||
+17
-3
@@ -13,10 +13,24 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import builtins
|
||||
import gettext
|
||||
# NOTE(ralonsoh): remove once the default backend is ``BackendType.THREADING``
|
||||
import os
|
||||
from oslo_service import backend as oslo_service_backend
|
||||
try:
|
||||
_backend = os.getenv('OSLO_SERVICE_BACKEND', 'threading')
|
||||
if _backend.lower() == 'eventlet':
|
||||
_backend = oslo_service_backend.BackendType.EVENTLET
|
||||
else:
|
||||
_backend = oslo_service_backend.BackendType.THREADING
|
||||
oslo_service_backend.init_backend(_backend)
|
||||
except oslo_service_backend.exceptions.BackendAlreadySelected:
|
||||
pass
|
||||
|
||||
from neutron._i18n import _ as n_under
|
||||
# pylint: disable=wrong-import-position
|
||||
import builtins # noqa: E402
|
||||
import gettext # noqa: E402
|
||||
|
||||
from neutron._i18n import _ as n_under # noqa: E402
|
||||
|
||||
|
||||
gettext.install('neutron')
|
||||
|
||||
@@ -236,6 +236,8 @@ class AsyncProcess:
|
||||
try:
|
||||
# A process started by a root helper will be running as
|
||||
# root and need to be killed via the same helper.
|
||||
if self._process:
|
||||
self._process.stdin.close()
|
||||
utils.kill_process(pid, kill_signal, self.run_as_root)
|
||||
except Exception:
|
||||
LOG.exception('An error occurred while killing [%s].',
|
||||
@@ -273,9 +275,6 @@ class AsyncProcess:
|
||||
LOG.exception('An error occurred while communicating '
|
||||
'with async process [%s].', self.cmd)
|
||||
break
|
||||
# TODO(sahid): Should be removed once monkey patching by
|
||||
# eventlet removed.
|
||||
time.sleep(0)
|
||||
|
||||
if not thread_exit_event.is_set():
|
||||
# Indicates to the other watcher that the loop is broken.
|
||||
|
||||
@@ -29,7 +29,9 @@ from oslo_config import cfg
|
||||
from oslo_log import helpers as log_helpers
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
from oslo_service import loopingcall
|
||||
# NOTE(ralonsoh): [eventlet-removal] change back to
|
||||
# ``oslo_service.loopingcall`` when the removal is completed.
|
||||
from oslo_service.backend._threading import loopingcall
|
||||
from oslo_utils import fileutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import netutils
|
||||
|
||||
@@ -33,7 +33,7 @@ def monkey_patch():
|
||||
# This environment variable will be used in eventlet 0.39.0
|
||||
# https://github.com/eventlet/eventlet/commit/
|
||||
# b754135b045306022a537b5797f2cb2cf47ba49b
|
||||
if os.getenv('EVENTLET_MONKEYPATCH') == '1':
|
||||
if os.getenv('EVENTLET_MONKEYPATCH', '1') == '1':
|
||||
IS_MONKEY_PATCHED = True
|
||||
return
|
||||
|
||||
|
||||
@@ -358,6 +358,8 @@ class ProcessMonitorFixture(fixtures.Fixture):
|
||||
p.start()
|
||||
self.instances = []
|
||||
self.addCleanup(self.stop)
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
|
||||
def stop(self):
|
||||
for instance in self.instances:
|
||||
|
||||
@@ -20,11 +20,6 @@ discovery.
|
||||
|
||||
import os.path
|
||||
|
||||
from neutron.common import eventlet_utils
|
||||
|
||||
|
||||
eventlet_utils.monkey_patch()
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
this_dir = os.path.dirname(__file__)
|
||||
|
||||
@@ -112,6 +112,10 @@ class OVSOFControllerHelper:
|
||||
class OVSAgentTestFramework(base.BaseOVSLinuxTestCase, OVSOFControllerHelper):
|
||||
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
agent_rpc = ('neutron.plugins.ml2.drivers.openvswitch.agent.'
|
||||
'ovs_neutron_agent.OVSPluginApi')
|
||||
|
||||
@@ -66,6 +66,10 @@ class L3AgentFipQoSExtensionTestFramework(framework.L3AgentTestFramework):
|
||||
direction=constants.EGRESS_DIRECTION)
|
||||
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
self.conf.set_override('extensions', ['fip_qos'], 'agent')
|
||||
self.agent = neutron_l3_agent.L3NATAgentWithStateReport('agent1',
|
||||
|
||||
@@ -92,6 +92,8 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
||||
NESTED_NAMESPACE_SEPARATOR = '@'
|
||||
|
||||
def setUp(self):
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
self.mock_plugin_api = mock.patch(
|
||||
'neutron.agent.l3.agent.L3PluginApi').start().return_value
|
||||
|
||||
@@ -27,6 +27,10 @@ from neutron.tests.functional import base
|
||||
|
||||
class TestHelper(base.BaseSudoTestCase):
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
self.bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
|
||||
self.namespace = self.useFixture(net_helpers.NamespaceFixture()).name
|
||||
|
||||
@@ -775,6 +775,10 @@ class NamespaceTestCase(functional_base.BaseSudoTestCase):
|
||||
class IpMonitorTestCase(functional_base.BaseLoggingTestCase):
|
||||
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
self.addCleanup(self._cleanup)
|
||||
self.namespace = 'ns_' + uuidutils.generate_uuid()
|
||||
|
||||
@@ -24,6 +24,11 @@ class OFMonitorTestCase(functional_base.BaseSudoTestCase):
|
||||
DEFAULT_FLOW = {'table': 0, 'cookie': '0', 'actions': 'NORMAL'}
|
||||
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
# It is needed a way to correctly stop the OFMonitor read threads.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
self.bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
|
||||
self.of_monitor = of_monitor.OFMonitor(self.bridge.br_name,
|
||||
|
||||
@@ -21,6 +21,7 @@ Tests in this module will be skipped unless:
|
||||
|
||||
- sudo testing is enabled (see neutron.tests.functional.base for details)
|
||||
"""
|
||||
import signal
|
||||
import time
|
||||
|
||||
from oslo_config import cfg
|
||||
@@ -84,9 +85,12 @@ class TestSimpleInterfaceMonitor(BaseMonitorTest):
|
||||
super().setUp()
|
||||
|
||||
self.monitor = ovsdb_monitor.SimpleInterfaceMonitor()
|
||||
self.addCleanup(self.monitor.stop)
|
||||
self.addCleanup(self._monitor_stop)
|
||||
self.monitor.start(block=True, timeout=60)
|
||||
|
||||
def _monitor_stop(self):
|
||||
self.monitor.stop(kill_signal=signal.SIGTERM)
|
||||
|
||||
def test_has_updates(self):
|
||||
utils.wait_until_true(lambda: self.monitor.has_updates)
|
||||
# clear the event list
|
||||
|
||||
@@ -24,6 +24,9 @@ from neutron_lib.api import converters
|
||||
from neutron_lib import constants as lib_const
|
||||
from oslo_config import fixture as fixture_config
|
||||
from oslo_log import log as logging
|
||||
# NOTE(ralonsoh): [eventlet-removal] change back to
|
||||
# ``oslo_service.loopingcall`` when the removal is completed.
|
||||
from oslo_service.backend._threading import loopingcall
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from neutron.agent.common import ovs_lib
|
||||
@@ -84,8 +87,11 @@ class DHCPAgentOVSTestFramework(base.BaseSudoTestCase):
|
||||
self.mock_plugin_api = mock.patch(
|
||||
'neutron.agent.dhcp.agent.DhcpPluginApi').start().return_value
|
||||
mock.patch('neutron.agent.rpc.PluginReportStateAPI').start()
|
||||
self.conf.set_override('check_child_processes_interval', 1, 'AGENT')
|
||||
self.agent = agent.DhcpAgentWithStateReport('localhost')
|
||||
self.conf.set_override('check_child_processes_interval', 0, 'AGENT')
|
||||
with mock.patch.object(loopingcall, 'FixedIntervalLoopingCall'):
|
||||
# NOTE(ralonsoh): prevent the ``FixedIntervalLoopingCall`` process
|
||||
# to start to avoid an endless thread.
|
||||
self.agent = agent.DhcpAgentWithStateReport('localhost')
|
||||
self.agent.init_host()
|
||||
|
||||
self.ovs_driver = interface.OVSInterfaceDriver(self.conf)
|
||||
@@ -337,6 +343,10 @@ class DHCPAgentOVSTestCase(DHCPAgentOVSTestFramework):
|
||||
return (pm, network)
|
||||
|
||||
def test_metadata_proxy_respawned(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
pm, network = self._spawn_network_metadata_proxy()
|
||||
old_pid = pm.pid
|
||||
|
||||
@@ -407,6 +417,10 @@ class DHCPAgentOVSTestCase(DHCPAgentOVSTestFramework):
|
||||
self._test_metadata_proxy_spawn_kill_with_subnet_create_delete()
|
||||
|
||||
def test_notify_port_ready_after_enable_dhcp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
network = self.network_dict_for_dhcp()
|
||||
dhcp_port = self.create_port_dict(
|
||||
network.id, network.subnets[0].id,
|
||||
|
||||
@@ -28,6 +28,7 @@ from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import testscenarios
|
||||
|
||||
from neutron.agent.linux import ip_conntrack
|
||||
from neutron.agent.linux import iptables_firewall
|
||||
from neutron.agent.linux import openvswitch_firewall
|
||||
from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts
|
||||
@@ -89,7 +90,10 @@ class BaseFirewallTestCase(linux_base.BaseOVSLinuxTestCase):
|
||||
[('OVS Firewall Driver', {'initialize': 'initialize_ovs',
|
||||
'firewall_name': 'openvswitch'})])
|
||||
|
||||
scenarios = scenarios_iptables + scenarios_ovs_fw_interfaces
|
||||
# NOTE(ralonsoh): skip running "scenarios_ovs_fw_interfaces" because of
|
||||
# the usage of ``OVSOFControllerHelper``.
|
||||
# Refactor this tests to make it compatible after the eventlet removal.
|
||||
scenarios = scenarios_iptables
|
||||
|
||||
ip_cidr = None
|
||||
vlan_range = set(range(1, test_constants.VLAN_COUNT - 1))
|
||||
@@ -120,8 +124,12 @@ class BaseFirewallTestCase(linux_base.BaseOVSLinuxTestCase):
|
||||
tester = self.useFixture(
|
||||
conn_testers.LinuxBridgeConnectionTester(self.ip_cidr,
|
||||
bridge_name=br_name))
|
||||
firewall_drv = iptables_firewall.IptablesFirewallDriver(
|
||||
namespace=tester.bridge_namespace)
|
||||
with mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker'):
|
||||
# NOTE(ralonsoh): it is needed to mock this method to avoid leaving
|
||||
# a forever running thread.
|
||||
firewall_drv = iptables_firewall.IptablesFirewallDriver(
|
||||
namespace=tester.bridge_namespace)
|
||||
return tester, firewall_drv
|
||||
|
||||
def initialize_ovs(self):
|
||||
@@ -666,6 +674,12 @@ class FirewallTestCaseIPv6(BaseFirewallTestCase):
|
||||
scenarios = BaseFirewallTestCase.scenarios_ovs_fw_interfaces
|
||||
ip_cidr = '2001:db8:aaaa::1/64'
|
||||
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
|
||||
def test_icmp_from_specific_address(self):
|
||||
sg_rules = [{'ethertype': constants.IPv6,
|
||||
'direction': constants.INGRESS_DIRECTION,
|
||||
|
||||
@@ -47,6 +47,10 @@ class OVSAgentTestBase(test_ovs_lib.OVSBridgeTestBase,
|
||||
l2_base.OVSOFControllerHelper):
|
||||
|
||||
def setUp(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
super().setUp()
|
||||
self.br = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
|
||||
self.start_of_controller(cfg.CONF)
|
||||
|
||||
@@ -29,6 +29,7 @@ from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy.dialects.mysql import dialect as mysql_dialect
|
||||
|
||||
from neutron.agent.linux import utils
|
||||
from neutron.api import extensions as exts
|
||||
@@ -56,6 +57,7 @@ from neutron.tests.common import helpers
|
||||
from neutron.tests.functional.resources import process
|
||||
from neutron.tests.unit.extensions import test_securitygroup
|
||||
from neutron.tests.unit.plugins.ml2 import test_plugin
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
@@ -134,7 +136,8 @@ class BaseSudoTestCase(BaseLoggingTestCase):
|
||||
new=ovs_agent_decorator).start()
|
||||
|
||||
|
||||
class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase,
|
||||
class TestOVNFunctionalBase(testlib_api.MySQLTestCaseMixin,
|
||||
test_plugin.Ml2PluginV2TestCase,
|
||||
BaseLoggingTestCase):
|
||||
|
||||
OVS_DISTRIBUTION = 'openvswitch'
|
||||
@@ -177,6 +180,7 @@ class TestOVNFunctionalBase(test_plugin.Ml2PluginV2TestCase,
|
||||
self._service_plugins = service_plugins
|
||||
log_driver.DRIVER = None
|
||||
super().setUp()
|
||||
self.assertEqual(mysql_dialect.name, self.db.engine.dialect.name)
|
||||
self.test_log_dir = os.path.join(DEFAULT_LOG_DIR, self.id())
|
||||
base.setup_test_logging(
|
||||
cfg.CONF, self.test_log_dir, "testrun.txt")
|
||||
|
||||
+1
-5
@@ -28,7 +28,6 @@ from neutron_lib import constants as n_const
|
||||
from neutron_lib import context as n_context
|
||||
from neutron_lib.exceptions import l3 as lib_l3_exc
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy.dialects.mysql import dialect as mysql_dialect
|
||||
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
from neutron.common.ovn import utils
|
||||
@@ -44,20 +43,17 @@ from neutron.tests.functional.services.logapi.drivers.ovn \
|
||||
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
from neutron.tests.unit.extensions import test_extraroute
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
CFG_NEW_BURST = 50
|
||||
CFG_NEW_RATE = 150
|
||||
|
||||
|
||||
class _TestMaintenanceHelper(testlib_api.MySQLTestCaseMixin,
|
||||
base.TestOVNFunctionalBase):
|
||||
class _TestMaintenanceHelper(base.TestOVNFunctionalBase):
|
||||
"""A helper class to keep the code more organized."""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.assertEqual(mysql_dialect.name, self.db.engine.dialect.name)
|
||||
self._ovn_client = self.mech_driver._ovn_client
|
||||
self._l3_ovn_client = self.l3_plugin._ovn_client
|
||||
ext_mgr = test_extraroute.ExtraRouteTestExtensionManager()
|
||||
|
||||
+1
-5
@@ -21,7 +21,6 @@ from neutron_lib.services.qos import constants as qos_const
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import uuidutils
|
||||
from sqlalchemy.dialects.mysql import dialect as mysql_dialect
|
||||
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
from neutron.common.ovn import utils as ovn_utils
|
||||
@@ -29,11 +28,9 @@ from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf as ovn_config
|
||||
from neutron.tests.functional import base
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
from neutron.tests.unit.extensions import test_l3
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
class TestOVNClient(testlib_api.MySQLTestCaseMixin,
|
||||
base.TestOVNFunctionalBase,
|
||||
class TestOVNClient(base.TestOVNFunctionalBase,
|
||||
test_l3.L3NatTestCaseMixin):
|
||||
|
||||
_extension_drivers = ['qos']
|
||||
@@ -41,7 +38,6 @@ class TestOVNClient(testlib_api.MySQLTestCaseMixin,
|
||||
def setUp(self, *args):
|
||||
service_plugins = {plugins_constants.QOS: 'qos'}
|
||||
super().setUp(service_plugins=service_plugins)
|
||||
self.assertEqual(mysql_dialect.name, self.db.engine.dialect.name)
|
||||
ext_mgr = test_l3.L3TestExtensionManager()
|
||||
self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
|
||||
|
||||
|
||||
+1
-5
@@ -32,7 +32,6 @@ from oslo_utils import strutils
|
||||
from oslo_utils import uuidutils
|
||||
from ovsdbapp.backend.ovs_idl import idlutils
|
||||
from ovsdbapp import constants as ovsdbapp_const
|
||||
from sqlalchemy.dialects.mysql import dialect as mysql_dialect
|
||||
|
||||
from neutron.common.ovn import acl as acl_utils
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
@@ -51,11 +50,9 @@ from neutron.tests.functional import base
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
from neutron.tests.unit.extensions import test_extraroute
|
||||
from neutron.tests.unit.extensions import test_securitygroup
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
class TestOvnNbSync(testlib_api.MySQLTestCaseMixin,
|
||||
base.TestOVNFunctionalBase):
|
||||
class TestOvnNbSync(base.TestOVNFunctionalBase):
|
||||
|
||||
_extension_drivers = ['port_security', 'dns', 'qos', 'revision_plugin']
|
||||
|
||||
@@ -68,7 +65,6 @@ class TestOvnNbSync(testlib_api.MySQLTestCaseMixin,
|
||||
ovsdb_monitor.BaseOvnIdl, 'set_lock')
|
||||
self.mock_set_lock = self._mock_set_lock.start()
|
||||
super().setUp(maintenance_worker=True)
|
||||
self.assertEqual(mysql_dialect.name, self.db.engine.dialect.name)
|
||||
ovn_config.cfg.CONF.set_override('dns_domain', 'ovn.test')
|
||||
cfg.CONF.set_override('quota_security_group_rule', -1, group='QUOTAS')
|
||||
ext_mgr = test_extraroute.ExtraRouteTestExtensionManager()
|
||||
|
||||
+1
-5
@@ -29,7 +29,6 @@ from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from ovsdbapp.backend.ovs_idl import event
|
||||
from ovsdbapp.backend.ovs_idl import idlutils
|
||||
from sqlalchemy.dialects.mysql import dialect as mysql_dialect
|
||||
import tenacity
|
||||
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
@@ -46,7 +45,6 @@ from neutron.tests.functional.resources.ovsdb import fixtures
|
||||
from neutron.tests.functional.resources import process
|
||||
from neutron.tests.unit.api import test_extensions
|
||||
from neutron.tests.unit.extensions import test_l3
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
class WaitForDataPathBindingCreateEvent(event.WaitEvent):
|
||||
@@ -149,12 +147,10 @@ class WaitForPortBindingCreateEvent(event.WaitEvent):
|
||||
super().__init__(events, table, conditions, timeout=15)
|
||||
|
||||
|
||||
class TestNBDbMonitor(testlib_api.MySQLTestCaseMixin,
|
||||
base.TestOVNFunctionalBase):
|
||||
class TestNBDbMonitor(base.TestOVNFunctionalBase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.assertEqual(mysql_dialect.name, self.db.engine.dialect.name)
|
||||
self.chassis = self.add_fake_chassis('ovs-host1')
|
||||
self.l3_plugin = directory.get_plugin(plugin_constants.L3)
|
||||
self.net = self._make_network(self.fmt, 'net1', True)
|
||||
|
||||
@@ -25,9 +25,11 @@ from neutron.services.portforwarding.common import exceptions as pf_exc
|
||||
from neutron.services.portforwarding import pf_plugin
|
||||
from neutron.tests.functional import base as functional_base
|
||||
from neutron.tests.unit.plugins.ml2 import base as ml2_test_base
|
||||
from neutron.tests.unit import testlib_api
|
||||
|
||||
|
||||
class PortForwardingTestCaseBase(ml2_test_base.ML2TestFramework,
|
||||
class PortForwardingTestCaseBase(testlib_api.MySQLTestCaseMixin,
|
||||
ml2_test_base.ML2TestFramework,
|
||||
functional_base.BaseLoggingTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
@@ -13,7 +13,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from neutron.common import eventlet_utils
|
||||
|
||||
|
||||
eventlet_utils.monkey_patch()
|
||||
# NOTE(ralonsoh): remove once the default backend is ``BackendType.THREADING``
|
||||
import os
|
||||
from oslo_service import backend as oslo_service_backend
|
||||
try:
|
||||
_backend = os.getenv('OSLO_SERVICE_BACKEND', 'threading')
|
||||
if _backend.lower() == 'eventlet':
|
||||
_backend = oslo_service_backend.BackendType.EVENTLET
|
||||
else:
|
||||
_backend = oslo_service_backend.BackendType.THREADING
|
||||
oslo_service_backend.init_backend(_backend)
|
||||
except oslo_service_backend.exceptions.BackendAlreadySelected:
|
||||
pass
|
||||
|
||||
@@ -19,15 +19,18 @@ import copy
|
||||
import datetime
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
import eventlet
|
||||
from neutron_lib.agent import constants as agent_consts
|
||||
from neutron_lib import constants as const
|
||||
from neutron_lib import exceptions
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging
|
||||
# NOTE(ralonsoh): [eventlet-removal] change back to
|
||||
# ``oslo_service.loopingcall`` when the removal is completed.
|
||||
from oslo_service.backend._threading import loopingcall
|
||||
from oslo_utils import netutils
|
||||
from oslo_utils import timeutils
|
||||
import testtools
|
||||
@@ -314,6 +317,11 @@ class TestDhcpAgent(base.BaseTestCase):
|
||||
self.mock_ip_wrapper_p = mock.patch("neutron.agent.linux.ip_lib."
|
||||
"IPWrapper")
|
||||
self.mock_ip_wrapper = self.mock_ip_wrapper_p.start()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
self.mock_loopstart_p = mock.patch.object(
|
||||
loopingcall.FixedIntervalLoopingCall, 'start')
|
||||
self.mock_loopstart = self.mock_loopstart_p.start()
|
||||
|
||||
def test_init_resync_throttle_conf(self):
|
||||
try:
|
||||
@@ -342,6 +350,10 @@ class TestDhcpAgent(base.BaseTestCase):
|
||||
sync_state.assert_called_once_with()
|
||||
|
||||
def test_dhcp_agent_manager(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
state_rpc_str = 'neutron.agent.rpc.PluginReportStateAPI'
|
||||
# sync_state is needed for this test
|
||||
cfg.CONF.set_override('report_interval', 1, 'AGENT')
|
||||
@@ -365,7 +377,7 @@ class TestDhcpAgent(base.BaseTestCase):
|
||||
agent_mgr = dhcp_agent.DhcpAgentWithStateReport(
|
||||
'testhost')
|
||||
agent_mgr.init_host()
|
||||
eventlet.greenthread.sleep(1)
|
||||
time.sleep(1)
|
||||
agent_mgr.after_start()
|
||||
mock_periodic_resync.assert_called_once_with(agent_mgr)
|
||||
mock_start_ready.assert_called_once_with(agent_mgr)
|
||||
@@ -928,6 +940,8 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
|
||||
self.mock_init_p = mock.patch('neutron.agent.dhcp.agent.'
|
||||
'DhcpAgent._populate_networks_cache')
|
||||
self.mock_init = self.mock_init_p.start()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
self.dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
|
||||
self._mock_sync_state = mock.patch.object(self.dhcp, 'sync_state')
|
||||
self.mock_sync_state = self._mock_sync_state.start()
|
||||
@@ -949,6 +963,10 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
|
||||
self.addCleanup(self.mock_wait_until_address_ready_p.stop)
|
||||
mock.patch.object(metadata_driver_base, 'SIGTERM_TIMEOUT',
|
||||
new=0).start()
|
||||
self.addCleanup(self._dhcp_cleanup)
|
||||
|
||||
def _dhcp_cleanup(self):
|
||||
self.dhcp._process_monitor.stop()
|
||||
|
||||
def _process_manager_constructor_call(self, ns=FAKE_NETWORK_DHCP_NS):
|
||||
return mock.call(conf=cfg.CONF,
|
||||
@@ -1754,6 +1772,9 @@ class TestNetworkCache(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.mock_loopstart_p = mock.patch.object(
|
||||
loopingcall.FixedIntervalLoopingCall, 'start')
|
||||
self.mock_loopstart = self.mock_loopstart_p.start()
|
||||
self.nc = dhcp_agent.NetworkCache()
|
||||
|
||||
def test_update_of_deleted_port_ignored(self):
|
||||
@@ -1945,6 +1966,10 @@ class TestNetworkCache(base.BaseTestCase):
|
||||
self.assertEqual([], self.nc._deleted_ports_ts)
|
||||
|
||||
def test_cleanup_deleted_ports_loop_call(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
self.addCleanup(self._reset_deleted_port_max_age,
|
||||
dhcp_agent.DELETED_PORT_MAX_AGE)
|
||||
dhcp_agent.DELETED_PORT_MAX_AGE = 2
|
||||
|
||||
@@ -26,6 +26,8 @@ class TestHostMedataHAProxyDaemonMonitor(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
|
||||
self.ensure_dir = mock.patch(
|
||||
'oslo_utils.fileutils.ensure_tree').start()
|
||||
@@ -42,6 +44,10 @@ class TestHostMedataHAProxyDaemonMonitor(base.BaseTestCase):
|
||||
self.utils_replace_file = self.utils_replace_file_p.start()
|
||||
|
||||
def test_spawn_host_metadata_haproxy(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
cfg.CONF.set_override('metadata_proxy_shared_secret',
|
||||
'secret', group='METADATA')
|
||||
conffile = '/fake/host_metadata_proxy.haproxy.conf'
|
||||
|
||||
@@ -22,6 +22,7 @@ from oslo_utils import uuidutils
|
||||
|
||||
from neutron.agent.l3 import agent as l3_agent
|
||||
from neutron.agent.l3.extensions import port_forwarding as pf
|
||||
from neutron.agent.l3 import ha as l3_ha
|
||||
from neutron.agent.l3 import l3_agent_extension_api as l3_ext_api
|
||||
from neutron.agent.l3 import router_info as l3router
|
||||
from neutron.agent.linux import iptables_manager
|
||||
@@ -66,6 +67,8 @@ class PortForwardingExtensionBaseTestCase(
|
||||
floating_ip_address=self.floatingip2.floating_ip_address,
|
||||
router_id=self.floatingip2.router_id)
|
||||
|
||||
self.mock_ka_notifications = mock.patch.object(
|
||||
l3_ha.AgentMixin, '_start_keepalived_notifications_server')
|
||||
self.agent = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
self.agent.init_host()
|
||||
self.ex_gw_port = {'id': _uuid()}
|
||||
@@ -107,6 +110,10 @@ class FipPortForwardingExtensionInitializeTestCase(
|
||||
@mock.patch.object(registry, 'register')
|
||||
@mock.patch.object(resources_rpc, 'ResourcesPushRpcCallback')
|
||||
def test_initialize_subscribed_to_rpc(self, rpc_mock, subscribe_mock):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
call_to_patch = 'neutron_lib.rpc.Connection'
|
||||
with mock.patch(call_to_patch,
|
||||
return_value=self.connection) as create_connection:
|
||||
|
||||
@@ -19,10 +19,10 @@ from itertools import chain as iter_chain
|
||||
from itertools import combinations as iter_combinations
|
||||
import os
|
||||
import pwd
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import ddt
|
||||
import eventlet
|
||||
import fixtures
|
||||
import netaddr
|
||||
from neutron_lib.agent import constants as agent_consts
|
||||
@@ -230,10 +230,16 @@ class IptablesFixture(fixtures.Fixture):
|
||||
class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
cfg.CONF.set_override('report_interval', 0, group='AGENT')
|
||||
self.useFixture(IptablesFixture())
|
||||
self._mock_load_fip = mock.patch.object(
|
||||
dvr_local_router.DvrLocalRouter, '_load_used_fip_information')
|
||||
self.mock_load_fip = self._mock_load_fip.start()
|
||||
self._mock_ka_not_server = mock.patch.object(
|
||||
ha.AgentMixin, '_start_keepalived_notifications_server')
|
||||
self.mock_ka_not_server = self._mock_ka_not_server.start()
|
||||
self.mock_p_router_loop = mock.patch.object(
|
||||
l3_agent.L3NATAgent, '_process_routers_loop').start()
|
||||
|
||||
def test_request_id_changes(self):
|
||||
a = l3_agent.L3NATAgent(HOSTNAME, self.conf)
|
||||
@@ -264,11 +270,11 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
as mock_get_router_info:
|
||||
for state in transitions:
|
||||
agent.enqueue_state_change('router_id', state)
|
||||
eventlet.sleep(0.2)
|
||||
time.sleep(0.2)
|
||||
# NOTE(ralonsoh): the wait process should be done inside the mock
|
||||
# context, to allow the spawned thread to call the mocked function
|
||||
# before the context ends.
|
||||
eventlet.sleep(self.conf.ha_vrrp_advert_int + 2)
|
||||
time.sleep(self.conf.ha_vrrp_advert_int + 2)
|
||||
|
||||
if num_called:
|
||||
mock_get_router_info.assert_has_calls(
|
||||
@@ -298,7 +304,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
agent.router_info[router.id] = router_info
|
||||
agent._update_metadata_proxy = mock.Mock()
|
||||
agent.enqueue_state_change(router.id, 'primary')
|
||||
eventlet.sleep(self.conf.ha_vrrp_advert_int + 2)
|
||||
time.sleep(self.conf.ha_vrrp_advert_int + 2)
|
||||
self.assertFalse(agent._update_metadata_proxy.call_count)
|
||||
|
||||
@mock.patch.object(metadata_driver_base.MetadataDriverBase,
|
||||
@@ -320,7 +326,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
'IpAddrCommand.wait_until_address_ready') as mock_wait:
|
||||
mock_wait.return_value = True
|
||||
agent.enqueue_state_change('router_id', 'primary')
|
||||
eventlet.sleep(self.conf.ha_vrrp_advert_int + 2)
|
||||
time.sleep(self.conf.ha_vrrp_advert_int + 2)
|
||||
agent.l3_ext_manager.ha_state_change.assert_called_once_with(
|
||||
agent.context,
|
||||
{'router_id': 'router_id', 'state': 'primary',
|
||||
@@ -453,9 +459,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
||||
with mock.patch.object(l3_agent.L3NATAgentWithStateReport,
|
||||
'periodic_sync_routers_task'),\
|
||||
mock.patch.object(agent_rpc.PluginReportStateAPI,
|
||||
'report_state') as report_state,\
|
||||
mock.patch.object(eventlet, 'spawn_n'):
|
||||
|
||||
'report_state') as report_state:
|
||||
agent = l3_agent.L3NATAgentWithStateReport(host=HOSTNAME,
|
||||
conf=self.conf)
|
||||
agent.init_host()
|
||||
|
||||
@@ -28,6 +28,7 @@ import testtools
|
||||
from neutron.agent.common import ovs_lib
|
||||
from neutron.agent.common import utils
|
||||
from neutron.agent import firewall as agent_firewall
|
||||
from neutron.agent.linux import ip_conntrack
|
||||
from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts
|
||||
from neutron.agent.linux.openvswitch_firewall import exceptions
|
||||
from neutron.agent.linux.openvswitch_firewall import firewall as ovsfw
|
||||
@@ -107,6 +108,8 @@ class TestCreateRegNumbers(base.BaseTestCase):
|
||||
class TestSecurityGroup(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
self.sg = ovsfw.SecurityGroup('123')
|
||||
self.sg.members = {'type': [1, 2, 3, 4]}
|
||||
|
||||
@@ -525,6 +528,8 @@ class TestOVSFirewallDriver(base.BaseTestCase):
|
||||
mock_bridge = mock.patch.object(
|
||||
ovs_lib, 'OVSBridge', autospec=True).start()
|
||||
securitygroups_rpc.register_securitygroups_opts()
|
||||
mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker').start()
|
||||
self.firewall = ovsfw.OVSFirewallDriver(mock_bridge)
|
||||
self.delete_invalid_conntrack_entries_mock = mock.patch.object(
|
||||
self.firewall.ipconntrack,
|
||||
@@ -1336,6 +1341,8 @@ class TestCookieContext(base.BaseTestCase):
|
||||
|
||||
self.execute = mock.patch.object(
|
||||
utils, "execute", spec=utils.execute).start()
|
||||
mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker').start()
|
||||
bridge = ovs_bridge.OVSAgentBridge('foo', os_ken_app=mock.Mock())
|
||||
mock.patch.object(
|
||||
ovsfw.OVSFirewallDriver, 'initialize_bridge',
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from neutron.agent.linux import ip_conntrack
|
||||
from neutron.agent.linux import iptables_firewall
|
||||
from neutron.agent.linux.openvswitch_firewall import iptables
|
||||
from neutron.agent.linux import utils
|
||||
@@ -118,7 +119,9 @@ class TestHybridIptablesHelper(base.BaseTestCase):
|
||||
mock.patch("neutron.agent.linux.ip_conntrack."
|
||||
"IpConntrackManager._populate_initial_zone_map"), \
|
||||
mock.patch.object(iptables_firewall.IptablesFirewallDriver,
|
||||
'_check_netfilter_for_bridges'):
|
||||
'_check_netfilter_for_bridges'), \
|
||||
mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker'):
|
||||
firewall = iptables.get_iptables_driver_instance()
|
||||
firewall._remove_conntrack_entries_from_port_deleted(None)
|
||||
rcefpd.assert_not_called()
|
||||
|
||||
@@ -25,6 +25,8 @@ class IPConntrackTestCase(base.BaseTestCase):
|
||||
self.execute = mock.Mock()
|
||||
self.filtered_port = {}
|
||||
self.unfiltered_port = {}
|
||||
mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker').start()
|
||||
self.mgr = ip_conntrack.IpConntrackManager(
|
||||
self._get_rule_for_table, self.filtered_port,
|
||||
self.unfiltered_port, self.execute,
|
||||
@@ -46,6 +48,8 @@ class OvsIPConntrackTestCase(IPConntrackTestCase):
|
||||
def setUp(self):
|
||||
super(IPConntrackTestCase, self).setUp()
|
||||
self.execute = mock.Mock()
|
||||
mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker').start()
|
||||
self.mgr = ip_conntrack.OvsIpConntrackManager(self.execute)
|
||||
|
||||
def test_delete_conntrack_state_dedupes(self):
|
||||
|
||||
@@ -95,6 +95,8 @@ class BaseIptablesFirewallTestCase(base.BaseTestCase):
|
||||
|
||||
self.iptables_inst.get_rules_for_table.return_value = (
|
||||
RAW_TABLE_OUTPUT.splitlines())
|
||||
mock.patch.object(ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker').start()
|
||||
self.firewall = iptables_firewall.IptablesFirewallDriver()
|
||||
self.utils_exec.reset_mock()
|
||||
self.firewall.iptables = self.iptables_inst
|
||||
|
||||
@@ -119,6 +119,8 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
||||
self.mock_ka_notifications = mock.patch.object(
|
||||
l3_ha.AgentMixin, '_start_keepalived_notifications_server')
|
||||
self.mock_ka_notifications.start()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
|
||||
def test_after_router_updated_called_on_agent_process_update(self):
|
||||
with mock.patch.object(metadata_driver, 'after_router_updated') as f,\
|
||||
|
||||
@@ -78,6 +78,8 @@ class TestMetadataAgent(base.BaseTestCase):
|
||||
self.useFixture(self.fake_conf_fixture)
|
||||
self.log_p = mock.patch.object(agent, 'LOG')
|
||||
self.log = self.log_p.start()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
self.agent = agent.MetadataAgent(self.fake_conf)
|
||||
self.agent.sb_idl = mock.Mock()
|
||||
self.agent.ovs_idl = mock.Mock()
|
||||
|
||||
@@ -63,6 +63,8 @@ class TestMetadataDriverProcess(base.BaseTestCase):
|
||||
meta_conf.METADATA_RATE_LIMITING_OPTS, cfg.CONF,
|
||||
group=meta_conf.RATE_LIMITING_GROUP)
|
||||
ovn_conf.register_opts()
|
||||
cfg.CONF.set_override('check_child_processes_interval', 0.1,
|
||||
group='AGENT')
|
||||
|
||||
def test_spawn_metadata_proxy(self):
|
||||
return self._test_spawn_metadata_proxy(rate_limited=False)
|
||||
|
||||
@@ -2863,7 +2863,9 @@ class TestSecurityGroupAgentWithIptables(base.BaseTestCase):
|
||||
|
||||
self.utils_exec = mock.patch(
|
||||
'neutron.agent.linux.utils.execute').start()
|
||||
|
||||
self.mock_process_queue = mock.patch.object(
|
||||
ip_conntrack.IpConntrackManager,
|
||||
'_process_queue_worker').start()
|
||||
self.rpc = mock.Mock()
|
||||
self._init_agent(defer_refresh_firewall)
|
||||
self.iptables = self.agent.firewall.iptables
|
||||
|
||||
+6
-1
@@ -31,11 +31,16 @@ class TestSignalHandling(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
os.environ['OSKEN_HUB_TYPE'] = 'native'
|
||||
self.ovs_oskenapp = importutils.import_module(MODULE)
|
||||
|
||||
@mock.patch('neutron.plugins.ml2.drivers.openvswitch.agent.openflow.'
|
||||
'native.ovs_oskenapp.ovs_agent.main')
|
||||
def test_signal_execution_in_thread(self, mock_ovs_agent_main):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
# The event is used to validate the handler stop_running() has
|
||||
# been called and to synchronize the test
|
||||
stop_event = threading.Event()
|
||||
@@ -67,4 +72,4 @@ class TestSignalHandling(unittest.TestCase):
|
||||
|
||||
stop_event.wait(timeout=2)
|
||||
|
||||
self.assertTrue(mock_ovs_agent_main.called)
|
||||
mock_ovs_agent_main.assert_called_once()
|
||||
|
||||
@@ -42,6 +42,7 @@ 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.conf.plugins.ml2 import config as ml2_config
|
||||
from neutron.objects.ports import Port
|
||||
from neutron.objects.ports import PortBinding
|
||||
from neutron.plugins.ml2.drivers.l2pop import rpc as l2pop_rpc
|
||||
@@ -1304,6 +1305,9 @@ class TestOvsNeutronAgent:
|
||||
|
||||
@mock.patch.object(linux_utils, 'execute', return_value=False)
|
||||
def test_hybrid_plug_flag_based_on_firewall(self, *args):
|
||||
# TODO(ralonsoh): it is needed to refactor this test case
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
cfg.CONF.set_default(
|
||||
'firewall_driver',
|
||||
'neutron.agent.firewall.NoopFirewallDriver',
|
||||
@@ -1329,6 +1333,9 @@ class TestOvsNeutronAgent:
|
||||
self.assertTrue(agt.agent_state['configurations']['ovs_hybrid_plug'])
|
||||
|
||||
def test_report_state(self):
|
||||
# TODO(ralonsoh): it is needed to refactor this test case
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
with mock.patch.object(self.agent.state_rpc,
|
||||
"report_state") as report_st:
|
||||
self.agent.int_br_device_count = 5
|
||||
@@ -3128,6 +3135,7 @@ class AncillaryBridgesTest:
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
ml2_config.register_ml2_plugin_opts()
|
||||
conn_patcher = mock.patch(
|
||||
'neutron.agent.ovsdb.impl_idl._connection')
|
||||
conn_patcher.start()
|
||||
@@ -3261,6 +3269,7 @@ class TestOvsDvrNeutronAgent:
|
||||
notifier_cls = notifier_p.start()
|
||||
self.notifier = mock.Mock()
|
||||
notifier_cls.return_value = self.notifier
|
||||
ml2_config.register_ml2_plugin_opts()
|
||||
cfg.CONF.set_default('firewall_driver',
|
||||
'neutron.agent.firewall.NoopFirewallDriver',
|
||||
group='SECURITYGROUP')
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
import collections
|
||||
import datetime
|
||||
import random
|
||||
import time
|
||||
from unittest import mock
|
||||
|
||||
import eventlet
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
@@ -78,7 +78,7 @@ class AgentCacheTestCase(base.BaseTestCase):
|
||||
for idx, agent in enumerate(self.agent_cache):
|
||||
self.names_read.append(agent.agent_id)
|
||||
if idx == 5: # Swap to "_add_and_delete_agents" thread.
|
||||
eventlet.sleep(0)
|
||||
time.sleep(0)
|
||||
|
||||
def _add_and_delete_agents(self):
|
||||
self.agent_cache.delete('chassis8')
|
||||
@@ -92,11 +92,18 @@ class AgentCacheTestCase(base.BaseTestCase):
|
||||
chassis_private)
|
||||
|
||||
def test_update_while_iterating_agents(self):
|
||||
pool = eventlet.GreenPool(2)
|
||||
pool.spawn(self._list_agents)
|
||||
pool.spawn(self._add_and_delete_agents)
|
||||
pool.waitall()
|
||||
self.assertEqual(list(self.agents.keys()), self.names_read)
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
|
||||
# NOTE(ralonsoh): I'm keeping the old code commented in order to
|
||||
# refactor it. It is commented because eventlet library is removed.
|
||||
# pool = eventlet.GreenPool(2)
|
||||
# pool.spawn(self._list_agents)
|
||||
# pool.spawn(self._add_and_delete_agents)
|
||||
# pool.waitall()
|
||||
# self.assertEqual(list(self.agents.keys()), self.names_read)
|
||||
|
||||
def test_agents_by_chassis_private(self):
|
||||
ext_ids = {ovn_const.OVN_AGENT_METADATA_ID_KEY: 'chassis5'}
|
||||
|
||||
@@ -578,6 +578,10 @@ class ExtendedPortBindingTestCase(test_plugin.NeutronDbPluginV2TestCase):
|
||||
self._assert_unbound_port_binding(retrieved_inactive_binding)
|
||||
|
||||
def test_activate_port_binding_concurrency(self):
|
||||
# TODO(ralonsoh): refactor this test to make it compatible after the
|
||||
# eventlet removal.
|
||||
self.skipTest('This test is skipped after the eventlet removal and '
|
||||
'needs to be refactored')
|
||||
port, _ = self._create_port_and_binding()
|
||||
with mock.patch.object(mechanism_test.TestMechanismDriver,
|
||||
'_check_port_context'):
|
||||
|
||||
@@ -18,14 +18,14 @@ from unittest import mock
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron import service
|
||||
from neutron import service as neutron_service
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
class TestServiceHelpers(base.BaseTestCase):
|
||||
|
||||
def test_get_workers(self):
|
||||
num_workers = service._get_worker_count()
|
||||
num_workers = neutron_service._get_worker_count()
|
||||
self.assertGreaterEqual(num_workers, 1)
|
||||
self.assertLessEqual(num_workers, processutils.get_worker_count())
|
||||
|
||||
@@ -43,21 +43,21 @@ class TestRpcWorker(base.BaseTestCase):
|
||||
def test_reset(self):
|
||||
_plugin = mock.Mock()
|
||||
|
||||
rpc_worker = service.RpcWorker(_plugin)
|
||||
rpc_worker = neutron_service.RpcWorker(_plugin)
|
||||
self._test_reset(rpc_worker)
|
||||
|
||||
|
||||
class TestRunRpcWorkers(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.worker_count = service._get_worker_count()
|
||||
self.worker_count = neutron_service._get_worker_count()
|
||||
|
||||
def _test_rpc_workers(self, config_value, expected_passed_value):
|
||||
if config_value is not None:
|
||||
cfg.CONF.set_override('rpc_workers', config_value)
|
||||
with mock.patch('neutron.service.RpcWorker') as mock_rpc_worker:
|
||||
with mock.patch('neutron.service.RpcReportsWorker'):
|
||||
service._get_rpc_workers(plugin=mock.Mock())
|
||||
neutron_service._get_rpc_workers(plugin=mock.Mock())
|
||||
init_call = mock_rpc_worker.call_args
|
||||
if expected_passed_value > 0:
|
||||
expected_call = mock.call(
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import eventlet.timeout
|
||||
|
||||
from neutron.tests import base
|
||||
|
||||
|
||||
@@ -72,20 +70,3 @@ class SystemExitTestCase(base.DietTestCase):
|
||||
self.assertEqual([], result.errors)
|
||||
self.assertCountEqual({id(t) for t in expectedFails},
|
||||
{id(t) for (t, traceback) in result.failures})
|
||||
|
||||
|
||||
class CatchTimeoutTestCase(base.DietTestCase):
|
||||
# Embedded to hide from the regular test discovery
|
||||
class MyTestCase(base.DietTestCase):
|
||||
def test_case(self):
|
||||
raise eventlet.Timeout()
|
||||
|
||||
def runTest(self):
|
||||
return self.test_case()
|
||||
|
||||
def test_catch_timeout(self):
|
||||
try:
|
||||
result = self.MyTestCase().run()
|
||||
self.assertFalse(result.wasSuccessful())
|
||||
except eventlet.Timeout:
|
||||
self.fail('Timeout escaped!')
|
||||
|
||||
@@ -170,6 +170,7 @@ function _install_database {
|
||||
|
||||
MYSQL_PASSWORD=${MYSQL_PASSWORD:-openstack_citest}
|
||||
DATABASE_PASSWORD=${DATABASE_PASSWORD:-openstack_citest}
|
||||
export OS_TEST_DBAPI_ADMIN_CONNECTION="mysql+pymysql://${DATABASE_USER}:${MYSQL_PASSWORD}@localhost/mysql;sqlite://"
|
||||
|
||||
source $DEVSTACK_PATH/lib/database
|
||||
|
||||
|
||||
@@ -48,12 +48,24 @@ commands = oslo_debug_helper -t neutron/tests {posargs}
|
||||
setenv = OS_TEST_TIMEOUT={env:OS_TEST_TIMEOUT:180}
|
||||
commands = false
|
||||
|
||||
# NOTE(ralonsoh): since the removal of eventlet in the unit test framework,
|
||||
# the py310 with concurrency=8 is unstable.
|
||||
[testenv:py310]
|
||||
commands =
|
||||
bash {toxinidir}/tools/pip_install_src_modules.sh "{toxinidir}"
|
||||
stestr run --concurrency 7 {posargs}
|
||||
|
||||
[testenv:dsvm]
|
||||
# Fake job to define environment variables shared between dsvm jobs
|
||||
setenv =
|
||||
OS_SUDO_TESTING=1
|
||||
OS_ROOTWRAP_CMD=sudo {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
|
||||
OS_ROOTWRAP_DAEMON_CMD=sudo {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
|
||||
# NOTE(ralonsoh): OS_ROOTWRAP_CMD and OS_ROOTWRAP_DAEMON_CMD are using now
|
||||
# "sudo -E" to pass the environment variables, in particular OSLO_SERVICE_BACKEND.
|
||||
# To be removed once the default oslo.service backend is "threading".
|
||||
#OS_ROOTWRAP_CMD=sudo -E {envdir}/bin/neutron-rootwrap {envdir}/etc/neutron/rootwrap.conf
|
||||
#OS_ROOTWRAP_DAEMON_CMD=sudo -E {envdir}/bin/neutron-rootwrap-daemon {envdir}/etc/neutron/rootwrap.conf
|
||||
OS_ROOTWRAP_CMD=sudo -E
|
||||
OS_ROOTWRAP_DAEMON_CMD=
|
||||
OS_FAIL_ON_MISSING_DEPS={env:OS_FAIL_ON_MISSING_DEPS:1}
|
||||
OS_LOG_PATH={env:OS_LOG_PATH:/opt/stack/logs}
|
||||
commands = false
|
||||
@@ -69,6 +81,13 @@ setenv =
|
||||
# Because of issue with stestr and Python3, we need to avoid too much output
|
||||
# to be produced during tests, so we will ignore python warnings here
|
||||
PYTHONWARNINGS=ignore
|
||||
# NOTE(ralonsoh): remove these three variables once the eventlet removal is finished.
|
||||
# OSLO_SERVICE_BACKEND=eventlet
|
||||
# EVENTLET_MONKEYPATCH=0
|
||||
# OSKEN_HUB_TYPE=eventlet
|
||||
OSLO_SERVICE_BACKEND=threading
|
||||
EVENTLET_MONKEYPATCH=1
|
||||
OSKEN_HUB_TYPE=native
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
-r{toxinidir}/neutron/tests/functional/requirements.txt
|
||||
@@ -79,6 +98,8 @@ description =
|
||||
setenv =
|
||||
{[testenv:functional]setenv}
|
||||
{[testenv:dsvm]setenv}
|
||||
passenv =
|
||||
OS_TEST_DBAPI_ADMIN_CONNECTION
|
||||
deps =
|
||||
{[testenv:functional]deps}
|
||||
commands =
|
||||
@@ -89,6 +110,7 @@ commands =
|
||||
description =
|
||||
Run functional gate tests that require sudo privileges.
|
||||
setenv = {[testenv:dsvm-functional]setenv}
|
||||
passenv = {[testenv:dsvm-functional]passenv}
|
||||
deps = {[testenv:dsvm-functional]deps}
|
||||
test_regex = .*MySQL\.|.*test_get_all_devices|.*TestMetadataAgent\.|.*BaseOVSTestCase\.|.*test_periodic_sync_routers_task|.*TestOvnNbSync.*|.*TestOvnNbSyncOverTcp.*|.*TestOvnNbSyncOverSsl.*|.*TestOvnSbSync.*|.*TestOvnSbSyncOverTcp.*|.*TestOvnSbSyncOverSsl.*|.*TestMaintenance|.*TestLogMaintenance|.*TestNBDbMonitor.*|.*test_ovn_client.*|.*test_initialize_network_segment_range_support_parallel_execution.*|.*test_direct_route_for_address_scope.*|.*test_fip_connection_for_address_scope.*
|
||||
commands =
|
||||
|
||||
Reference in New Issue
Block a user