Reset timeout exception in DietTestCase when retrying
In case of fixtures.TimeoutException, DietTestCase retries the
execution of the test case (introduced in [1]). But the timeout
fixture was not reset. This can lead to a general execution timeout
if a test do not exit in a proper time.
[1] If865c4683645f9bd11f5e1b528bade0547505bfd
Related-Bug: #1843478
Partial-Bug: #1848944
Change-Id: Ib6ef58b5259ea4bf151e866f6244ff87b195b139
(cherry picked from commit 4f59db2fab
)
This commit is contained in:
parent
94b7298c65
commit
9db46c5794
|
@ -44,6 +44,7 @@ from osprofiler import profiler
|
||||||
import six
|
import six
|
||||||
from sqlalchemy import exc as sqlalchemy_exc
|
from sqlalchemy import exc as sqlalchemy_exc
|
||||||
import testtools
|
import testtools
|
||||||
|
from testtools import content
|
||||||
|
|
||||||
from neutron._i18n import _
|
from neutron._i18n import _
|
||||||
from neutron.agent.linux import external_process
|
from neutron.agent.linux import external_process
|
||||||
|
@ -187,12 +188,14 @@ def _catch_timeout(f):
|
||||||
# declarations) this catch can be remove.
|
# declarations) this catch can be remove.
|
||||||
# [1] https://review.opendev.org/#/c/631275/
|
# [1] https://review.opendev.org/#/c/631275/
|
||||||
except fixtures.TimeoutException:
|
except fixtures.TimeoutException:
|
||||||
with excutils.save_and_reraise_exception() as ctxt:
|
if idx < TESTCASE_RETRIES:
|
||||||
if idx < TESTCASE_RETRIES:
|
msg = ('"fixtures.TimeoutException" during test case '
|
||||||
msg = ('"fixtures.TimeoutException" during test case '
|
'execution no %s; test case re-executed' % idx)
|
||||||
'execution no %s; test case re-executed' % idx)
|
self.addDetail('DietTestCase',
|
||||||
self.addDetail('DietTestCase', msg)
|
content.text_content(msg))
|
||||||
ctxt.reraise = False
|
self._set_timeout()
|
||||||
|
else:
|
||||||
|
self.fail('Execution of this test timed out')
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue