Commit f7319ec9 authored by Sebastien Robin's avatar Sebastien Robin

erp5.util.testnode: do not block all test suites if one of them define broken repository

parent b56e3520
...@@ -38,6 +38,7 @@ class ERP5TestNode(TestCase): ...@@ -38,6 +38,7 @@ class ERP5TestNode(TestCase):
self.remote_repository0 = os.path.join(self._temp_dir, 'rep0') self.remote_repository0 = os.path.join(self._temp_dir, 'rep0')
self.remote_repository1 = os.path.join(self._temp_dir, 'rep1') self.remote_repository1 = os.path.join(self._temp_dir, 'rep1')
self.remote_repository2 = os.path.join(self._temp_dir, 'rep2') self.remote_repository2 = os.path.join(self._temp_dir, 'rep2')
self.remote_repository_broken = os.path.join(self._temp_dir, 'broken')
self.system_temp_folder = os.path.join(self._temp_dir,'tmp') self.system_temp_folder = os.path.join(self._temp_dir,'tmp')
os.mkdir(self.working_directory) os.mkdir(self.working_directory)
os.mkdir(self.slapos_directory) os.mkdir(self.slapos_directory)
...@@ -89,7 +90,8 @@ class ERP5TestNode(TestCase): ...@@ -89,7 +90,8 @@ class ERP5TestNode(TestCase):
return TestNode(self.log, config) return TestNode(self.log, config)
def getTestSuiteData(self, add_third_repository=False, reference="foo"): def getTestSuiteData(self, add_third_repository=False,
add_broken_repository=False, reference="foo"):
data = [{ data = [{
"test_suite": "Foo", "test_suite": "Foo",
"project_title": reference, "project_title": reference,
...@@ -110,15 +112,22 @@ class ERP5TestNode(TestCase): ...@@ -110,15 +112,22 @@ class ERP5TestNode(TestCase):
{'url': self.remote_repository2, {'url': self.remote_repository2,
'buildout_section_id': 'rep2', 'buildout_section_id': 'rep2',
'branch': 'foo'}) 'branch': 'foo'})
if add_broken_repository:
data[0]['vcs_repository_list'].append(
{'url': self.remote_repository_broken,
'buildout_section_id': 'rep2',
'branch': 'foo'})
return data return data
def updateNodeTestSuiteData(self, node_test_suite, def updateNodeTestSuiteData(self, node_test_suite,
add_third_repository=False): add_third_repository=False,
add_broken_repository=False):
""" """
Update from zero/Regenerate the testsuite Update from zero/Regenerate the testsuite
""" """
node_test_suite.edit(working_directory=self.working_directory, node_test_suite.edit(working_directory=self.working_directory,
**self.getTestSuiteData(add_third_repository=add_third_repository)[0]) **self.getTestSuiteData(add_third_repository=add_third_repository,
add_broken_repository=add_broken_repository)[0])
def getCaller(self, **kw): def getCaller(self, **kw):
class Caller(object): class Caller(object):
...@@ -360,7 +369,7 @@ develop = false ...@@ -360,7 +369,7 @@ develop = false
finally: finally:
Updater.deleteRepository = original_deleteRepository Updater.deleteRepository = original_deleteRepository
def test_05d_LocalModifcationOnRepository(self): def test_05d_LocalModificationOnRepository(self):
""" """
It could happen that there is local modification to to either bug of It could happen that there is local modification to to either bug of
git or any manual operation. git or any manual operation.
...@@ -389,6 +398,19 @@ develop = false ...@@ -389,6 +398,19 @@ develop = false
self.assertEqual("initial_content0", my_file.read()) self.assertEqual("initial_content0", my_file.read())
my_file.close() my_file.close()
def test_05e_IgnoringIncorrectRepository(self):
"""
If someone add a test suite with a bad url for git repository (or wrong
crendentials), the testnode should not block forever and should work on
other test suites. This method should be able to run
"""
commit_dict = self.generateTestRepositoryList()
test_node = self.getTestNode()
node_test_suite = test_node.getNodeTestSuite('foo')
self.updateNodeTestSuiteData(node_test_suite, add_broken_repository=True)
rev_list = test_node.getAndUpdateFullRevisionList(node_test_suite)
self.assertEqual(None, rev_list)
def test_06_checkRevision(self): def test_06_checkRevision(self):
""" """
Check if we are able to restore older commit hash if master decide so Check if we are able to restore older commit hash if master decide so
......
...@@ -189,6 +189,7 @@ develop = false ...@@ -189,6 +189,7 @@ develop = false
full_revision_list = [] full_revision_list = []
config = self.config config = self.config
log = self.log log = self.log
try:
for vcs_repository in node_test_suite.vcs_repository_list: for vcs_repository in node_test_suite.vcs_repository_list:
repository_path = vcs_repository['repository_path'] repository_path = vcs_repository['repository_path']
repository_id = vcs_repository['repository_id'] repository_id = vcs_repository['repository_id']
...@@ -202,6 +203,9 @@ develop = false ...@@ -202,6 +203,9 @@ develop = false
revision = "-".join(updater.getRevision()) revision = "-".join(updater.getRevision())
full_revision_list.append('%s=%s' % (repository_id, revision)) full_revision_list.append('%s=%s' % (repository_id, revision))
node_test_suite.revision = ','.join(full_revision_list) node_test_suite.revision = ','.join(full_revision_list)
except SubprocessError, e:
log("Error while getting repository, ignoring this test suite : %r" % (e,), exc_info=sys.exc_info())
full_revision_list = None
return full_revision_list return full_revision_list
def registerSuiteLog(self, test_result, node_test_suite): def registerSuiteLog(self, test_result, node_test_suite):
...@@ -379,7 +383,9 @@ from the distributor.") ...@@ -379,7 +383,9 @@ from the distributor.")
run_software = True run_software = True
# kill processes from previous loop if any # kill processes from previous loop if any
self.process_manager.killPreviousRun() self.process_manager.killPreviousRun()
self.getAndUpdateFullRevisionList(node_test_suite) revision_list = self.getAndUpdateFullRevisionList(node_test_suite)
if revision_list is None:
continue
# Write our own software.cfg to use the local repository # Write our own software.cfg to use the local repository
self.constructProfile(node_test_suite, my_test_type, self.constructProfile(node_test_suite, my_test_type,
runner.getRelativePathUsage()) runner.getRelativePathUsage())
...@@ -432,7 +438,7 @@ from the distributor.") ...@@ -432,7 +438,7 @@ from the distributor.")
break break
self.cleanUp(test_result) self.cleanUp(test_result)
except (SubprocessError, CalledProcessError, RequestException) as e: except (SubprocessError, CalledProcessError, RequestException) as e:
log("SubprocessError or RequestException", exc_info=sys.exc_info()) log("SubprocessError or RequestException : %r" % (e,), exc_info=sys.exc_info())
if remote_test_result_needs_cleanup: if remote_test_result_needs_cleanup:
status_dict = e.status_dict or {} status_dict = e.status_dict or {}
test_result.reportFailure( test_result.reportFailure(
...@@ -443,7 +449,7 @@ from the distributor.") ...@@ -443,7 +449,7 @@ from the distributor.")
continue continue
except ValueError as e: except ValueError as e:
# This could at least happens if runTestSuite is not found # This could at least happens if runTestSuite is not found
log("ValueError", exc_info=sys.exc_info()) log("ValueError : %r" % (e,), exc_info=sys.exc_info())
if node_test_suite is not None: if node_test_suite is not None:
node_test_suite.retry_software_count += 1 node_test_suite.retry_software_count += 1
if remote_test_result_needs_cleanup: if remote_test_result_needs_cleanup:
...@@ -467,8 +473,8 @@ from the distributor.") ...@@ -467,8 +473,8 @@ from the distributor.")
sleep_time = 120 - (now-begin) sleep_time = 120 - (now-begin)
log("End of processing, going to sleep %s" % sleep_time) log("End of processing, going to sleep %s" % sleep_time)
time.sleep(sleep_time) time.sleep(sleep_time)
except: except Exception as e:
log("Exception in error handling", exc_info=sys.exc_info()) log("Exception in error handling : %r" % (e,), exc_info=sys.exc_info())
finally: finally:
if 'tb' in locals(): if 'tb' in locals():
del tb del tb
......
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