Commit 817335fc authored by Sebastien Robin's avatar Sebastien Robin

erp5_test_result: avoid relaunching test on an already tested revision

parent f7050220
...@@ -333,6 +333,38 @@ class TestTaskDistribution(ERP5TypeTestCase): ...@@ -333,6 +333,38 @@ class TestTaskDistribution(ERP5TypeTestCase):
self.assertEqual((test_result_path, revision), result) self.assertEqual((test_result_path, revision), result)
next_line_url, next_test = self.tool.startUnitTest(test_result_path) next_line_url, next_test = self.tool.startUnitTest(test_result_path)
def test_05b_createTestResultDoesNotReexecuteRevision(self):
"""
Make sure to no retest former revision. This scenario must work
- testnode call createTestResult with revision r0=b. Test is executed
- By hand is created test with revision r0=a (to make testnode checking old
revision). Test is executed
- if testnode ask again for r0=b, no test must be created
- if testnode ask for r0=c, then usual test is created/executed
"""
# launch test r0=b
test_result_path, revision = self._createTestResult(revision="r0=b", test_list=["testFoo"])
line_url, test = self.tool.startUnitTest(test_result_path)
status_dict = {}
self.tool.stopUnitTest(line_url, status_dict)
test_result = self.getPortalObject().unrestrictedTraverse(test_result_path)
self.assertEqual("stopped", test_result.getSimulationState())
# launch test r0=a
test_result_path, revision = self._createTestResult(revision="r0=a", test_list=["testFoo"])
line_url, test = self.tool.startUnitTest(test_result_path)
self.tool.stopUnitTest(line_url, status_dict)
test_result = self.getPortalObject().unrestrictedTraverse(test_result_path)
self.assertEqual("stopped", test_result.getSimulationState())
# Make sure we do not relaunch test with revision r0=b
result = self._createTestResult(revision="r0=b", test_list=["testFoo"])
self.assertEqual(None, result)
# launch test r0=c
test_result_path, revision = self._createTestResult(revision="r0=c", test_list=["testFoo"])
line_url, test = self.tool.startUnitTest(test_result_path)
self.tool.stopUnitTest(line_url, status_dict)
test_result = self.getPortalObject().unrestrictedTraverse(test_result_path)
self.assertEqual("stopped", test_result.getSimulationState())
def test_06_startStopUnitTest(self): def test_06_startStopUnitTest(self):
""" """
We will check methods startUnitTest/stopUnitTest of task distribution tool We will check methods startUnitTest/stopUnitTest of task distribution tool
......
...@@ -125,12 +125,12 @@ class TaskDistributionTool(BaseTool): ...@@ -125,12 +125,12 @@ class TaskDistributionTool(BaseTool):
else: else:
# backward compatibility # backward compatibility
int_index, reference = revision int_index, reference = revision
result_list = portal.test_result_module.searchFolder( catalog_kw = {'portal_type': 'Test Result',
portal_type="Test Result", 'title': SimpleQuery(comparison_operator='=', title=test_title),
title=SimpleQuery(comparison_operator='=', title=test_title), 'sort_on': (("creation_date","descending"),),
sort_on=(("creation_date","descending"),), 'query': NegatedQuery(SimpleQuery(simulation_state="cancelled")),
query=NegatedQuery(SimpleQuery(simulation_state="cancelled")), 'limit': 1}
limit=1) result_list = portal.test_result_module.searchFolder(**catalog_kw)
if result_list: if result_list:
test_result = result_list[0].getObject() test_result = result_list[0].getObject()
if test_result is not None: if test_result is not None:
...@@ -154,11 +154,15 @@ class TaskDistributionTool(BaseTool): ...@@ -154,11 +154,15 @@ class TaskDistributionTool(BaseTool):
return return
return test_result.getRelativeUrl(), last_revision return test_result.getRelativeUrl(), last_revision
if last_state in ('stopped', 'public_stopped'): if last_state in ('stopped', 'public_stopped'):
if not allow_restart:
if reference_list_string is not None: if reference_list_string is not None:
if reference_list_string == test_result.getReference() \ if reference_list_string == test_result.getReference():
and not allow_restart: return
if portal.test_result_module.searchFolder(
reference=SimpleQuery(comparison_operator='=', reference=reference_list_string),
**catalog_kw):
return return
elif last_revision == int_index and not allow_restart: if last_revision == int_index:
return return
test_result = portal.test_result_module.newContent( test_result = portal.test_result_module.newContent(
portal_type='Test Result', portal_type='Test Result',
......
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