Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Carlos Ramos Carreño
erp5
Commits
82a85c26
Commit
82a85c26
authored
Apr 11, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an external browser.
Decouple the seleniumrunner from the browser and the xserver.
parent
5df3791a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
129 deletions
+109
-129
slapos/recipe/seleniumrunner/__init__.py
slapos/recipe/seleniumrunner/__init__.py
+12
-72
slapos/recipe/seleniumrunner/testrunner.py
slapos/recipe/seleniumrunner/testrunner.py
+29
-16
software/seleniumrunner/instance-selenium.cfg
software/seleniumrunner/instance-selenium.cfg
+47
-0
software/seleniumrunner/instance.cfg
software/seleniumrunner/instance.cfg
+13
-40
software/seleniumrunner/software.cfg
software/seleniumrunner/software.cfg
+8
-1
No files found.
slapos/recipe/seleniumrunner/__init__.py
View file @
82a85c26
...
@@ -29,79 +29,19 @@ import os
...
@@ -29,79 +29,19 @@ import os
import
sys
import
sys
import
zc.buildout
import
zc.buildout
from
slapos.recipe.librecipe
import
BaseSlapRecipe
from
slapos.recipe.librecipe
import
BaseSlapRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
BaseSlapRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
_install
(
self
):
def
install
(
self
):
"""Set the connection dictionnary for the computer partition and create a list
of paths to the different wrappers."""
self
.
path_list
=
[]
self
.
requirements
,
self
.
ws
=
self
.
egg
.
working_set
()
self
.
installTestrunner
(
self
.
getDisplay
())
runner
=
self
.
createPythonScript
(
self
.
linkBinary
()
self
.
options
[
'runner-path'
],
__name__
+
'.testrunner.run'
,
arguments
=
[
self
.
options
[
'suite-url'
],
self
.
options
[
'report-url'
],
self
.
options
[
'report-project'
],
self
.
options
[
'browser'
],
])
return
self
.
path_list
return
[
runner
]
def
getDisplay
(
self
):
"""Generate display id for the instance."""
display_list
=
[
":%s"
%
i
for
i
in
range
(
123
,
144
)]
for
display_try
in
display_list
:
lock_filepath
=
'/tmp/.X%s-lock'
%
display_try
.
replace
(
":"
,
""
)
if
not
os
.
path
.
exists
(
lock_filepath
):
display
=
display_try
break
return
display
def
installTestrunner
(
self
,
display
):
"""Instanciate a wrapper for the browser and the test reports."""
arguments
=
dict
(
xvfb_binary
=
self
.
options
[
'xvfb_binary'
],
display
=
display
,
suite_name
=
self
.
parameter_dict
[
'suite_name'
],
base_url
=
self
.
parameter_dict
[
'url'
],
browser_argument_list
=
[],
user
=
self
.
parameter_dict
[
'user'
],
password
=
self
.
parameter_dict
[
'password'
],
project
=
self
.
parameter_dict
[
'project'
],
test_report_instance_url
=
\
self
.
parameter_dict
[
'test_report_instance_url'
],
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:
arguments
[
'browser_binary'
]
=
self
.
options
[
'firefox_binary'
]
#elif self.parameter_dict['browser'].strip().lowercase() == 'chrome' or
# self.parameter_dict['browser'].strip().lowercase() == 'chromium':
# arguments['browser_binary'] = self.options['chromium_binary']
# arguments['browser_argument_list'].extend['--ignore-certificate-errors',
# option_translate = '--disable-translate',
# option_security = '--disable-web-security']
#elif self.parameter_dict['browser'].strip().lowercase() == 'firefox':
# arguments['browser_binary'] = self.options['firefox_binary']
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
([(
'testrunner'
,
__name__
+
'.testrunner'
,
'run'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
arguments
]))
def
linkBinary
(
self
):
"""Links binaries to instance's bin directory for easier exposal"""
for
linkline
in
self
.
options
.
get
(
'link_binary_list'
,
''
).
splitlines
():
if
not
linkline
:
continue
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/seleniumrunner/testrunner.py
View file @
82a85c26
...
@@ -27,14 +27,30 @@
...
@@ -27,14 +27,30 @@
from
datetime
import
datetime
from
datetime
import
datetime
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
ERP5TypeFunctionalTestCase
import
Xvfb
,
Firefox
,
TimeoutError
from
ERP5TypeFunctionalTestCase
import
TimeoutError
from
time
import
sleep
from
time
import
sleep
import
time
import
time
import
os
import
os
import
urllib2
import
urllib2
import
urlparse
from
subprocess
import
Popen
,
PIPE
import
signal
def
run
(
args
):
def
run
(
args
):
config
=
args
[
0
]
suite_url
=
args
[
0
]
report_url
=
args
[
1
]
project
=
args
[
2
]
browser_binary
=
args
[
3
]
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'
],
test_url
=
assembleTestUrl
(
config
[
'base_url'
],
config
[
'suite_name'
],
config
[
'user'
],
config
[
'password'
])
config
[
'user'
],
config
[
'password'
])
...
@@ -43,20 +59,17 @@ def run(args):
...
@@ -43,20 +59,17 @@ def run(args):
timeout
=
2.0
*
60
*
60
timeout
=
2.0
*
60
*
60
while
True
:
while
True
:
erp5_report
=
ERP5TestReportHandler
(
config
[
'test_report_instance_url'
]
,
erp5_report
=
ERP5TestReportHandler
(
report_url
,
config
[
'project'
]
+
'@'
+
config
[
'suite_name'
])
project
+
'@'
+
config
[
'suite_name'
])
try
:
try
:
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
xvfb
=
Xvfb
(
config
[
'etc_directory'
],
config
[
'xvfb_binary'
])
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
# XXX-Cedric : change Firefox prefs.js generation so that it can take a
# list of websites supposed to be reached instead of config['base_url']
browser
=
Firefox
(
profile_dir
,
config
[
'base_url'
],
config
[
'browser_binary'
])
try
:
try
:
start
=
time
.
time
()
start
=
time
.
time
()
xvfb
.
run
()
print
(
"Running test on: %s"
%
test_url
)
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
process
=
Popen
(
'%s "%s"'
%
(
browser_binary
,
test_url
),
browser
.
run
(
test_url
,
xvfb
.
display
)
stdout
=
PIPE
,
stderr
=
PIPE
,
shell
=
True
,
close_fds
=
True
)
erp5_report
.
reportStart
()
erp5_report
.
reportStart
()
while
not
isTestFinished
(
config
[
'base_url'
]):
while
not
isTestFinished
(
config
[
'base_url'
]):
time
.
sleep
(
10
)
time
.
sleep
(
10
)
...
@@ -66,8 +79,8 @@ def run(args):
...
@@ -66,8 +79,8 @@ def run(args):
except
TimeoutError
:
except
TimeoutError
:
continue
continue
finally
:
finally
:
browser
.
quit
()
if
process
.
pid
:
xvfb
.
quit
(
)
os
.
kill
(
process
.
pid
,
signal
.
SIGTERM
)
print
(
"Test has finished and Firefox has been killed."
)
print
(
"Test has finished and Firefox has been killed."
)
erp5_report
.
reportFinished
(
getStatus
(
config
[
'base_url'
]).
encode
(
"utf-8"
,
erp5_report
.
reportFinished
(
getStatus
(
config
[
'base_url'
]).
encode
(
"utf-8"
,
...
@@ -135,4 +148,4 @@ def assembleTestUrl(base_url, suite_name, user, password):
...
@@ -135,4 +148,4 @@ def assembleTestUrl(base_url, suite_name, user, password):
test_url
=
"%s/%s/core/TestRunner.html?test=../test_suite_html&"
\
test_url
=
"%s/%s/core/TestRunner.html?test=../test_suite_html&"
\
"resultsUrl=%s/postResults&auto=on&__ac_name=%s&__ac_password=%s"
%
(
"resultsUrl=%s/postResults&auto=on&__ac_name=%s&__ac_password=%s"
%
(
base_url
,
suite_name
,
base_url
,
user
,
password
)
base_url
,
suite_name
,
base_url
,
user
,
password
)
return
test_url
return
test_url
\ No newline at end of file
software/seleniumrunner/instance-selenium.cfg
0 → 100644
View file @
82a85c26
[buildout]
parts =
selenium-instance
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[selenium-instance]
recipe = slapos.cookbook:seleniumrunner
runner-path = $${basedirectory:services}/selenium-runner
browser = $${firefox-instance:runner-path}
suite-url = $${slap-parameter:suite-url}
report-url = $${slap-parameter:report-url}
report-project = $${slap-parameter:report-project}
[firefox-instance]
recipe = slapos.cookbook:firefox
runner-path = $${rootdirectory:bin}/firefox-sandboxed
firefox-path = ${firefox:location}/firefox-slapos
prefsjs-path = $${rootdirectory:etc}/prefs.js
shell-path = ${dash:location}/bin/dash
tmp-path = $${xvfb-instance:tmp-path}
[xvfb-instance]
recipe = slapos.cookbook:xvfb
runner-path = $${basedirectory:services}/xvfb
xvfb-path = ${xserver:location}/bin/Xvfb
fbdir-path = $${basedirectory:framebuffer}
tmp-path = $${basedirectory:run}
shell-path = ${dash:location}/bin/dash
xwd-path = ${xwd:location}/bin/xwd
xwd-hook-path = $${rootdirectory:bin}/xwd
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
var = $${buildout:directory}/var
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin
[basedirectory]
recipe = slapos.cookbook:mkdirectory
services = $${rootdirectory:etc}/run
run = $${rootdirectory:var}/run
framebuffer = $${rootdirectory:srv}/framebuffer
software/seleniumrunner/instance.cfg
View file @
82a85c26
[buildout]
[buildout]
parts =
parts =
firefox-instanc
e
switch-softwaretyp
e
eggs-directory = ${buildout:eggs-directory}
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
offline = true
# [selenium-instance]
[switch-softwaretype]
# recipe = slapos.cookbook:seleniumrunner
recipe = slapos.cookbook:softwaretype
#
default = ${template-selenium:output}
# runner-path = $${basedirectory:services}/selenium-runner
# browser = $${firefox-instance:runner-path}
# suite-url =
# report-url =
[firefox-instance]
[slap-connection]
recipe = slapos.cookbook:firefox
# part to migrate to new - separated words
runner-path = $${rootdirectory:bin}/firefox-sandboxed
computer-id = $${slap_connection:computer_id}
firefox-path = ${firefox:location}/firefox-slapos
partition-id = $${slap_connection:partition_id}
prefsjs-path = $${rootdirectory:etc}/prefs.js
server-url = $${slap_connection:server_url}
shell-path = ${dash:location}/bin/dash
software-release-url = $${slap_connection:software_release_url}
tmp-path = $${xvfb-instance:tmp-path}
key-file = $${slap_connection:key_file}
cert-file = $${slap_connection:cert_file}
[xvfb-instance]
recipe = slapos.cookbook:xvfb
runner-path = $${basedirectory:services}/xvfb
xvfb-path = ${xserver:location}/bin/Xvfb
fbdir-path = $${basedirectory:framebuffer}
tmp-path = $${basedirectory:run}
shell-path = ${dash:location}/bin/dash
xwd-path = ${xwd:location}/bin/xwd
xwd-hook-path = $${rootdirectory:bin}/xwd
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc
var = $${buildout:directory}/var
srv = $${buildout:directory}/srv
bin = $${buildout:directory}/bin
[basedirectory]
recipe = slapos.cookbook:mkdirectory
services = $${rootdirectory:etc}/run
run = $${rootdirectory:var}/run
framebuffer = $${rootdirectory:srv}/framebuffer
software/seleniumrunner/software.cfg
View file @
82a85c26
...
@@ -47,10 +47,17 @@ eggs =
...
@@ -47,10 +47,17 @@ eggs =
# Default template for the instance.
# Default template for the instance.
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg
url = ${:_profile_base_location_}/instance.cfg
md5sum =
4803dbd479f36b2b744075af2bf25dc1
md5sum =
c4ac5de141ae6a64848309af03e51d88
output = ${buildout:directory}/template.cfg
output = ${buildout:directory}/template.cfg
mode = 0644
mode = 0644
[template-selenium]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-selenium.cfg
md5sum = 8be91f4515decef0f8af5910e43e0e52
output = ${buildout:directory}/template-selenium.cfg
mode = 0644
[versions]
[versions]
# Use SlapOS patched zc.buildout
# Use SlapOS patched zc.buildout
zc.buildout = 1.6.0-dev-SlapOS-004
zc.buildout = 1.6.0-dev-SlapOS-004
...
...
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