Commit ee9683f8 authored by Romain Courteaud's avatar Romain Courteaud

jstestnode: catch all errors

parent b3685251
...@@ -20,6 +20,7 @@ FIREFOX_EXECUTABLE = '$${firefox-instance:executable}' ...@@ -20,6 +20,7 @@ FIREFOX_EXECUTABLE = '$${firefox-instance:executable}'
BASE_URL = 'http://[$${nginx-configuration:ip}]:$${nginx-configuration:port}/' BASE_URL = 'http://[$${nginx-configuration:ip}]:$${nginx-configuration:port}/'
def main(): def main():
try:
parser = argparse.ArgumentParser(description='Run a test suite.') parser = argparse.ArgumentParser(description='Run a test suite.')
parser.add_argument('--test_suite', help='The test suite name') parser.add_argument('--test_suite', help='The test suite name')
parser.add_argument('--test_suite_title', help='The test suite title') parser.add_argument('--test_suite_title', help='The test suite title')
...@@ -34,25 +35,27 @@ def main(): ...@@ -34,25 +35,27 @@ def main():
args = parser.parse_args() args = parser.parse_args()
test_suite_title = args.test_suite_title or args.test_suite test_suite_title = args.test_suite_title or args.test_suite
test_suite = args.test_suite
revision = args.revision revision = args.revision
test_line_dict = {} test_line_dict = {}
if ('jio' in test_suite_title): if ('jio' in test_suite):
url = BASE_URL + '/jio/test/tests.html' url = BASE_URL + 'jio/test/tests.html'
else: else:
url = BASE_URL + '/renderjs/test/' url = BASE_URL + 'renderjs/test/'
date = strftime("%Y/%m/%d %H:%M:%S", gmtime()) date = strftime("%Y/%m/%d %H:%M:%S", gmtime())
########################## ##########################
# Run all tests # Run all tests
########################## ##########################
try:
firefox_binary = webdriver.firefox.firefox_binary.FirefoxBinary(firefox_path=FIREFOX_EXECUTABLE) firefox_binary = webdriver.firefox.firefox_binary.FirefoxBinary(firefox_path=FIREFOX_EXECUTABLE)
browser = webdriver.Firefox(firefox_binary=firefox_binary) browser = webdriver.Firefox(firefox_binary=firefox_binary)
agent = browser.execute_script("return navigator.userAgent") agent = browser.execute_script("return navigator.userAgent")
print agent print agent
print url
browser.get(url) browser.get(url)
WebDriverWait(browser, 60).until(EC.presence_of_element_located(( WebDriverWait(browser, 60).until(EC.presence_of_element_located((
...@@ -87,16 +90,6 @@ def main(): ...@@ -87,16 +90,6 @@ def main():
browser.quit() browser.quit()
except Exception:
# Catch any exception here, to warn user instead of being silent,
# by generating fake error result
result = dict(status_code=-1,
command=url,
stderr=traceback.format_exc(),
stdout='')
# XXX: inform test node master of error
raise EnvironmentError(result)
tool = taskdistribution.TaskDistributionTool(portal_url=args.master_url) tool = taskdistribution.TaskDistributionTool(portal_url=args.master_url)
test_result = tool.createTestResult(revision = revision, test_result = tool.createTestResult(revision = revision,
test_name_list = test_line_dict.keys(), test_name_list = test_line_dict.keys(),
...@@ -109,10 +102,22 @@ def main(): ...@@ -109,10 +102,22 @@ def main():
while 1: while 1:
test_result_line = test_result.start() test_result_line = test_result.start()
if not test_result_line: if not test_result_line:
print 'No test result anymore.'
break break
print 'Submitting: "%s"' % test_result_line.name
# report status back to Nexedi ERP5 # report status back to Nexedi ERP5
test_result_line.stop(**test_line_dict[test_result_line.name]) test_result_line.stop(**test_line_dict[test_result_line.name])
except Exception:
# Catch any exception here, to warn user instead of being silent,
# by generating fake error result
result = dict(status_code=-1,
command=url,
stderr=traceback.format_exc(),
stdout='')
# XXX: inform test node master of error
raise EnvironmentError(result)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -106,7 +106,7 @@ mode = 0644 ...@@ -106,7 +106,7 @@ mode = 0644
[template-runTestSuite] [template-runTestSuite]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/runTestSuite.in url = ${:_profile_base_location_}/runTestSuite.in
md5sum = e2ccc99c510416b7cfa3134799a733fb md5sum = 57c151675d13fdae1af82664ebe3269f
output = ${buildout:directory}/runTestSuite.in output = ${buildout:directory}/runTestSuite.in
mode = 0644 mode = 0644
......
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