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
Guillaume Hervier
slapos
Commits
64d452d2
Commit
64d452d2
authored
Oct 18, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work in progress : seleniumrunner
parent
57432a28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
99 additions
and
112 deletions
+99
-112
slapos/recipe/selenium/__init__.py
slapos/recipe/selenium/__init__.py
+72
-89
slapos/recipe/selenium/testrunner.py
slapos/recipe/selenium/testrunner.py
+27
-23
No files found.
slapos/recipe/selenium/__init__.py
View file @
64d452d2
...
@@ -29,94 +29,77 @@ import os
...
@@ -29,94 +29,77 @@ import os
import
sys
import
sys
import
zc.buildout
import
zc.buildout
from
slapos.recipe.librecipe
import
BaseSlapRecipe
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
pkg_resources
class
Recipe
(
BaseSlapRecipe
):
class
Recipe
(
BaseSlapRecipe
):
def
_install
(
self
):
def
_install
(
self
):
"""Set the connection dictionnary for the computer partition and create a list
"""
of paths to the different wrappers."""
Set the connection dictionnary for the computer partition and create a list
self
.
path_list
=
[]
of paths to the different wrappers
self
.
requirements
,
self
.
ws
=
self
.
egg
.
working_set
()
Parameters : none
self
.
installtestrunner
(
self
.
getDisplay
())
self
.
linkBinary
()
Returns : List path_list
"""
return
self
.
path_list
self
.
path_list
=
[]
def
getDisplay
(
self
):
"""Generate display id for the instance."""
self
.
requirements
,
self
.
ws
=
self
.
egg
.
working_set
()
display_list
=
[
":%s"
%
i
for
i
in
range
(
123
,
144
)]
for
display_try
in
display_list
:
self
.
instanciateTestRunner
(
self
.
getDisplay
())
lock_filepath
=
'/tmp/.X%s-lock'
%
display_try
.
replace
(
":"
,
""
)
if
not
os
.
path
.
exists
(
lock_filepath
):
self
.
linkBinary
()
display
=
display_try
break
return
display
return
self
.
path_list
def
installTestrunner
(
self
,
display
):
def
getDisplay
(
self
):
"""Instanciate a wrapper for the browser and the test reports."""
"""
arguments
=
dict
(
Choose a display for the instance
xvfb_binary
=
self
.
options
[
'xvfb_binary'
],
display
=
display
,
Parameters : None
suite_name
=
self
.
parameter_dict
[
'suite_name'
],
base_url
=
self
.
parameter_dict
[
'url'
],
Returns : display
browser_argument_list
=
[],
"""
# XXX-Cedric : No need for user/pass
display_list
=
[
":%s"
%
i
for
i
in
range
(
123
,
144
)]
user
=
self
.
parameter_dict
[
'user'
],
password
=
self
.
parameter_dict
[
'password'
])
for
display_try
in
display_list
:
lock_filepath
=
'/tmp/.X%s-lock'
%
display_try
.
replace
(
":"
,
""
)
# Check wanted browser XXX-Cedric not yet used but can be useful
if
not
os
.
path
.
exists
(
lock_filepath
):
#if self.parameter_dict.get('browser', None) is None:
display
=
display_try
arguments
[
'browser_binary'
]
=
self
.
options
[
'firefox_binary'
]
break
#elif self.parameter_dict['browser'].strip().lowercase() == 'chrome' or
# self.parameter_dict['browser'].strip().lowercase() == 'chromium':
return
display
# arguments['browser_binary'] = self.options['chromium_binary']
# arguments['browser_argument_list'].extend['--ignore-certificate-errors',
def
instanciateTestRunner
(
self
,
display
):
# option_translate = '--disable-translate',
"""
# option_security = '--disable-web-security']
Instanciate a wrapper for the browser and the test report's
#elif self.parameter_dict['browser'].strip().lowercase() == 'firefox':
# arguments['browser_binary'] = self.options['firefox_binary']
Parameters : display on which the browser will run
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([(
Returns : None
'testrunner'
,
__name__
+
'.testrunner'
,
'run'
)],
self
.
ws
,
"""
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
arguments
]))
if
self
.
parameter_dict
[
'browser'
]
==
'chrome'
or
self
.
parameter_dict
[
'browser'
]
==
'chromium'
:
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([(
def
linkBinary
(
self
):
'testrunner'
,
__name__
+
'.testrunner'
,
'run'
)],
self
.
ws
,
"""Links binaries to instance's bin directory for easier exposal"""
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
for
linkline
in
self
.
options
.
get
(
'link_binary_list'
,
''
).
splitlines
():
dict
(
if
not
linkline
:
browser_binary
=
self
.
options
[
'chromium_binary'
],
continue
xvfb_binary
=
self
.
options
[
'xvfb_binary'
],
target
=
linkline
.
split
()
display
=
display
,
if
len
(
target
)
==
1
:
option_ssl
=
'--ignore-certificate-errors'
,
target
=
target
[
0
]
option_translate
=
'--disable-translate'
,
path
,
linkname
=
os
.
path
.
split
(
target
)
option_security
=
'--disable-web-security'
,
else
:
suite_name
=
self
.
parameter_dict
[
'suite_name'
],
linkname
=
target
[
1
]
base_url
=
self
.
parameter_dict
[
'url'
],
target
=
target
[
0
]
user
=
self
.
parameter_dict
[
'user'
],
link
=
os
.
path
.
join
(
self
.
bin_directory
,
linkname
)
password
=
self
.
parameter_dict
[
'password'
]
if
os
.
path
.
lexists
(
link
):
)]))
if
not
os
.
path
.
islink
(
link
):
raise
zc
.
buildout
.
UserError
(
def
linkBinary
(
self
):
'Target link already %r exists but it is not link'
%
link
)
"""Links binaries to instance's bin directory for easier exposal"""
os
.
unlink
(
link
)
for
linkline
in
self
.
options
.
get
(
'link_binary_list'
,
''
).
splitlines
():
os
.
symlink
(
target
,
link
)
if
not
linkline
:
self
.
logger
.
debug
(
'Created link %r -> %r'
%
(
link
,
target
))
continue
self
.
path_list
.
append
(
link
)
target
=
linkline
.
split
()
if
len
(
target
)
==
1
:
target
=
target
[
0
]
path
,
linkname
=
os
.
path
.
split
(
target
)
else
:
linkname
=
target
[
1
]
target
=
target
[
0
]
link
=
os
.
path
.
join
(
self
.
bin_directory
,
linkname
)
if
os
.
path
.
lexists
(
link
):
if
not
os
.
path
.
islink
(
link
):
raise
zc
.
buildout
.
UserError
(
'Target link already %r exists but it is not link'
%
link
)
os
.
unlink
(
link
)
os
.
symlink
(
target
,
link
)
self
.
logger
.
debug
(
'Created link %r -> %r'
%
(
link
,
target
))
self
.
path_list
.
append
(
link
)
slapos/recipe/selenium/testrunner.py
View file @
64d452d2
...
@@ -29,16 +29,23 @@ from erp5functionaltestreporthandler import ERP5TestReportHandler
...
@@ -29,16 +29,23 @@ from erp5functionaltestreporthandler import ERP5TestReportHandler
from
time
import
sleep
from
time
import
sleep
import
os
import
os
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
from
re
import
search
import
urllib2
import
urllib2
def
run
(
args
):
def
run
(
args
):
config
=
args
[
0
]
config
=
args
[
0
]
test_url
=
assembleTestUrl
(
config
[
'base_url'
],
config
[
'user'
],
config
[
'password'
])
test_url
=
assembleTestUrl
(
config
[
'base_url'
],
config
[
'suite_name'
],
config
[
'user'
],
config
[
'password'
])
while
True
:
while
True
:
erp5_report
=
ERP5TestReportHandler
(
test_url
,
config
[
'suite_name'
])
erp5_report
=
ERP5TestReportHandler
(
test_url
,
config
[
'suite_name'
])
import
pdb
;
pdb
.
set_trace
()
# Clean old test results
#TODO how to clean results / post results without password?
openUrl
(
'%s/TestTool_cleanUpTestResults'
%
(
config
[
'base_url'
]))
# 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
)
xvfb
=
Popen
([
config
[
'xvfb_binary'
],
config
[
'display'
]],
stdout
=
PIPE
)
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
...
@@ -46,23 +53,21 @@ def run(args):
...
@@ -46,23 +53,21 @@ def run(args):
command
=
[]
command
=
[]
command
.
append
(
config
[
'browser_binary'
])
command
.
append
(
config
[
'browser_binary'
])
command
.
append
(
config
[
'option_ssl'
])
for
browser_argument
in
config
[
'browser_argument_list'
]:
command
.
append
(
config
[
'option_translate'
])
command
.
append
(
browser_argument
)
command
.
append
(
config
[
'option_security'
])
command
.
append
(
test_url
)
command
.
append
(
test_url
)
browser
=
Popen
(
command
,
stdout
=
PIPE
)
chromium
=
Popen
(
command
,
stdout
=
PIPE
)
erp5_report
.
reportStart
()
erp5_report
.
reportStart
()
sleep
(
10
)
# Wait for test to be finished
#while getStatus(config['base_url']) is None:
while
getStatus
(
config
[
'base_url'
])
is
''
:
# sleep(10)
sleep
(
10
)
erp5_report
.
reportFinished
(
getStatus
(
config
[
'base_url'
]).
encode
(
"utf-8"
,
#erp5_report.reportFinished(getStatus(config['base_url']).encode("utf-8", "replace"))
"replace"
))
browser
.
kill
()
chromium
.
kill
()
terminateXvfb
(
xvfb
,
config
[
'display'
])
terminateXvfb
(
xvfb
,
config
[
'display'
])
sleep
(
1
0
)
sleep
(
360
0
)
def
openUrl
(
url
):
def
openUrl
(
url
):
# Send Accept-Charset headers to activate the UnicodeConflictResolver
# Send Accept-Charset headers to activate the UnicodeConflictResolver
...
@@ -83,24 +88,23 @@ def getStatus(url):
...
@@ -83,24 +88,23 @@ def getStatus(url):
try
:
try
:
status
=
openUrl
(
'%s/portal_tests/TestTool_getResults'
%
(
url
))
status
=
openUrl
(
'%s/portal_tests/TestTool_getResults'
%
(
url
))
except
urllib2
.
HTTPError
,
e
:
except
urllib2
.
HTTPError
,
e
:
if
e
.
msg
==
"No Content"
:
if
e
.
msg
==
"No Content"
:
status
=
""
status
=
""
else
:
else
:
raise
raise
return
status
return
status
def
assembleTestUrl
(
base_url
,
user
,
password
):
def
assembleTestUrl
(
base_url
,
suite_name
,
user
,
password
):
"""
"""
Create the full url to the testrunner
Create the full url to the testrunner
"""
"""
test_url
=
"%s/%s/core/TestRunner.html?test=../test_suite_html&"
\
test_url
=
"%s/core/TestRunner.html?test=../test_suite_html&resultsUrl=%s/postResults&auto=on&__ac_name=%s&__ac_password=%s"
%
(
base_url
,
base_url
,
user
,
password
)
"resultsUrl=%s/postResults&auto=on&__ac_name=%s&__ac_password=%s"
%
(
base_url
,
suite_name
,
base_url
,
user
,
password
)
return
test_url
return
test_url
def
terminateXvfb
(
process
,
display
):
def
terminateXvfb
(
process
,
display
):
process
.
kill
()
process
.
kill
()
lock_filepath
=
'/tmp/.X%s-lock'
%
display
.
replace
(
":"
,
""
)
lock_filepath
=
'/tmp/.X%s-lock'
%
display
.
replace
(
":"
,
""
)
if
os
.
path
.
exists
(
lock_filepath
):
if
os
.
path
.
exists
(
lock_filepath
):
os
.
system
(
'rm %s'
%
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