Commit ab4d851c authored by Romain Courteaud's avatar Romain Courteaud

WIP [ERP5] TaskDistribution: start a random test instead of looking for the smaller int_index

This prevent getting DB read/write conflicts
parent 5fa1541c
...@@ -231,18 +231,26 @@ class TaskDistributionTool(BaseTool): ...@@ -231,18 +231,26 @@ class TaskDistributionTool(BaseTool):
if test_result.getSimulationState() != 'started': if test_result.getSimulationState() != 'started':
return return
started_list = [] started_list = []
for line in test_result.objectValues(portal_type="Test Result Line",
sort_on=[("int_index","ascending")]): # Look for a test to run
# As many nodes may call this function at the same time,
# fetching all lines will create read/write DB conflicts
# To prevent this, randomize the list of documents to check
# and stop as soon as one test to run is found
line_id_list = [x for x in test_result.objectIds()]
random.shuffle(line_id_list)
for line_id in line_id_list:
line = test_result[line_id]
if (line.getPortalType() != 'Test Result Line'):
continue
test = line.getTitle() test = line.getTitle()
if test not in exclude_list: if test not in exclude_list:
state = line.getSimulationState() if line.getSimulationState() == 'draft':
test = line.getRelativeUrl(), test
if state == 'draft':
if node_title: if node_title:
node = self._getTestNodeRelativeUrl(node_title) node = self._getTestNodeRelativeUrl(node_title)
line.setSource(node) line.setSource(node)
line.start() line.start()
return test return line.getRelativeUrl(), test
security.declarePublic('stopUnitTest') security.declarePublic('stopUnitTest')
def stopUnitTest(self, test_path, status_dict, node_title=None): def stopUnitTest(self, test_path, status_dict, node_title=None):
......
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