Commit faa6705c authored by Sebastien Robin's avatar Sebastien Robin

erp5_test_result: avoid useless failures when a test suite is invalidated

parent 037b5f10
...@@ -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,8 +391,9 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -391,8 +391,9 @@ 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)
test_suite.setPingDate() if test_suite is not None:
return portal.portal_task_distribution_tool.createTestResult(name, test_suite.setPingDate()
return portal.portal_task_distribution_tool.createTestResult(name,
revision, test_name_list, allow_restart, revision, test_name_list, allow_restart,
test_title=title_title, node_title=node_title, test_title=title_title, node_title=node_title,
project_title=project_title) project_title=project_title)
...@@ -412,9 +413,11 @@ class ERP5ProjectUnitTestDistributor(XMLObject): ...@@ -412,9 +413,11 @@ 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 = test_suite_list[0].getObject() test_suite = None
if len(test_suite_list):
test_suite = test_suite_list[0].getObject()
return test_suite return test_suite
security.declarePublic("startUnitTest") security.declarePublic("startUnitTest")
...@@ -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)
cluster_configuration = test_suite.getClusterConfiguration() or '{}' generated_configuration = {"configuration_list": [{}]}
try: if test_suite is not None:
generated_configuration = {"configuration_list": [json.loads(cluster_configuration)]} cluster_configuration = test_suite.getClusterConfiguration() or '{}'
except ValueError: try:
generated_configuration = {"configuration_list": [{}]} generated_configuration = {"configuration_list": [json.loads(cluster_configuration)]}
except ValueError:
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