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

wip

parent bf01075e
......@@ -2,10 +2,8 @@
"""
Script to run NEO test suite using Nexedi's test node framework.
"""
import argparse, sys, subprocess, os, glob
import traceback
import argparse, os, re, shutil, subprocess, sys, traceback
from erp5.util import taskdistribution
import re
from time import gmtime, strftime
# pattern to get test counts from stdout
......@@ -14,26 +12,12 @@ SUMMARY_RE = re.compile( \
re.MULTILINE)
# NEO specific environment
TEMP_DIRECTORY = '{{neo_temp_directory}}/neotest_tmp'
MYSQL_UNIX_PORT = '{{my_cnf_parameters.socket}}'
NEO_TESTS_ADAPTER = 'SQLite'
TEMP_DIRECTORY = '{{neo_temp_directory}}'
NEO_DB_SOCKET = '{{my_cnf_parameters.socket}}'
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):
"""
"""
Parse output of NEO testrunner script.
"""
test_count = 0
......@@ -80,28 +64,13 @@ def main():
parser.add_argument('--master_url',
help='The Url of Master controling many suites',
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()
test_suite_title = args.test_suite_title or args.test_suite
revision = args.revision
# XXX: think of good name as it represents al tests inside NEO
# 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']
test_name_list = 'SQLite', 'MySQL'
tool = taskdistribution.TaskDistributionTool(portal_url = args.master_url)
test_result = tool.createTestResult(revision = revision,
......@@ -109,26 +78,30 @@ def main():
node_title = args.test_node_title,
test_title = test_suite_title,
project_title = args.project_title)
if test_result is not None:
# clean up previous runs
cleanup()
# run NEO tests
if test_result is None:
return
# clean up previous runs
for x in os.listdir(TEMP_DIRECTORY):
shutil.rmtree(os.path.join(TEMP_DIRECTORY, x))
# run NEO tests
while 1:
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.
args = [RUN_NEO_TESTS_COMMAND, '-ufv']
args = [RUN_NEO_TESTS_COMMAND, '-uf']
command = ' '.join(args)
stdin = file(os.devnull)
env = {'TEMP': TEMP_DIRECTORY,
'NEO_TESTS_ADAPTER': NEO_TESTS_ADAPTER}
if NEO_TESTS_ADAPTER == 'MySQL':
env['MYSQL_UNIX_PORT'] = MYSQL_UNIX_PORT
env = {'TEMP': TEMP_DIRECTORY,
'NEO_TESTS_ADAPTER': test_result_line.name,
'NEO_TEST_ZODB_FUNCTIONAL': '1',
'NEO_DB_SOCKET': NEO_DB_SOCKET}
try:
p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env)
with open(os.devnull) as stdin:
p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, env=env)
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
result = dict(status_code=-1,
command=command,
......@@ -138,25 +111,26 @@ def main():
raise EnvironmentError(result)
# 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())
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 test_result_line
print stdout
sys.stdout.write(stdout)
sys.stderr.write(stderr)
# report status back to Nexedi ERP5
test_result_line.stop(
test_count = test_count,
error_count = error_count,
test_count = test_count,
error_count = error_count,
failure_count = expected_count,
skip_count = skip_count,
duration = duration,
date = date,
skip_count = skip_count,
duration = duration,
date = date,
command = command,
stdout= stdout,
stderr= None,
stdout= stdout,
stderr= stderr,
html_test_result='')
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