Commit 0f553840 authored by Ivan Tyagov's avatar Ivan Tyagov Committed by Julien Muchembled

wip

parent 19f5940f
...@@ -125,6 +125,7 @@ etc_run = ${:etc}/run ...@@ -125,6 +125,7 @@ etc_run = ${:etc}/run
var_run = ${:var}/run var_run = ${:var}/run
srv_mariadb = ${buildout:directory}/srv/mariadb srv_mariadb = ${buildout:directory}/srv/mariadb
log = ${buildout:directory}/var/log log = ${buildout:directory}/var/log
tmp = ${buildout:directory}/tmp
[logrotate-mysql] [logrotate-mysql]
recipe = slapos.cookbook:logrotate.d recipe = slapos.cookbook:logrotate.d
...@@ -134,6 +135,20 @@ name = mariadb ...@@ -134,6 +135,20 @@ name = mariadb
log = ${my-cnf-parameters:error-log} ${my-cnf-parameters:slow-query-log} log = ${my-cnf-parameters:error-log} ${my-cnf-parameters:slow-query-log}
post = ${mysqld:mysql-base-directory}/bin/mysql --defaults-file="${my-cnf:rendered}" -e "FLUSH LOGS" post = ${mysqld:mysql-base-directory}/bin/mysql --defaults-file="${my-cnf:rendered}" -e "FLUSH LOGS"
{% if runTestSuite_in is defined -%}
# bin/runTestSuite to run NEO tests
[{{ section('runTestSuite') }}]
recipe = slapos.recipe.template:jinja2
rendered = ${directory:bin}/${:_buildout_section_name_}
template = {{ runTestSuite_in }}
mode = 0755
context =
section directory directory
section my_cnf_parameters my-cnf-parameters
raw python_executable {{ runTestSuite_py }}
raw neotestrunner {{ bin_directory }}/neotestrunner
{% endif -%}
[buildout] [buildout]
extends = extends =
{{ logrotate_cfg }} {{ logrotate_cfg }}
......
...@@ -12,6 +12,11 @@ extra-context = ...@@ -12,6 +12,11 @@ extra-context =
import-list = import-list =
rawfile root_common {{ root_common }} rawfile root_common {{ root_common }}
[neo-storage-mysql]
extra-context +=
raw runTestSuite_in {{ runTestSuite_in }}
raw runTestSuite_py {{ runTestSuite_py }}
[switch-softwaretype] [switch-softwaretype]
recipe = slapos.cookbook:switch-softwaretype recipe = slapos.cookbook:switch-softwaretype
override = {{ dumps(override_switch_softwaretype |default) }} override = {{ dumps(override_switch_softwaretype |default) }}
......
#!{{ python_executable }}
"""
Script to run NEO test suite using Nexedi's test node framework.
"""
import argparse, os, re, shutil, subprocess, sys, traceback
from erp5.util import taskdistribution
from time import gmtime, strftime
# pattern to get test counts from stdout
SUMMARY_RE = re.compile(
r'^(.*)Summary (.*) (?P<test_count>\d+) (.*) (?P<unexpected_count>\d+|\.)'
r' (.*) (?P<expected_count>\d+|\.) (.*) (?P<skip_count>\d+|\.)'
r' (.*) (?P<duration>\d+(\.\d*)?|\.\d+)s', re.MULTILINE)
# NEO specific environment
TEMP_DIRECTORY = '{{directory.tmp}}/neo_tests'
NEO_DB_SOCKET = '{{my_cnf_parameters.socket}}'
RUN_NEO_TESTS_COMMAND = '{{ neotestrunner }}'
def parseTestStdOut(data):
"""
Parse output of NEO testrunner script.
"""
test_count = 0
unexpected_count = 0
expected_count = 0
skip_count = 0
duration = 0
search = SUMMARY_RE.search(data)
if search:
groupdict = search.groupdict()
test_count = int(groupdict['test_count'])
duration = float(groupdict['duration'])
try:
# it can match '.'!
skip_count = int(groupdict['skip_count'])
except ValueError:
pass
try:
# it can match '.'!
unexpected_count = int(groupdict['unexpected_count'])
except ValueError:
pass
try:
# it can match '.'!
expected_count = int(groupdict['expected_count'])
except ValueError:
pass
return test_count, unexpected_count, expected_count, skip_count, duration
def main():
parser = argparse.ArgumentParser(description='Run a test suite.')
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_node_title', help='The test node title')
parser.add_argument('--project_title', help='The project title')
parser.add_argument('--revision', help='The revision to test',
default='dummy_revision')
parser.add_argument('--master_url',
help='The Url of Master controling many suites')
args = parser.parse_args()
test_suite_title = args.test_suite_title or args.test_suite
revision = args.revision
test_name_list = 'SQLite', 'MySQL'
tool = taskdistribution.TaskDistributionTool(portal_url = args.master_url)
test_result = tool.createTestResult(revision = revision,
test_name_list = test_name_list,
node_title = args.test_node_title,
test_title = test_suite_title,
project_title = args.project_title)
if test_result is None:
return
# run NEO tests
while 1:
test_result_line = test_result.start()
if not test_result_line:
break
if os.path.exists(TEMP_DIRECTORY):
shutil.rmtree(TEMP_DIRECTORY)
os.mkdir(TEMP_DIRECTORY)
args = [RUN_NEO_TESTS_COMMAND, '-ufz']
command = ' '.join(args)
env = {'TEMP': TEMP_DIRECTORY,
'NEO_TESTS_ADAPTER': test_result_line.name,
'NEO_TEST_ZODB_FUNCTIONAL': '1',
'NEO_DB_USER': 'root',
'NEO_DB_SOCKET': NEO_DB_SOCKET}
try:
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 being silent,
# by generating fake error result
result = dict(status_code=-1,
command=command,
stderr=traceback.format_exc(),
stdout='')
# XXX: inform test node master of error
raise EnvironmentError(result)
# parse test stdout / stderr, hint to speed up use files first!
stdout, stderr = p.communicate()
date = strftime("%Y/%m/%d %H:%M:%S", gmtime())
test_count, unexpected_count, expected_count, skip_count, duration = \
parseTestStdOut(stdout)
# print to stdout so we can see in testnode logs
sys.stdout.write(stdout)
sys.stderr.write(stderr)
# report status back to Nexedi ERP5
test_result_line.stop(
test_count = test_count,
error_count = unexpected_count, # XXX
failure_count = expected_count, # XXX
skip_count = skip_count,
duration = duration,
date = date,
command = command,
stdout= stdout,
stderr= stderr,
html_test_result='')
if __name__ == "__main__":
main()
...@@ -36,7 +36,7 @@ setup = ${neoppod-repository:location} ...@@ -36,7 +36,7 @@ setup = ${neoppod-repository:location}
[neoppod] [neoppod]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = neoppod[admin, ctl, master, storage-importer, storage-mysqldb] eggs = neoppod[admin, ctl, master, storage-importer, storage-mysqldb, tests]
${python-mysqlclient:egg} ${python-mysqlclient:egg}
ZODB3 ZODB3
ZODB3-patches = ZODB3-patches =
...@@ -102,7 +102,7 @@ md5sum = 82f3f76f54ee9db355966a7ada61f56e ...@@ -102,7 +102,7 @@ md5sum = 82f3f76f54ee9db355966a7ada61f56e
[instance-neo-storage-mysql] [instance-neo-storage-mysql]
<= download-base-neo <= download-base-neo
md5sum = 84b1150ce30ec827485f9c17debd6b44 md5sum = 19b4f713350aa92c9861bd2c3699d62f
[template-neo-my-cnf] [template-neo-my-cnf]
<= download-base-neo <= download-base-neo
......
...@@ -9,19 +9,32 @@ parts += ...@@ -9,19 +9,32 @@ parts +=
[template] [template]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg.in template = ${:_profile_base_location_}/instance.cfg.in
md5sum = 777c00a7dbcb145a75f980421a9b20b5 md5sum = 28e105e57af59ce23a1e90ae8ba04e59
# XXX: "template.cfg" is hardcoded in instanciation recipe # XXX: "template.cfg" is hardcoded in instanciation recipe
rendered = ${buildout:directory}/template.cfg rendered = ${buildout:directory}/template.cfg
context = context =
key cluster cluster:target key cluster cluster:target
key instance_common_cfg instance-common:rendered key instance_common_cfg instance-common:rendered
key root_common root-common:target key root_common root-common:target
key runTestSuite_in runTestSuite.in:target
key runTestSuite_py runTestSuite_py:target
[cluster] [cluster]
<= download-base-neo <= download-base-neo
md5sum = ee8401a4e7d82bf488a57e3399f9ce48 md5sum = ee8401a4e7d82bf488a57e3399f9ce48
[runTestSuite.in]
recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_buildout_section_name_}
md5sum = 3a184c04c197fa322d9b34131e3815e7
[runTestSuite_py]
recipe = zc.recipe.egg
eggs = erp5.util
interpreter = ${:_buildout_section_name_}
[versions] [versions]
erp5.util = 0.4.44
# To match ERP5 # To match ERP5
transaction = 1.1.1 transaction = 1.1.1
ZConfig = 2.9.1 ZConfig = 2.9.1
......
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