Commit 0ab7d0ea authored by Sebastien Robin's avatar Sebastien Robin

fixed indentation to have proper try/except messages

parent bb451659
...@@ -281,7 +281,7 @@ branch = %(branch)s ...@@ -281,7 +281,7 @@ branch = %(branch)s
log = self.log log = self.log
log('Testnode.run, finally close') log('Testnode.run, finally close')
process_manager.killPreviousRun() process_manager.killPreviousRun()
if 0 and test_result is not None: if test_result is not None:
try: try:
test_result.removeWatch(log_file_name) test_result.removeWatch(log_file_name)
except KeyError: except KeyError:
...@@ -298,84 +298,84 @@ branch = %(branch)s ...@@ -298,84 +298,84 @@ branch = %(branch)s
test_result = None test_result = None
try: try:
while True: while True:
begin = time.time() try:
portal_url = config['test_suite_master_url'] begin = time.time()
portal = taskdistribution.TaskDistributionTool(portal_url, logger=DummyLogger(log)) portal_url = config['test_suite_master_url']
test_suite_portal = taskdistribution.TaskDistributor(portal_url, logger=DummyLogger(log)) portal = taskdistribution.TaskDistributionTool(portal_url, logger=DummyLogger(log))
test_suite_json = test_suite_portal.startTestSuite(config['test_node_title']) test_suite_portal = taskdistribution.TaskDistributor(portal_url, logger=DummyLogger(log))
test_suite_data = json.loads(test_suite_json) test_suite_json = test_suite_portal.startTestSuite(config['test_node_title'])
#Clean-up test suites test_suite_data = json.loads(test_suite_json)
self.checkOldTestSuite(test_suite_data) #Clean-up test suites
for test_suite in test_suite_data: self.checkOldTestSuite(test_suite_data)
self.updateConfigForTestSuite(test_suite) for test_suite in test_suite_data:
run_software = True self.updateConfigForTestSuite(test_suite)
self.process_manager.supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run', run_software = True
'supervisord.pid') self.process_manager.supervisord_pid_file = os.path.join(config['instance_root'], 'var', 'run',
# Write our own software.cfg to use the local repository 'supervisord.pid')
vcs_repository_list = self.constructProfile() # Write our own software.cfg to use the local repository
retry = False vcs_repository_list = self.constructProfile()
retry_software_count = 0 retry = False
same_revision_count = 0 retry_software_count = 0
test_suite_title = config['test_suite_title'] same_revision_count = 0
try: test_suite_title = config['test_suite_title']
# kill processes from previous loop if any # kill processes from previous loop if any
process_manager.killPreviousRun() process_manager.killPreviousRun()
full_revision_list = self.getFullRevisionList(revision_dict) full_revision_list = self.getFullRevisionList(revision_dict)
# Make sure we have local repository # Make sure we have local repository
now = time.time() now = time.time()
try: try:
if previous_revision_dict[test_suite_title] == revision_dict[test_suite_title]: if previous_revision_dict[test_suite_title] == revision_dict[test_suite_title]:
log('Same Revision') log('Same Revision')
same_revision_count += 1 same_revision_count += 1
if not(retry) and same_revision_count <= 2: if not(retry) and same_revision_count <= 2:
log('Sleeping a bit since same revision') log('Sleeping a bit since same revision')
time.sleep(DEFAULT_SLEEP_TIMEOUT) time.sleep(DEFAULT_SLEEP_TIMEOUT)
continue continue
same_revision_count = 0 same_revision_count = 0
log('Retrying install or checking if previous test was cancelled') log('Retrying install or checking if previous test was cancelled')
except KeyError: except KeyError:
pass pass
retry = False retry = False
previous_revision_dict[test_suite_title] = revision_dict[test_suite_title] previous_revision_dict[test_suite_title] = revision_dict[test_suite_title]
now = time.time() now = time.time()
test_result = portal.createTestResult(revision_dict[test_suite_title],[], test_result = portal.createTestResult(revision_dict[test_suite_title],[],
config['test_node_title'],False,test_suite_title,config['project_title']) config['test_node_title'],False,test_suite_title,config['project_title'])
remote_test_result_needs_cleanup = True remote_test_result_needs_cleanup = True
log("testnode, test_result : %r" % (test_result, )) log("testnode, test_result : %r" % (test_result, ))
if test_result is not None:
log_file_name = self.addWatcher(test_result)
self.checkRevision(test_result,revision_dict,previous_revision_dict,
vcs_repository_list)
# Now prepare the installation of SlapOS and create instance
status_dict = self.prepareSlapOS(retry_software_count,retry)
# Give some time so computer partitions may start
# as partitions can be of any kind we have and likely will never have
# a reliable way to check if they are up or not ...
time.sleep(20)
self.runTestSuite(revision_dict,portal_url)
test_result.removeWatch(log_file_name)
except SubprocessError, e:
log("SubprocessError", exc_info=sys.exc_info())
if test_result is not None: if test_result is not None:
log_file_name = self.addWatcher(test_result)
self.checkRevision(test_result,revision_dict,previous_revision_dict,
vcs_repository_list)
# Now prepare the installation of SlapOS and create instance
status_dict = self.prepareSlapOS(retry_software_count,retry)
# Give some time so computer partitions may start
# as partitions can be of any kind we have and likely will never have
# a reliable way to check if they are up or not ...
time.sleep(20)
self.runTestSuite(revision_dict,portal_url)
test_result.removeWatch(log_file_name) test_result.removeWatch(log_file_name)
if remote_test_result_needs_cleanup: except SubprocessError, e:
status_dict = e.status_dict or {} log("SubprocessError", exc_info=sys.exc_info())
test_result.reportFailure( if test_result is not None:
command=status_dict.get('command'), test_result.removeWatch(log_file_name)
stdout=status_dict.get('stdout'), if remote_test_result_needs_cleanup:
stderr=status_dict.get('stderr'), status_dict = e.status_dict or {}
) test_result.reportFailure(
log("SubprocessError, going to sleep %s" % DEFAULT_SLEEP_TIMEOUT) command=status_dict.get('command'),
time.sleep(DEFAULT_SLEEP_TIMEOUT) stdout=status_dict.get('stdout'),
continue stderr=status_dict.get('stderr'),
except CancellationError, e: )
log("CancellationError", exc_info=sys.exc_info()) log("SubprocessError, going to sleep %s" % DEFAULT_SLEEP_TIMEOUT)
process_manager.under_cancellation = False time.sleep(DEFAULT_SLEEP_TIMEOUT)
retry = True continue
continue except CancellationError, e:
except: log("CancellationError", exc_info=sys.exc_info())
log("erp5testnode exception", exc_info=sys.exc_info()) process_manager.under_cancellation = False
raise retry = True
continue
except:
log("erp5testnode exception", exc_info=sys.exc_info())
raise
if (now-begin) < 120: if (now-begin) < 120:
time.sleep(120 - (now-begin)) time.sleep(120 - (now-begin))
finally: finally:
......
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