Commit 861f1136 authored by Julien Muchembled's avatar Julien Muchembled

wip

parent bf01075e
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
""" """
Script to run NEO test suite using Nexedi's test node framework. Script to run NEO test suite using Nexedi's test node framework.
""" """
import argparse, sys, subprocess, os, glob import argparse, os, re, shutil, subprocess, sys, traceback
import traceback
from erp5.util import taskdistribution from erp5.util import taskdistribution
import re
from time import gmtime, strftime from time import gmtime, strftime
# pattern to get test counts from stdout # pattern to get test counts from stdout
...@@ -14,26 +12,12 @@ SUMMARY_RE = re.compile( \ ...@@ -14,26 +12,12 @@ SUMMARY_RE = re.compile( \
re.MULTILINE) re.MULTILINE)
# NEO specific environment # NEO specific environment
TEMP_DIRECTORY = '{{neo_temp_directory}}/neotest_tmp' TEMP_DIRECTORY = '{{neo_temp_directory}}'
MYSQL_UNIX_PORT = '{{my_cnf_parameters.socket}}' NEO_DB_SOCKET = '{{my_cnf_parameters.socket}}'
NEO_TESTS_ADAPTER = 'SQLite'
RUN_NEO_TESTS_COMMAND = '{{ neotestrunner }}' RUN_NEO_TESTS_COMMAND = '{{ neotestrunner }}'
def cleanup():
"""
Clean up from previous runs.
"""
for root, dirs, files in os.walk(TEMP_DIRECTORY, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
os.rmdir(os.path.join(root, name))
if NEO_TESTS_ADAPTER == 'MySQL':
# XXX: remove MySQL
pass
def parseTestStdOut(data): def parseTestStdOut(data):
""" """
Parse output of NEO testrunner script. Parse output of NEO testrunner script.
""" """
test_count = 0 test_count = 0
...@@ -80,28 +64,13 @@ def main(): ...@@ -80,28 +64,13 @@ def main():
parser.add_argument('--master_url', parser.add_argument('--master_url',
help='The Url of Master controling many suites', help='The Url of Master controling many suites',
default=None) default=None)
parser.add_argument('--db_list', help='A list of sql connection strings')
# parameters that needs to be passed to runUnitTest
parser.add_argument('--conversion_server_hostname', default=None)
parser.add_argument('--conversion_server_port', default=None)
parser.add_argument('--volatile_memcached_server_hostname', default=None)
parser.add_argument('--volatile_memcached_server_port', default=None)
parser.add_argument('--persistent_memcached_server_hostname', default=None)
parser.add_argument('--persistent_memcached_server_port', default=None)
parser.add_argument('--bt5_path', default=None)
parser.add_argument("--xvfb_bin", default=None)
parser.add_argument("--firefox_bin", default=None)
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
revision = args.revision revision = args.revision
# XXX: think of good name as it represents al tests inside NEO test_name_list = 'SQLite', 'MySQL'
# one way is to examing all test files avaliable and register them
# but then when parsing we must report each test as a test line - i.e.
# we execute test one by one, collect output and parse and report to Nexedi ERP5.
test_name_list = ['testNEO']
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,
...@@ -109,26 +78,30 @@ def main(): ...@@ -109,26 +78,30 @@ def main():
node_title = args.test_node_title, node_title = args.test_node_title,
test_title = test_suite_title, test_title = test_suite_title,
project_title = args.project_title) project_title = args.project_title)
if test_result is not None: if test_result is None:
# clean up previous runs return
cleanup() # clean up previous runs
for x in os.listdir(TEMP_DIRECTORY):
# run NEO tests shutil.rmtree(os.path.join(TEMP_DIRECTORY, x))
# run NEO tests
while 1:
test_result_line = test_result.start() test_result_line = test_result.start()
if not test_result_line:
break
# XXX: add '-z' - i.e. ZODB tests when find out why it stalled execution. # XXX: add '-z' - i.e. ZODB tests when find out why it stalled execution.
args = [RUN_NEO_TESTS_COMMAND, '-ufv'] args = [RUN_NEO_TESTS_COMMAND, '-uf']
command = ' '.join(args) command = ' '.join(args)
stdin = file(os.devnull) env = {'TEMP': TEMP_DIRECTORY,
env = {'TEMP': TEMP_DIRECTORY, 'NEO_TESTS_ADAPTER': test_result_line.name,
'NEO_TESTS_ADAPTER': NEO_TESTS_ADAPTER} 'NEO_TEST_ZODB_FUNCTIONAL': '1',
if NEO_TESTS_ADAPTER == 'MySQL': 'NEO_DB_SOCKET': NEO_DB_SOCKET}
env['MYSQL_UNIX_PORT'] = MYSQL_UNIX_PORT
try: try:
p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, with open(os.devnull) as stdin:
stderr=subprocess.PIPE, env=env) p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env)
except Exception: except Exception:
# Catch any exception here, to warn user instead of beeing silent, # Catch any exception here, to warn user instead of being silent,
# by generating fake error result # by generating fake error result
result = dict(status_code=-1, result = dict(status_code=-1,
command=command, command=command,
...@@ -138,25 +111,26 @@ def main(): ...@@ -138,25 +111,26 @@ def main():
raise EnvironmentError(result) raise EnvironmentError(result)
# parse test stdout / stderr, hint to speed up use files first! # parse test stdout / stderr, hint to speed up use files first!
stdout = p.stdout.read() stdout, stderr = p.communicate()
date = strftime("%Y/%m/%d %H:%M:%S", gmtime()) date = strftime("%Y/%m/%d %H:%M:%S", gmtime())
test_count, error_count, expected_count, skip_count, duration = parseTestStdOut(stdout) test_count, error_count, expected_count, skip_count, duration = \
parseTestStdOut(stdout)
# print to stdout so we can see in testnode logs # print to stdout so we can see in testnode logs
print test_result_line sys.stdout.write(stdout)
print stdout sys.stderr.write(stderr)
# report status back to Nexedi ERP5 # report status back to Nexedi ERP5
test_result_line.stop( test_result_line.stop(
test_count = test_count, test_count = test_count,
error_count = error_count, error_count = error_count,
failure_count = expected_count, failure_count = expected_count,
skip_count = skip_count, skip_count = skip_count,
duration = duration, duration = duration,
date = date, date = date,
command = command, command = command,
stdout= stdout, stdout= stdout,
stderr= None, stderr= stderr,
html_test_result='') html_test_result='')
if __name__ == "__main__": if __name__ == "__main__":
......
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