Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
Boxiang Sun
gitlab-ce
Commits
05886c63
Commit
05886c63
authored
Dec 10, 2018
by
ddavison
Committed by
Sanad Liaquat
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow QA to run in remote grid environments
Signed-off-by:
ddavison
<
ddavison@gitlab.com
>
parent
9370ba6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
17 deletions
+49
-17
qa/qa/runtime/browser.rb
qa/qa/runtime/browser.rb
+24
-17
qa/qa/runtime/env.rb
qa/qa/runtime/env.rb
+25
-0
No files found.
qa/qa/runtime/browser.rb
View file @
05886c63
...
...
@@ -40,22 +40,23 @@ module QA
return
if
Capybara
.
drivers
.
include?
(
:chrome
)
Capybara
.
register_driver
:chrome
do
|
app
|
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
chrome
(
# This enables access to logs with `page.driver.manage.get_log(:browser)`
loggingPrefs:
{
browser:
"ALL"
,
client:
"ALL"
,
driver:
"ALL"
,
server:
"ALL"
}
)
Capybara
.
register_driver
QA
::
Runtime
::
Env
.
browser
do
|
app
|
capabilities
=
Selenium
::
WebDriver
::
Remote
::
Capabilities
.
send
(
QA
::
Runtime
::
Env
.
browser
,
# This enables access to logs with `page.driver.manage.get_log(:browser)`
loggingPrefs:
{
browser:
"ALL"
,
client:
"ALL"
,
driver:
"ALL"
,
server:
"ALL"
})
if
QA
::
Runtime
::
Env
.
accept_insecure_certs?
capabilities
[
'acceptInsecureCerts'
]
=
true
end
options
=
Selenium
::
WebDriver
::
Chrome
::
Options
.
new
# QA::Runtime::Env.browser.capitalize will work for every driver type except PhantomJS.
# We will have no use to use PhantomJS so this shouldn't be a problem.
options
=
Selenium
::
WebDriver
.
const_get
(
QA
::
Runtime
::
Env
.
browser
.
capitalize
)
::
Options
.
new
options
.
add_argument
(
"window-size=1240,1680"
)
# Chrome won't work properly in a Docker container in sandbox mode
...
...
@@ -80,12 +81,18 @@ module QA
# Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252
options
.
add_argument
(
"disable-dev-shm-usage"
)
if
QA
::
Runtime
::
Env
.
running_in_ci?
Capybara
::
Selenium
::
Driver
.
new
(
app
,
browser: :chrome
,
selenium_options
=
{
browser:
QA
::
Runtime
::
Env
.
browser
,
clear_local_storage:
true
,
desired_capabilities:
capabilities
,
options:
options
}
selenium_options
[
:url
]
=
QA
::
Runtime
::
Env
.
remote_grid
if
QA
::
Runtime
::
Env
.
remote_grid
Capybara
::
Selenium
::
Driver
.
new
(
app
,
selenium_options
)
end
...
...
@@ -93,7 +100,7 @@ module QA
Capybara
::
Screenshot
.
prune_strategy
=
:keep_last_run
# From https://github.com/mattheworiordan/capybara-screenshot/issues/84#issuecomment-41219326
Capybara
::
Screenshot
.
register_driver
(
:chrome
)
do
|
driver
,
path
|
Capybara
::
Screenshot
.
register_driver
(
QA
::
Runtime
::
Env
.
browser
)
do
|
driver
,
path
|
driver
.
browser
.
save_screenshot
(
path
)
end
...
...
@@ -102,8 +109,8 @@ module QA
end
Capybara
.
configure
do
|
config
|
config
.
default_driver
=
:chrome
config
.
javascript_driver
=
:chrome
config
.
default_driver
=
QA
::
Runtime
::
Env
.
browser
config
.
javascript_driver
=
QA
::
Runtime
::
Env
.
browser
config
.
default_max_wait_time
=
10
# https://github.com/mattheworiordan/capybara-screenshot/issues/164
config
.
save_path
=
::
File
.
expand_path
(
'../../tmp'
,
__dir__
)
...
...
qa/qa/runtime/env.rb
View file @
05886c63
...
...
@@ -56,6 +56,31 @@ module QA
@personal_access_token
||=
ENV
[
'PERSONAL_ACCESS_TOKEN'
]
end
def
remote_grid
# if username specified, password/auth token is required
# can be
# - "http://user:pass@somehost.com/wd/hub"
# - "https://user:pass@somehost.com:443/wd/hub"
# - "http://localhost:4444/wd/hub"
"
#{
remote_grid_protocol
}
://
#{
"
#{
remote_grid_username
}
:
#{
remote_grid_access_key
}
@"
if
remote_grid_username
}#{
ENV
[
'QA_REMOTE_GRID'
]
}
/wd/hub"
if
ENV
[
'QA_REMOTE_GRID'
]
end
def
remote_grid_username
ENV
[
'QA_REMOTE_GRID_USERNAME'
]
end
def
remote_grid_access_key
ENV
[
'QA_REMOTE_GRID_ACCESS_KEY'
]
end
def
remote_grid_protocol
ENV
[
'QA_REMOTE_GRID_PROTOCOL'
]
||
'http'
end
def
browser
ENV
[
'QA_BROWSER'
]
||
:chrome
end
def
user_username
ENV
[
'GITLAB_USERNAME'
]
end
...
...
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