Commit 6a7849bd authored by Jérome Perrin's avatar Jérome Perrin

test_result: fix "Retry Count" being acquired on test result line

At the end of test result, we calculate the sum of test result line
retries and set it as a property on test result. Listbox will then
show for each test result line the number of retries. Problem is
that we did not set retry count property on test result lines which
were not retried, so they acquired this from the parent test result.

To prevent this, always set a retry count property on test result
and set it to 0 when they are not retried.
parent 5341bf54
Pipeline #11772 failed with stage
in 0 seconds
...@@ -1505,6 +1505,44 @@ class TestRetryFailedTest(TaskDistributionTestCase): ...@@ -1505,6 +1505,44 @@ class TestRetryFailedTest(TaskDistributionTestCase):
self.assertEqual(test_result.getSimulationState(), 'stopped') self.assertEqual(test_result.getSimulationState(), 'stopped')
self.assertEqual(test_result.getProperty('test_result_retry_count'), 1) self.assertEqual(test_result.getProperty('test_result_retry_count'), 1)
def test_retried_retry_count_acquisition(self):
# non regression test, test_result_retry_count should not be acquired
# from test result on test result lines that were not retried.
self.test_suite.setRetryTestPattern('test.*')
test_result_path, _ = self._createTestResult(test_list=['testFoo', 'testBar' ])
test_result = self.portal.unrestrictedTraverse(test_result_path)
line_url, _ = self.tool.startUnitTest(test_result_path)
retried_test_result_line = self.portal.restrictedTraverse(line_url)
status_dict = {
'test_count': 100,
'error_count': 2,
'failure_count': 3,
}
self.tool.stopUnitTest(line_url, status_dict)
self.tic()
self.assertEqual(retried_test_result_line.getStringIndex(), 'RETRYING')
self.assertEqual(retried_test_result_line.getSimulationState(), 'draft')
status_dict['error_count'] = 0
status_dict['failure_count'] = 0
self.tool.stopUnitTest(line_url, status_dict)
self.tic()
self.assertEqual(retried_test_result_line.getStringIndex(), 'PASSED')
self.assertEqual(retried_test_result_line.getSimulationState(), 'stopped')
line_url, _ = self.tool.startUnitTest(test_result_path)
not_retried_test_result_line = self.portal.restrictedTraverse(line_url)
self.assertNotEqual(retried_test_result_line, not_retried_test_result_line)
self.tool.stopUnitTest(line_url, status_dict)
self.tic()
self.assertEqual(not_retried_test_result_line.getStringIndex(), 'PASSED')
self.assertEqual(not_retried_test_result_line.getSimulationState(), 'stopped')
self.assertEqual(test_result.getStringIndex(), 'PASS')
self.assertEqual(test_result.getSimulationState(), 'stopped')
self.assertEqual(test_result.getProperty('test_result_retry_count'), 1)
self.assertEqual(retried_test_result_line.getProperty('test_result_retry_count'), 1)
self.assertEqual(not_retried_test_result_line.getProperty('test_result_retry_count'), 0)
class TestGitlabRESTConnectorInterface(ERP5TypeTestCase): class TestGitlabRESTConnectorInterface(ERP5TypeTestCase):
"""Tests for Gitlab commits annotations. """Tests for Gitlab commits annotations.
......
...@@ -88,10 +88,11 @@ elif test_result.getPortalType() == 'Test Result Line': ...@@ -88,10 +88,11 @@ elif test_result.getPortalType() == 'Test Result Line':
errors=errors, errors=errors,
failures=failures, failures=failures,
skips=skips, skips=skips,
test_result_retry_count=(test_result.getProperty('test_result_retry_count') or 0),
html_test_result=html_test_result) html_test_result=html_test_result)
if status == 'FAILED' and shouldRetry(test_result): if status == 'FAILED' and shouldRetry(test_result):
test_result.edit( test_result.edit(
test_result_retry_count=1 + (test_result.getProperty('test_result_retry_count') or 0), test_result_retry_count=test_result.getProperty('test_result_retry_count') + 1,
string_index='RETRYING', string_index='RETRYING',
) )
test_result.redraft(comment="Retried after a first failure") test_result.redraft(comment="Retried after a first failure")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment