Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
moodle_rebase10.1.2
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
Dmitry Blinov
moodle_rebase10.1.2
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
Hide 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 @@
#
#############################################################################
from
datetime
import
datetime
from
erp5functionaltestreporthandler
import
ERP5TestReportHandler
from
ERP5TypeFunctionalTestCase
import
Xvfb
,
Firefox
,
TimeoutError
from
time
import
sleep
...
...
@@ -44,42 +45,34 @@ def run(args):
while
True
:
erp5_report
=
ERP5TestReportHandler
(
config
[
'test_report_instance_url'
],
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
:
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'
]
xvfb
=
Xvfb
(
config
[
'etc_directory'
],
config
[
'xvfb_binary'
])
os
.
environ
[
'DISPLAY'
]
=
config
[
'display'
]
xvfb
=
Xvfb
(
config
[
'etc_directory'
],
config
[
'xvfb_binary'
])
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
browser
=
Firefox
(
profile_dir
,
config
[
'base_url'
],
config
[
'browser_binary'
])
try
:
start
=
time
.
time
()
xvfb
.
run
()
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
browser
=
Firefox
(
profile_dir
,
config
[
'base_url'
],
config
[
'browser_binary'
])
try
:
start
=
time
.
time
()
xvfb
.
run
()
profile_dir
=
os
.
path
.
join
(
config
[
'etc_directory'
],
'profile'
)
browser
.
run
(
test_url
,
xvfb
.
display
)
erp5_report
.
reportStart
()
while
getStatus
(
config
[
'base_url'
])
is
''
:
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"
))
# 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."
)
browser
.
run
(
test_url
,
xvfb
.
display
)
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
:
browser
.
quit
()
xvfb
.
quit
()
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
)
...
...
@@ -99,12 +92,29 @@ def openUrl(url):
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
))
status
=
openUrl
(
'%s/portal_tests/TestTool_getResults
/
'
%
(
url
))
break
except
urllib2
.
URLError
,
urlError
:
if
i
is
4
:
raise
...
...
@@ -123,4 +133,4 @@ def assembleTestUrl(base_url, suite_name, user, password):
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
return
test_url
\ No newline at end of file
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