Commit 85659f60 authored by Sebastien Robin's avatar Sebastien Robin Committed by Tristan Cavelier

CHERRY-PICKED erp5_test_result: avoid useless failures when a test suite is invalidated

parent 60e118e0
...@@ -512,6 +512,10 @@ class TestTaskDistribution(ERP5TypeTestCase): ...@@ -512,6 +512,10 @@ class TestTaskDistribution(ERP5TypeTestCase):
self.assertEquals('{"configuration_list": [{}]}', self.distributor.generateConfiguration(test_suite.getTitle())) self.assertEquals('{"configuration_list": [{}]}', self.distributor.generateConfiguration(test_suite.getTitle()))
test_suite.setClusterConfiguration('{"foo": 3}') test_suite.setClusterConfiguration('{"foo": 3}')
self.assertEquals('{"configuration_list": [{"foo": 3}]}', self.distributor.generateConfiguration(test_suite.getTitle())) self.assertEquals('{"configuration_list": [{"foo": 3}]}', self.distributor.generateConfiguration(test_suite.getTitle()))
# make sure generateConfiguration does not fail if test suite is invalidated
test_suite.invalidate()
self.tic()
self.assertEquals('{"configuration_list": [{}]}', self.distributor.generateConfiguration(test_suite.getTitle()))
def _checkTestSuiteAggregateList(self, *args): def _checkTestSuiteAggregateList(self, *args):
self.tic() self.tic()
......
...@@ -391,6 +391,7 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -391,6 +391,7 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
test_node = self._getTestNodeFromTitle(node_title) test_node = self._getTestNodeFromTitle(node_title)
test_node.setPingDate() test_node.setPingDate()
test_suite = self._getTestSuiteFromTitle(name) test_suite = self._getTestSuiteFromTitle(name)
if test_suite is not None:
test_suite.setPingDate() test_suite.setPingDate()
return portal.portal_task_distribution_tool.createTestResult(name, return portal.portal_task_distribution_tool.createTestResult(name,
revision, test_name_list, allow_restart, revision, test_name_list, allow_restart,
...@@ -412,8 +413,10 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -412,8 +413,10 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
portal_type='Test Suite', portal_type='Test Suite',
title=SimpleQuery(comparison_operator='=', title=suite_title), title=SimpleQuery(comparison_operator='=', title=suite_title),
validation_state='validated') validation_state='validated')
assert len(test_suite_list) == 1, "We found %i test suite for %s" % ( assert len(test_suite_list) <= 1, "We found %i test suite for %s" % (
len(test_suite_list), suite_title) len(test_suite_list), suite_title)
test_suite = None
if len(test_suite_list):
test_suite = test_suite_list[0].getObject() test_suite = test_suite_list[0].getObject()
return test_suite return test_suite
...@@ -445,11 +448,13 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -445,11 +448,13 @@ class ERP5ProjectUnitTestDistributor(XMLObject):
always return a list. always return a list.
""" """
test_suite = self._getTestSuiteFromTitle(test_suite_title) test_suite = self._getTestSuiteFromTitle(test_suite_title)
generated_configuration = {"configuration_list": [{}]}
if test_suite is not None:
cluster_configuration = test_suite.getClusterConfiguration() or '{}' cluster_configuration = test_suite.getClusterConfiguration() or '{}'
try: try:
generated_configuration = {"configuration_list": [json.loads(cluster_configuration)]} generated_configuration = {"configuration_list": [json.loads(cluster_configuration)]}
except ValueError: except ValueError:
generated_configuration = {"configuration_list": [{}]} pass
if batch_mode: if batch_mode:
return generated_configuration return generated_configuration
return json.dumps(generated_configuration) return json.dumps(generated_configuration)
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