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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
slapos
Commits
4514c00d
Commit
4514c00d
authored
Sep 05, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
recipe: drop slapos.recipe:seleniumrunner
We use jstestnode
parent
26ecb4d2
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
762 deletions
+0
-762
setup.py
setup.py
+0
-1
slapos/recipe/README.seleniumrunner.rst
slapos/recipe/README.seleniumrunner.rst
+0
-27
slapos/recipe/seleniumrunner/ERP5TypeFunctionalTestCase.py
slapos/recipe/seleniumrunner/ERP5TypeFunctionalTestCase.py
+0
-356
slapos/recipe/seleniumrunner/__init__.py
slapos/recipe/seleniumrunner/__init__.py
+0
-39
slapos/recipe/seleniumrunner/erp5functionaltestreporthandler.py
.../recipe/seleniumrunner/erp5functionaltestreporthandler.py
+0
-188
slapos/recipe/seleniumrunner/template/xvfb_run.in
slapos/recipe/seleniumrunner/template/xvfb_run.in
+0
-5
slapos/recipe/seleniumrunner/testrunner.py
slapos/recipe/seleniumrunner/testrunner.py
+0
-146
No files found.
setup.py
View file @
4514c00d
...
...
@@ -166,7 +166,6 @@ setup(name=name,
'slapos.recipe.request:RequestOptionalJSONEncoded'
,
're6stnet.registry = slapos.recipe.re6stnet:Recipe'
,
'reverseproxy.nginx = slapos.recipe.reverse_proxy_nginx:Recipe'
,
'seleniumrunner = slapos.recipe.seleniumrunner:Recipe'
,
'sheepdogtestbed = slapos.recipe.sheepdogtestbed:SheepDogTestBed'
,
'shell = slapos.recipe.shell:Recipe'
,
'shellinabox = slapos.recipe.shellinabox:Recipe'
,
...
...
slapos/recipe/README.seleniumrunner.rst
deleted
100644 → 0
View file @
26ecb4d2
seleniumrunner
==============
Allows to run selenium tests through browser and xvfb. Posts the results on
Nexedi ERP5.
Parameters
==========
* project : name of the project inside of ERP5 test result instance
* user : username to use in ERP5 instance to test
* password : password to use in ERP5 instance to test
* suite_name : name of test suite to launch
* url : url to portal_test of ERP5 isntance to test
* test_report_instance_url : url of test_result_module to put results
* Example::
<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="project">Vifib</parameter>
<parameter id="user">myuser</parameter>
<parameter id="password">mypassword</parameter>
<parameter id="suite_name">my_zuite</parameter>
<parameter id="url">https://myerp5totest/erp5/portal_tests</parameter>
<parameter id="test_report_instance_url">https://user:passwordwww.myerp5withtestresults.com/test_result_module/</parameter>
</instance>
slapos/recipe/seleniumrunner/ERP5TypeFunctionalTestCase.py
deleted
100644 → 0
View file @
26ecb4d2
This diff is collapsed.
Click to expand it.
slapos/recipe/seleniumrunner/__init__.py
deleted
100644 → 0
View file @
26ecb4d2
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#############################################################################
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
def
install
(
self
):
return
self
.
createPythonScript
(
self
.
options
[
'runner-path'
],
__name__
+
'.testrunner.run'
,
(
self
.
options
[
'suite-url'
],
self
.
options
[
'report-url'
],
self
.
options
[
'report-project'
],
self
.
options
[
'browser'
]))
slapos/recipe/seleniumrunner/erp5functionaltestreporthandler.py
deleted
100644 → 0
View file @
26ecb4d2
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#############################################################################
from
__future__
import
absolute_import
import
re
import
urlparse
import
urllib
import
httplib
import
mimetools
from
random
import
randint
import
tempfile
import
os
import
stat
import
zipfile
import
mimetypes
import
datetime
TB_SEP
=
"============================================================="
\
"========="
# REGEX FOR ZELENIUM TESTS
TEST_PASS_RE
=
re
.
compile
(
'<th[^>]*>Tests passed</th>
\
n
\
s*<
t
d[^>]*>([^<]*)'
)
TEST_FAILURE_RE
=
re
.
compile
(
'<th[^>]*>Tests failed</th>
\
n
\
s*<
t
d[^>]*>([^<]*)'
)
IMAGE_RE
=
re
.
compile
(
'<img[^>]*?>'
)
TEST_ERROR_TITLE_RE
=
re
.
compile
(
'(?:error.gif.*?>|title status_failed"><td[^>]*>)([^>]*?)</td></tr>'
,
re
.
S
)
TEST_RESULT_RE
=
re
.
compile
(
'<div style="padding-top: 10px;">
\
s*<p>
\
s*'
'<img.*?</div>
\
s.*?</di
v
>
\
s*
'
, re.S)
DURATION_RE = re.compile('
<
th
[
^>
]
*>
Elapsed
time
\
(
sec
\
)
</
th
>
\
n
\
s
*<
td
[
^>
]
*>
([
^<
]
*
)
')
TEST_ERROR_RESULT_RE = re.compile('
.
*
(
?
:
error
.
gif
|
title
status_failed
).
*
', re.S)
def get_content_type(f):
return mimetypes.guess_type(f.name)[0] or '
application
/
octet
-
stream
'
class ConnectionHelper:
def __init__(self, url):
self.conn = urlparse.urlparse(url)
if self.conn.scheme == '
http
':
connection_type = httplib.HTTPConnection
if self.conn.port is None:
self.port = 80
else:
connection_type = httplib.HTTPSConnection
if self.conn.port is None:
self.port = 443
self.connection_type = connection_type
def _connect(self):
self.connection = self.connection_type(self.conn.hostname + '
:
' +
str(self.conn.port or self.port))
def POST(self, path, parameter_dict, file_list=None):
self._connect()
parameter_dict.update(__ac_name=self.conn.username,
__ac_password=self.conn.password)
header_dict = {'
Content
-
type
': "application/x-www-form-urlencoded"}
if file_list is None:
body = urllib.urlencode(parameter_dict)
else:
boundary = mimetools.choose_boundary()
header_dict['
Content
-
type
'] = '
multipart
/
form
-
data
;
boundary
=%
s
' % (
boundary,)
body = ''
for k, v in parameter_dict.iteritems():
body += '
--%
s
\
r
\
n
' % boundary
body += '
Content
-
Disposition
:
form
-
data
;
name
=
"%s"
\
r
\
n
' % k
body += '
\
r
\
n
'
body += '
%
s
\
r
\
n
' % v
for name, filename in file_list:
f = open(filename, 'r')
body += '
--%
s
\
r
\
n
' % boundary
body += '
Content
-
Disposition
:
form
-
data
;
name
=
"%s"
;
filename
=
"%s"
\
r
\
n
'
\
% (name, name)
body += '
Content
-
Type
:
%
s
\
r
\
n
' % get_content_type(f)
body += '
Content
-
Length
:
%
d
\
r
\
n
' % os.fstat(f.fileno())[stat.ST_SIZE]
body += '
\
r
\
n
'
body += f.read()
f.close()
body += '
\
r
\
n
'
self.connection.request("POST", self.conn.path + '
/
' + path,
body, header_dict)
self.response = self.connection.getresponse()
class ERP5TestReportHandler:
def __init__(self, url, suite_name):
# random test id
self.test_id = "%s-%X" % (
("%s" % datetime.date.today()).replace("-", ""),
randint(1, 10000000000000000),
)
self.connection_helper = ConnectionHelper(url)
self.suite_name = suite_name
def reportStart(self):
# report that test is running
print '
Starting
test
with
id
%
s
' % self.test_id
self.connection_helper.POST('
TestResultModule_reportRunning
', dict(
test_suite=self.suite_name,
test_report_id=self.test_id,
))
def reportFinished(self, out_file):
# make file parsable by erp5_test_results
out_file, success, failure, duration = self.processResult(out_file)
# XXX-Cedric : make correct display in test_result_module
tempcmd = tempfile.mkstemp()[1]
tempcmd2 = tempfile.mkstemp()[1]
tempout = tempfile.mkstemp()[1]
templog = tempfile.mkstemp()[1]
tl = open(templog, '
w
')
tl.write(TB_SEP + '
\
n
')
tl.write(out_file)
tl.write("----------------------------------------------------------------------
\
n
")
tl.write('
Ran
1
test
in
%
.
2
fs
\
n
' % duration)
if success:
tl.write('
OK
\
n
')
else:
tl.write('
FAILED
(
failures
=
1
)
\
n
')
tl.write(TB_SEP + '
\
n
')
tl.close()
open(tempcmd, '
w
').write(""" %s""" % self.suite_name)
# create nice zip archive
tempzip = tempfile.mkstemp()[1]
# XXX-Cedric : support multiple tests
zip = zipfile.ZipFile(tempzip, '
w
')
zip.write(tempout, '
%
s
/
001
/
stdout
' % self.suite_name)
zip.write(templog, '
%
s
/
001
/
stderr
' % self.suite_name)
zip.write(tempcmd, '
%
s
/
001
/
cmdline
' % self.suite_name)
zip.close()
os.unlink(templog)
os.unlink(tempcmd)
os.unlink(tempout)
os.unlink(tempcmd2)
# post it to ERP5
self.connection_helper.POST('
TestResultModule_reportCompleted
',
dict(test_report_id=self.test_id), file_list=[('
filepath
', tempzip)])
os.unlink(tempzip)
def processResult(self, out_file):
file_content = out_file
sucess_amount = TEST_PASS_RE.search(file_content).group(1)
failure_amount = TEST_FAILURE_RE.search(file_content).group(1)
error_title_list = [re.compile('
\
s
+
').sub('
', x).strip()
for x in TEST_ERROR_TITLE_RE.findall(file_content)]
duration = DURATION_RE.search(file_content).group(1)
detail = ''
for test_result in TEST_RESULT_RE.findall(file_content):
if TEST_ERROR_RESULT_RE.match(test_result):
detail += test_result
detail = IMAGE_RE.sub('', detail)
if detail:
detail = IMAGE_RE.sub('', detail)
detail = '''<html>
<head>
<style type="text/css">tr.status_failed { background-color:red };</style>
</head>
<body>%s</body>
</html>''' % detail
return detail, int(sucess_amount), int(failure_amount), float(duration)
slapos/recipe/seleniumrunner/template/xvfb_run.in
deleted
100644 → 0
View file @
26ecb4d2
#!/bin/sh
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
%
(
xvfb_binary
)
:%
(
display
)
-screen
%
(
display
)
1024x768x24
\ No newline at end of file
slapos/recipe/seleniumrunner/testrunner.py
deleted
100644 → 0
View file @
26ecb4d2
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#############################################################################
from
datetime
import
datetime
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
ERP5TypeFunctionalTestCase
import
TimeoutError
from
time
import
sleep
import
time
import
os
import
urllib2
import
urlparse
from
subprocess
import
Popen
,
PIPE
import
signal
def
run
(
suite_url
,
report_url
,
project
,
browser_binary
):
suite_parsed
=
urlparse
.
urlparse
(
suite_url
)
config
=
{
'suite_name'
:
suite_parsed
.
path
.
split
(
'/'
)[
-
1
],
'base_url'
:
"%s://%s%s"
%
(
suite_parsed
.
scheme
,
suite_parsed
.
hostname
,
'/'
.
join
(
suite_parsed
.
path
.
split
(
'/'
)[:
-
1
])),
'user'
:
suite_parsed
.
username
,
'password'
:
suite_parsed
.
password
,
}
test_url
=
assembleTestUrl
(
config
[
'base_url'
],
config
[
'suite_name'
],
config
[
'user'
],
config
[
'password'
])
# There is no test that can take more them 24 hours
timeout
=
2.0
*
60
*
60
while
True
:
erp5_report
=
ERP5TestReportHandler
(
report_url
,
project
+
'@'
+
config
[
'suite_name'
])
try
:
try
:
start
=
time
.
time
()
print
(
"Running test on: %s"
%
test_url
)
process
=
Popen
(
'%s "%s"'
%
(
browser_binary
,
test_url
),
stdout
=
PIPE
,
stderr
=
PIPE
,
shell
=
True
,
close_fds
=
True
)
erp5_report
.
reportStart
()
while
not
isTestFinished
(
config
[
'base_url'
]):
time
.
sleep
(
10
)
print
(
"Test not finished yet."
)
if
(
time
.
time
()
-
start
)
>
float
(
timeout
):
raise
TimeoutError
(
"Test took more than %s seconds"
%
timeout
)
except
TimeoutError
:
continue
finally
:
if
process
.
pid
:
os
.
kill
(
process
.
pid
,
signal
.
SIGTERM
)
print
(
"Test has finished and Firefox has been killed."
)
erp5_report
.
reportFinished
(
getStatus
(
config
[
'base_url'
]).
encode
(
"utf-8"
,
"replace"
))
print
(
"Test finished and report sent, sleeping."
)
except
urllib2
.
URLError
,
urlError
:
print
"Error: %s"
%
urlError
.
msg
sleep
(
3600
)
def
openUrl
(
url
):
# Send Accept-Charset headers to activate the UnicodeConflictResolver
# (imitating firefox 3.5.9 here)
headers
=
{
'Accept-Charset'
:
'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
}
request
=
urllib2
.
Request
(
url
,
headers
=
headers
)
# Try to use long timeout, this is needed when there is many
# activities runing
try
:
f
=
urllib2
.
urlopen
(
request
,
timeout
=
3600
*
4
)
except
TypeError
:
f
=
urllib2
.
urlopen
(
request
)
file_content
=
f
.
read
()
f
.
close
()
return
file_content
def
isTestFinished
(
url
):
"""Fetch latest report. If report has been created less than 60 seconds ago,
it must be the current one.
Return true if test is finished, else return false.
"""
latest_report
=
openUrl
(
'%s/portal_tests/TestTool_getLatestReportId/'
%
url
)
if
latest_report
is
''
:
return
False
latest_report_date
=
latest_report
[
7
:]
time_delta
=
datetime
.
now
()
-
\
datetime
.
strptime
(
latest_report_date
,
'%Y%m%d_%H%M%S'
)
if
time_delta
.
days
is
not
0
:
return
False
if
time_delta
.
seconds
<
120
:
return
True
return
False
def
getStatus
(
url
):
try
:
# Try 5 times.
for
i
in
range
(
5
):
try
:
status
=
openUrl
(
'%s/portal_tests/TestTool_getResults/'
%
(
url
))
break
except
urllib2
.
URLError
,
urlError
:
if
i
is
4
:
raise
print
(
"Warning : %s while getting status"
%
urlError
.
msg
)
except
urllib2
.
HTTPError
,
e
:
if
e
.
msg
==
"No Content"
:
status
=
""
else
:
raise
return
status
def
assembleTestUrl
(
base_url
,
suite_name
,
user
,
password
):
"""
Create the full url to the testrunner
"""
test_url
=
"%s/%s/core/TestRunner.html?test=../test_suite_html&"
\
"resultsUrl=%s/postResults&auto=on&__ac_name=%s&__ac_password=%s"
%
(
base_url
,
suite_name
,
base_url
,
user
,
password
)
return
test_url
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