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
Joanne Hugé
slapos
Commits
6a87e823
Commit
6a87e823
authored
Jan 18, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor seleniumrunner to work without having to delete any zope object.
parent
b71717b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
36 deletions
+46
-36
slapos/recipe/seleniumrunner/testrunner.py
slapos/recipe/seleniumrunner/testrunner.py
+46
-36
No files found.
slapos/recipe/seleniumrunner/testrunner.py
View file @
6a87e823
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#
#
#############################################################################
#############################################################################
from
datetime
import
datetime
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
ERP5TypeFunctionalTestCase
import
Xvfb
,
Firefox
,
TimeoutError
from
ERP5TypeFunctionalTestCase
import
Xvfb
,
Firefox
,
TimeoutError
from
time
import
sleep
from
time
import
sleep
...
@@ -44,14 +45,7 @@ def run(args):
...
@@ -44,14 +45,7 @@ def run(args):
while
True
:
while
True
:
erp5_report
=
ERP5TestReportHandler
(
config
[
'test_report_instance_url'
],
erp5_report
=
ERP5TestReportHandler
(
config
[
'test_report_instance_url'
],
config
[
'project'
]
+
'@'
+
config
[
'suite_name'
])
config
[
'project'
]
+
'@'
+
config
[
'suite_name'
])
# Clean old test results if any
openUrl
(
'%s/TestTool_cleanUpTestResults?__ac_name=%s&__ac_password=%s'
%
(
config
[
'base_url'
],
config
[
'user'
],
config
[
'password'
]))
try
:
try
:
if
getStatus
(
config
[
'base_url'
])
is
not
''
:
print
(
"ERROR : Impossible to clean old test result(s)"
)
else
:
# Environment is ready, we launch test.
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
xvfb
=
Xvfb
(
config
[
'etc_directory'
],
config
[
'xvfb_binary'
])
xvfb
=
Xvfb
(
config
[
'etc_directory'
],
config
[
'xvfb_binary'
])
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
...
@@ -62,22 +56,21 @@ def run(args):
...
@@ -62,22 +56,21 @@ def run(args):
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
browser
.
run
(
test_url
,
xvfb
.
display
)
browser
.
run
(
test_url
,
xvfb
.
display
)
erp5_report
.
reportStart
()
erp5_report
.
reportStart
()
while
getStatus
(
config
[
'base_url'
])
is
''
:
while
not
isTestFinished
(
config
[
'base_url'
])
:
time
.
sleep
(
10
)
time
.
sleep
(
10
)
print
(
"Test not finished yet."
)
if
(
time
.
time
()
-
start
)
>
float
(
timeout
):
if
(
time
.
time
()
-
start
)
>
float
(
timeout
):
raise
TimeoutError
(
"Test took more them
%s seconds"
%
timeout
)
raise
TimeoutError
(
"Test took more than
%s seconds"
%
timeout
)
except
TimeoutError
:
except
TimeoutError
:
continue
continue
finally
:
finally
:
browser
.
quit
()
browser
.
quit
()
xvfb
.
quit
()
xvfb
.
quit
()
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"
,
"replace"
))
"replace"
))
# Clean test results for next test
openUrl
(
'%s/TestTool_cleanUpTestResults?__ac_name=%s&__ac_password=%s'
%
(
config
[
'base_url'
],
config
[
'user'
],
config
[
'password'
]))
print
(
"Test finished and report sent, sleeping."
)
print
(
"Test finished and report sent, sleeping."
)
except
urllib2
.
URLError
,
urlError
:
except
urllib2
.
URLError
,
urlError
:
...
@@ -99,12 +92,29 @@ def openUrl(url):
...
@@ -99,12 +92,29 @@ def openUrl(url):
f
.
close
()
f
.
close
()
return
file_content
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
):
def
getStatus
(
url
):
try
:
try
:
# Try 5 times.
# Try 5 times.
for
i
in
range
(
5
):
for
i
in
range
(
5
):
try
:
try
:
status
=
openUrl
(
'%s/portal_tests/TestTool_getResults'
%
(
url
))
status
=
openUrl
(
'%s/portal_tests/TestTool_getResults
/
'
%
(
url
))
break
break
except
urllib2
.
URLError
,
urlError
:
except
urllib2
.
URLError
,
urlError
:
if
i
is
4
:
raise
if
i
is
4
:
raise
...
...
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