Merge "Remove the `eventlet.Timeout` testcase capture"
This commit is contained in:
@@ -17,7 +17,6 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import abc
|
import abc
|
||||||
import contextlib
|
|
||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import logging
|
import logging
|
||||||
@@ -28,7 +27,6 @@ import threading
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import eventlet.timeout
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from neutron_lib.callbacks import manager as registry_manager
|
from neutron_lib.callbacks import manager as registry_manager
|
||||||
from neutron_lib.db import api as db_api
|
from neutron_lib.db import api as db_api
|
||||||
@@ -176,8 +174,6 @@ def _catch_errors(f):
|
|||||||
def func(self, *args, **kwargs):
|
def func(self, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return f(self, *args, **kwargs)
|
return f(self, *args, **kwargs)
|
||||||
except eventlet.Timeout as e:
|
|
||||||
self.fail('Execution of this test timed out: %s' % e)
|
|
||||||
except db_exceptions.DBReferenceError:
|
except db_exceptions.DBReferenceError:
|
||||||
# TODO(ralonsoh): fix the ``DBReferenceError`` issues in the functional
|
# TODO(ralonsoh): fix the ``DBReferenceError`` issues in the functional
|
||||||
# tests. This is retrying the test execution once more. If it fails
|
# tests. This is retrying the test execution once more. If it fails
|
||||||
@@ -200,10 +196,6 @@ class _CatchErrorsMetaclass(abc.ABCMeta):
|
|||||||
setattr(cls, name, _catch_errors(method))
|
setattr(cls, name, _catch_errors(method))
|
||||||
|
|
||||||
|
|
||||||
# Test worker cannot survive eventlet's Timeout exception, which effectively
|
|
||||||
# kills the whole worker, with all test cases scheduled to it. This metaclass
|
|
||||||
# makes all test cases convert Timeout exceptions into unittest friendly
|
|
||||||
# failure mode (self.fail).
|
|
||||||
class DietTestCase(base.BaseTestCase, metaclass=_CatchErrorsMetaclass):
|
class DietTestCase(base.BaseTestCase, metaclass=_CatchErrorsMetaclass):
|
||||||
"""Same great taste, less filling.
|
"""Same great taste, less filling.
|
||||||
|
|
||||||
@@ -305,13 +297,6 @@ class DietTestCase(base.BaseTestCase, metaclass=_CatchErrorsMetaclass):
|
|||||||
# This makes sys.exit(0) still a failure
|
# This makes sys.exit(0) still a failure
|
||||||
self.force_failure = True
|
self.force_failure = True
|
||||||
|
|
||||||
@contextlib.contextmanager
|
|
||||||
def assert_max_execution_time(self, max_execution_time=5):
|
|
||||||
with eventlet.Timeout(max_execution_time, False):
|
|
||||||
yield
|
|
||||||
return
|
|
||||||
self.fail('Execution of this test timed out')
|
|
||||||
|
|
||||||
def assertOrderedEqual(self, expected, actual):
|
def assertOrderedEqual(self, expected, actual):
|
||||||
expect_val = self.sort_dict_lists(expected)
|
expect_val = self.sort_dict_lists(expected)
|
||||||
actual_val = self.sort_dict_lists(actual)
|
actual_val = self.sort_dict_lists(actual)
|
||||||
|
|||||||
@@ -227,18 +227,17 @@ class L3AgentTestFramework(base.BaseSudoTestCase):
|
|||||||
if ha:
|
if ha:
|
||||||
self.wait_until_ha_router_has_state(router, 'primary')
|
self.wait_until_ha_router_has_state(router, 'primary')
|
||||||
|
|
||||||
with self.assert_max_execution_time(100):
|
assert_num_of_conntrack_rules(0)
|
||||||
assert_num_of_conntrack_rules(0)
|
|
||||||
|
|
||||||
self.assertTrue(netcat.test_connectivity())
|
self.assertTrue(netcat.test_connectivity())
|
||||||
assert_num_of_conntrack_rules(1)
|
assert_num_of_conntrack_rules(1)
|
||||||
|
|
||||||
clean_fips(router)
|
clean_fips(router)
|
||||||
router.process()
|
router.process()
|
||||||
assert_num_of_conntrack_rules(0)
|
assert_num_of_conntrack_rules(0)
|
||||||
|
|
||||||
with testtools.ExpectedException(RuntimeError):
|
with testtools.ExpectedException(RuntimeError):
|
||||||
netcat.test_connectivity()
|
netcat.test_connectivity()
|
||||||
|
|
||||||
def _test_update_floatingip_statuses(self, router_info):
|
def _test_update_floatingip_statuses(self, router_info):
|
||||||
router = self.manage_router(self.agent, router_info)
|
router = self.manage_router(self.agent, router_info)
|
||||||
|
|||||||
@@ -116,12 +116,10 @@ class TestAsyncProcess(base.BaseTestCase):
|
|||||||
|
|
||||||
thread_exit_event = threading.Event()
|
thread_exit_event = threading.Event()
|
||||||
|
|
||||||
# Ensure the test times out eventually if the watcher loops endlessly
|
with mock.patch.object(self.proc,
|
||||||
with self.assert_max_execution_time():
|
'_handle_process_error') as func:
|
||||||
with mock.patch.object(self.proc,
|
self.proc._watch_process(
|
||||||
'_handle_process_error') as func:
|
callback, kill_event, thread_exit_event)
|
||||||
self.proc._watch_process(
|
|
||||||
callback, kill_event, thread_exit_event)
|
|
||||||
|
|
||||||
if not kill_event.is_set():
|
if not kill_event.is_set():
|
||||||
func.assert_called_once_with()
|
func.assert_called_once_with()
|
||||||
|
|||||||
@@ -14,21 +14,12 @@
|
|||||||
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from ovsdbapp import exceptions
|
|
||||||
from ovsdbapp.schema.open_vswitch import impl_idl
|
from ovsdbapp.schema.open_vswitch import impl_idl
|
||||||
import testtools
|
|
||||||
|
|
||||||
from neutron.tests import base
|
from neutron.tests import base
|
||||||
|
|
||||||
|
|
||||||
class TransactionTestCase(base.BaseTestCase):
|
class TransactionTestCase(base.BaseTestCase):
|
||||||
def test_commit_raises_exception_on_timeout(self):
|
|
||||||
transaction = impl_idl.OvsVsctlTransaction(mock.sentinel,
|
|
||||||
mock.Mock(), 1)
|
|
||||||
with self.assert_max_execution_time(10):
|
|
||||||
with testtools.ExpectedException(exceptions.TimeoutException):
|
|
||||||
transaction.commit()
|
|
||||||
|
|
||||||
def test_post_commit_does_not_raise_exception(self):
|
def test_post_commit_does_not_raise_exception(self):
|
||||||
with mock.patch.object(impl_idl.OvsVsctlTransaction,
|
with mock.patch.object(impl_idl.OvsVsctlTransaction,
|
||||||
"do_post_commit", side_effect=Exception):
|
"do_post_commit", side_effect=Exception):
|
||||||
|
|||||||
@@ -83,12 +83,9 @@ class NetworkRbacTestcase(test_plugin.NeutronDbPluginV2TestCase):
|
|||||||
tenant,
|
tenant,
|
||||||
rbac_db_models.ACCESS_SHARED)
|
rbac_db_models.ACCESS_SHARED)
|
||||||
self.plugin.create_rbac_policy(self.context, policy)
|
self.plugin.create_rbac_policy(self.context, policy)
|
||||||
# Give server maximum of 10 seconds to make sure we don't hit DB
|
with testtools.ExpectedException(
|
||||||
# retry mechanism when resource already exists
|
ext_rbac.DuplicateRbacPolicy):
|
||||||
with self.assert_max_execution_time(10):
|
self.plugin.create_rbac_policy(self.context, policy)
|
||||||
with testtools.ExpectedException(
|
|
||||||
ext_rbac.DuplicateRbacPolicy):
|
|
||||||
self.plugin.create_rbac_policy(self.context, policy)
|
|
||||||
|
|
||||||
def test_update_network_rbac_external_valid(self):
|
def test_update_network_rbac_external_valid(self):
|
||||||
orig_target = 'test-tenant-2'
|
orig_target = 'test-tenant-2'
|
||||||
|
|||||||
Reference in New Issue
Block a user