Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos
Commits
4eebbcc2
Commit
4eebbcc2
authored
Feb 08, 2016
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add first implementation of a real script that can run NEO tests.
parent
df7ba1b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
16 deletions
+119
-16
software/neoppod/runTestSuite.in
software/neoppod/runTestSuite.in
+118
-15
software/neoppod/software-neoppod-testnode.cfg
software/neoppod/software-neoppod-testnode.cfg
+1
-1
No files found.
software/neoppod/runTestSuite.in
View file @
4eebbcc2
#!/bin/bash
#!/usr/bin/python
# XXX ^^^ bash better also be generated, but is draftly ok as it is now
"""
Script to run NEO test suite using Nexedi's test node framework.
"""
import
argparse
,
sys
,
subprocess
,
os
import
traceback
import
taskdistribution
import
re
neotestrunner
={{
neotestrunner
}}
# pattern to get test counts from stdout
tmp_directory
={{
neo_temp_directory
}}
/neotest_tmp
SUMMARY_RE
=
re
.
compile
(
\
r'^(.*)Summary (.*) (?P<test_count>\
d+) (.*) (?P<e
rror_count>\
d+) (.*) (?P<expec
ted_count>\
d+) (.*) (?P<skip_cou
nt>\
d+|
\.) (.*) (?P<duration>\
d+(
\.\
d*)?|
\.\
d+)s
', \
re.MULTILINE)
export
TEMP
=
$tmp_directory
# NEO specific environment
TEMP_DIRECTORY = '
{{
neo_temp_directory
}}
/
neotest_tmp
'
MYSQL_UNIX_PORT = '
{{
my_cnf_parameters
.
socket
}}
'
NEO_TESTS_ADAPTER = '
MySQL
'
RUN_NEO_TESTS_COMMAND = '
{{
neotestrunner
}}
'
# clean up
def parseTestStdOut(data):
rm
-rf
$tmp_directory
/
*
"""
Parse output of NEO testrunner script.
"""
search = SUMMARY_RE.search(data)
if search:
groupdict = search.groupdict()
test_count = int(groupdict['
test_count
'])
duration = float(groupdict['
duration
'])
error_count = int(groupdict['
error_count
'])
expected_count = int(groupdict['
expected_count
'])
try:
# it can match '
.
'!
skip_count = int(groupdict['
skip_count
'])
except ValueError:
skip_count = 0
return test_count, error_count, expected_count, skip_count, duration
# SQLite backend
def main():
export
NEO_TESTS_ADAPTER
=
SQLite
parser = argparse.ArgumentParser(description='
Run
a
test
suite
.
')
exec
$neotestrunner
-ufz
parser.add_argument('
--
test_suite
', help='
The
test
suite
name
')
parser.add_argument('
--
test_suite_title
', help='
The
test
suite
title
',
default=None)
parser.add_argument('
--
test_node_title
', help='
The
test
node
title
',
default=None)
parser.add_argument('
--
project_title
', help='
The
project
title
',
default=None)
parser.add_argument('
--
revision
', help='
The
revision
to
test
',
default='
dummy_revision
')
parser.add_argument('
--
node_quantity
', help='
Number
of
parallel
tests
to
run
',
default=1, type=int)
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)
# MySQL as backend
args = parser.parse_args()
export
MYSQL_UNIX_PORT
={{
my_cnf_parameters.socket
}}
export
NEO_TESTS_ADAPTER
=
MySQL
exec
$neotestrunner
-ufz
# XXX: parse results and send to Nexedi ERP5
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
']
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 not None:
# run NEO tests
test_result_line = test_result.start()
command = "%s -ufz" %RUN_NEO_TESTS_COMMAND
args = [RUN_NEO_TESTS_COMMAND, '
-
ufz
']
stdin = file(os.devnull)
env = {'
TEMP
': TEMP_DIRECTORY,
'
MYSQL_UNIX_PORT
': MYSQL_UNIX_PORT,
'
NEO_TESTS_ADAPTER
': NEO_TESTS_ADAPTER}
try:
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,
# by generating fake error result
result = dict(status_code=-1,
command=command,
stderr=traceback.format_exc(),
stdout='')
raise EnvironmentError(result)
# parse test stdout / stderr, hint to speed up use files first!
data = p.stdout.read()
test_count, error_count, expected_count, skip_count, duration = parseTestStdOut(data)
print test_result_line
# report status back to Nexedi ERP5
test_result_line.stop(
test_count = test_count,
error_count = error_count,
failure_count = expected_count,
skip_count = skip_count,
duration = duration,
date = None, # XXX: date when test run or when finished ?
command = command,
stdout= data,
stderr='
stderr
', # XXX:catch it
html_test_result='')
if __name__ == "__main__":
main()
software/neoppod/software-neoppod-testnode.cfg
View file @
4eebbcc2
...
@@ -13,4 +13,4 @@ destination = ${buildout:directory}/${:_buildout_section_name_}
...
@@ -13,4 +13,4 @@ destination = ${buildout:directory}/${:_buildout_section_name_}
[runTestSuite.in]
[runTestSuite.in]
<= download-file
<= download-file
md5sum = fd091d5db673e4e6470b1e25f8090415
#
md5sum = fd091d5db673e4e6470b1e25f8090415
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment