[IMP] tests: allow to disable auto retry
Auto retry can be usefull to avoid breaking a build because of a small tour or query count, but for long tests like qunit, this can be painfull when a real error is triggered. This commit proposes to disable autoretry on demand for some tests to solve this issue. This may be applied on all tests longer than a few seconds. closes odoo/odoo#95440 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
This commit is contained in:
@@ -10,6 +10,7 @@ RE_ONLY = re.compile(r'QUnit\.(only|debug)\(')
|
||||
@odoo.tests.tagged('post_install', '-at_install')
|
||||
class WebSuite(odoo.tests.HttpCase):
|
||||
|
||||
@odoo.tests.no_retry
|
||||
def test_js(self):
|
||||
# webclient desktop test suite
|
||||
self.browser_js('/web/tests?mod=web', "", "", login='admin', timeout=1800)
|
||||
|
||||
+14
-1
@@ -388,7 +388,14 @@ class BaseCase(unittest.TestCase, metaclass=MetaCase):
|
||||
self.addTypeEqualityFunc(html.HtmlElement, self.assertTreesEqual)
|
||||
|
||||
def run(self, result):
|
||||
tests_run_count = int(os.environ.get('ODOO_TEST_FAILURE_RETRIES', 0)) + 1
|
||||
testMethod = getattr(self, self._testMethodName)
|
||||
|
||||
if getattr(testMethod, '_retry', True) and getattr(self, '_retry', True):
|
||||
tests_run_count = int(os.environ.get('ODOO_TEST_FAILURE_RETRIES', 0)) + 1
|
||||
else:
|
||||
tests_run_count = 1
|
||||
_logger.info('Auto retry disabled for %s', self)
|
||||
|
||||
failure = False
|
||||
for retry in range(tests_run_count):
|
||||
if retry:
|
||||
@@ -1768,6 +1775,12 @@ class HttpSavepointCase(HttpCase):
|
||||
)
|
||||
|
||||
|
||||
def no_retry(arg):
|
||||
"""Disable auto retry on decorated test method or test class"""
|
||||
arg._retry = False
|
||||
return arg
|
||||
|
||||
|
||||
def users(*logins):
|
||||
""" Decorate a method to execute it once for each given user. """
|
||||
@decorator
|
||||
|
||||
Reference in New Issue
Block a user