Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos
Commits
98008e8d
Commit
98008e8d
authored
Oct 28, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish seleniumrunner, use work from ERP5
parent
9603db97
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
432 additions
and
83 deletions
+432
-83
slapos/recipe/seleniumrunner/ERP5TypeFunctionalTestCase.py
slapos/recipe/seleniumrunner/ERP5TypeFunctionalTestCase.py
+354
-0
slapos/recipe/seleniumrunner/__init__.py
slapos/recipe/seleniumrunner/__init__.py
+2
-1
slapos/recipe/seleniumrunner/erp5functionaltestreporthandler.py
.../recipe/seleniumrunner/erp5functionaltestreporthandler.py
+33
-57
slapos/recipe/seleniumrunner/testrunner.py
slapos/recipe/seleniumrunner/testrunner.py
+43
-25
No files found.
slapos/recipe/seleniumrunner/ERP5TypeFunctionalTestCase.py
0 → 100644
View file @
98008e8d
This diff is collapsed.
Click to expand it.
slapos/recipe/seleniumrunner/__init__.py
View file @
98008e8d
...
...
@@ -61,7 +61,8 @@ class Recipe(BaseSlapRecipe):
base_url
=
self
.
parameter_dict
[
'url'
],
browser_argument_list
=
[],
user
=
self
.
parameter_dict
[
'user'
],
password
=
self
.
parameter_dict
[
'password'
])
password
=
self
.
parameter_dict
[
'password'
],
etc_directory
=
self
.
etc_directory
)
# Check wanted browser XXX-Cedric not yet used but can be useful
#if self.parameter_dict.get('browser', None) is None:
...
...
slapos/recipe/seleniumrunner/erp5functionaltestreporthandler.py
View file @
98008e8d
...
...
@@ -48,6 +48,7 @@ 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)
...
...
@@ -113,7 +114,7 @@ class ERP5TestReportHandler:
)
self.connection_helper = ConnectionHelper(url)
self.suite_name = suite_name
self.test_id = "2011102
6-18C84076DE29E8
"
self.test_id = "2011102
5-1F0BF8263511D4
"
def reportStart(self):
# report that test is running
...
...
@@ -125,62 +126,41 @@ class ERP5TestReportHandler:
def reportFinished(self, out_file):
# make file parsable by erp5_test_results
out_file, success, failure, duration, error_title_list = self.processResult(
out_file)
#tempout = tempfile.mkstemp()[1]
#templog = tempfile.mkstemp()[1]
#log_lines = open(out_file, 'r').readlines()
#tl = open(templog, '
w
')
#tl.write(TB_SEP + '
\
n
')
#for log_line in log_lines:
# starts = log_line.startswith
# if starts('
Ran
') or starts('
FAILED
') or starts('
OK
') or starts(TB_SEP):
# continue
# if starts('
ERROR
:
') or starts('
FAIL
:
'):
# tl.write('
internal
-
test
:
' + log_line)
# continue
# tl.write(log_line)
#
#tl.write("----------------------------------------------------------------------
\
n
")
#tl.write('
Ran
%
s
test
in
%
.
2
fs
\
n
' % (test_count, duration))
#if success:
# tl.write('
OK
\
n
')
#else:
# tl.write('
FAILED
(
failures
=%
s
)
\
n
' % failure)
#tl.write(TB_SEP + '
\
n
')
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]
zip = zipfile.ZipFile(tempzip, '
w
')
# temperr is dummy
temperr = tempfile.mkstemp()[1]
open(temperr, '
w
')
i = 1
test_case_list = [dict(name="first", log="OK
\
n
"), dict(name="second", log="FAILED (failures=1)
\
n
")]
for test_case in test_case_list:
tempcmd = tempfile.mkstemp()[1]
tempout = tempfile.mkstemp()[1]
open(tempcmd, '
w
').write(test_case['
name
'])
open(tempout, '
w
').write(test_case['
log
'])
#XXX-Cedric : support cases for more than 9 test cases
zip.write(tempcmd, '
%
s
/
00
%
s
/
cmdline
' % (self.suite_name, i))
zip.write(tempout, '
%
s
/
00
%
s
/
stderr
' % (self.suite_name, i))
zip.write(temperr, '
%
s
/
00
%
s
/
stdout
' % (self.suite_name, i))
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)
i = i + 1
zip.close()
os.unlink(temperr)
os.unlink(tempcmd2)
# post it to ERP5
self.connection_helper.POST('
TestResultModule_reportCompleted
', dict(
test_report_id=self.test_id),
file_list=[('
filepath
', tempzip)]
)
import pdb; pdb.set_trace()
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):
...
...
@@ -189,9 +169,7 @@ class ERP5TestReportHandler:
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)]
# XXX-Cedric : duration
duration = 0
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):
...
...
@@ -206,6 +184,4 @@ class ERP5TestReportHandler:
</head>
<body>%s</body>
</html>''' % detail
return detail, int(sucess_amount), int(failure_amount), duration,
\
error_title_list
return detail, int(sucess_amount), int(failure_amount), float(duration)
slapos/recipe/seleniumrunner/testrunner.py
View file @
98008e8d
...
...
@@ -26,9 +26,10 @@
#############################################################################
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
ERP5TypeFunctionalTestCase
import
Xvfb
,
Firefox
,
TimeoutError
from
time
import
sleep
import
time
import
os
from
subprocess
import
Popen
,
PIPE
import
urllib2
def
run
(
args
):
...
...
@@ -37,6 +38,9 @@ def run(args):
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
(
config
[
'test_suite_master_url'
],
config
[
'project'
]
+
'@'
+
config
[
'suite_name'
])
...
...
@@ -45,32 +49,46 @@ def run(args):
config
[
'base_url'
],
config
[
'user'
],
config
[
'password'
]))
# TODO assert getresult is None
#XXX-Cedric : clean firefox data (so that it does not load previous session)
#xvfb = Popen([config['xvfb_binary'], config['display']], stdout=PIPE)
#os.environ['DISPLAY'] = config['display']
#sleep(10)
command
=
[]
command
.
append
(
config
[
'browser_binary'
])
for
browser_argument
in
config
[
'browser_argument_list'
]:
command
.
append
(
browser_argument
)
command
.
append
(
test_url
)
browser
=
Popen
(
command
,
stdout
=
PIPE
)
#
#command = []
#command.append(config['browser_binary'])
#for browser_argument in config['browser_argument_list']:
# command.append(browser_argument)
#command.append(test_url)
#browser = Popen(command, stdout=PIPE)
#
#erp5_report.reportStart()
#
## Wait for test to be finished
#while getStatus(config['base_url']) is '':
# sleep(10)
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
xvfb
=
Xvfb
(
config
[
'xvfb_binary'
],
config
[
'etc_directory'
])
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
browser
=
Firefox
(
config
[
'browser_binary'
],
profile_dir
,
config
[
'base_url'
])
try
:
start
=
time
.
time
()
xvfb
.
run
()
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
browser
.
run
(
test_url
,
xvfb
.
display
)
erp5_report
.
reportStart
()
# Wait for test to be finished
while
getStatus
(
config
[
'base_url'
])
is
''
:
sleep
(
1
)
#10
import
pdb
;
pdb
.
set_trace
()
time
.
sleep
(
10
)
if
(
time
.
time
()
-
start
)
>
float
(
timeout
):
raise
TimeoutError
(
"Test took more them %s seconds"
%
timeout
)
except
TimeoutError
:
continue
finally
:
browser
.
quit
()
xvfb
.
quit
()
erp5_report
.
reportFinished
(
getStatus
(
config
[
'base_url'
]).
encode
(
"utf-8"
,
"replace"
))
browser
.
kill
()
#terminateXvfb(xvfb, config['display'])
print
(
"Test finished and report sent, sleeping."
)
sleep
(
3600
)
...
...
@@ -108,8 +126,8 @@ def assembleTestUrl(base_url, suite_name, user, password):
base_url
,
suite_name
,
base_url
,
user
,
password
)
return
test_url
def
terminateXvfb
(
process
,
display
):
process
.
kill
()
lock_filepath
=
'/tmp/.X%s-lock'
%
display
.
replace
(
":"
,
""
)
if
os
.
path
.
exists
(
lock_filepath
):
os
.
system
(
'rm %s'
%
lock_filepath
)
#
def terminateXvfb(process, display):
#
process.kill()
#
lock_filepath = '/tmp/.X%s-lock' % display.replace(":", "")
#
if os.path.exists(lock_filepath):
#
os.system('rm %s' % lock_filepath)
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