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
Alexander Emmerich
erp5
Commits
2a2ee5d3
Commit
2a2ee5d3
authored
Sep 11, 2018
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5TypeFunctionalTestCase: workaround selenium localhost name resolution
/reviewed-on
nexedi/erp5!742
parent
419b4041
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
+34
-0
No files found.
product/ERP5Type/tests/ERP5TypeFunctionalTestCase.py
View file @
2a2ee5d3
...
...
@@ -46,6 +46,40 @@ from selenium.webdriver.common.by import By
from
selenium.webdriver.support.ui
import
WebDriverWait
from
selenium.webdriver.support
import
expected_conditions
as
EC
# selenium workaround for localhost / 127.0.0.1 resolution
# ------
# Selenium connects starts a service on localhost, but when ERP5
# is running under userhosts wrapper, because we don't have entry for
# localhost in our pseudo /etc/hosts file, localhost resolution is delegated
# to local DNS, which might not resolve localhost - for example 8.8.8.8
# does not.
# We work around this by monkey-patching the places in selenium where
# localhost resolution is required and returning 127.0.0.1 directly.
# This is not really correct, it would be better to use SlapOS partition IP,
# but we need a quick fix to have test results again.
# Service.start polls utils.is_connectable(port) - without host argument, assuming the default
# localhost.
# https://github.com/SeleniumHQ/selenium/blob/selenium-3.14.0/py/selenium/webdriver/common/service.py#L99
import
selenium.webdriver.common.utils
original_is_connectable
=
selenium
.
webdriver
.
common
.
utils
.
is_connectable
def
is_connectable
(
port
,
host
=
"localhost"
):
if
host
==
"localhost"
:
host
=
"127.0.0.1"
return
original_is_connectable
(
port
,
host
)
selenium
.
webdriver
.
common
.
utils
.
is_connectable
=
is_connectable
# Service.get_service_url hardcodes 127.0.0.1
# https://github.com/SeleniumHQ/selenium/blob/selenium-3.14.0/py/selenium/webdriver/common/service.py#L56
original_join_host_port
=
selenium
.
webdriver
.
common
.
utils
.
join_host_port
def
join_host_port
(
host
,
port
):
if
host
==
"localhost"
:
host
=
"127.0.0.1"
return
original_join_host_port
(
host
,
port
)
selenium
.
webdriver
.
common
.
utils
.
join_host_port
=
join_host_port
# /selenium workaround
ZELENIUM_BASE_URL
=
"%s/portal_tests/%s/core/TestRunner.html?test=../test_suite_html&auto=on&resultsUrl=../postResults&__ac_name=%s&__ac_password=%s"
tests_framework_home
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__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