Skip to content

Commit

Permalink
[rb] Run remote tests on RBE (#13906)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0deje authored Jun 24, 2024
1 parent 8184982 commit fd5f54e
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 30 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/ci-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,9 @@ jobs:
- edge
- firefox
os:
- ubuntu
- windows
- macos
exclude:
- browser: edge
os: ubuntu
- browser: edge
os: macos
with:
Expand All @@ -94,7 +91,7 @@ jobs:
--local_test_jobs 1
--test_size_filters large
--test_tag_filters ${{ matrix.browser }}
${{ matrix.os != 'windows' && '--pin_browsers=true' || '' }}
${{ matrix.os != 'windows' && '--pin_browsers' || '' }}
//rb/spec/...
integration-tests-remote:
Expand All @@ -107,10 +104,6 @@ jobs:
include:
- browser: edge
os: windows
- browser: chrome
os: ubuntu
- browser: firefox
os: ubuntu
with:
name: Remote Tests (${{ matrix.browser }}, ${{ matrix.os }})
browser: ${{ matrix.browser }}
Expand All @@ -124,5 +117,5 @@ jobs:
--local_test_jobs 1
--test_size_filters large
--test_tag_filters ${{ matrix.browser }}-remote
${{ matrix.os != 'windows' && '--pin_browsers=true' || '' }}
${{ matrix.os != 'windows' && '--pin_browsers' || '' }}
//rb/spec/...
23 changes: 18 additions & 5 deletions .skipped-tests
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,26 @@
-//py:test-chrome-test/selenium/webdriver/chrome/chrome_service_tests.py
-//py:test-chrome-test/selenium/webdriver/chrome/proxy_tests.py
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome-bidi
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome-remote
-//rb/spec/integration/selenium/webdriver/edge:service-edge
-//rb/spec/integration/selenium/webdriver/edge:service-edge-bidi
-//rb/spec/integration/selenium/webdriver/edge:service-edge-remote
-//rb/spec/integration/selenium/webdriver/firefox:driver-firefox-beta-bidi
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-beta
-//rb/spec/integration/selenium/webdriver:element-chrome
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome-bidi
-//rb/spec/integration/selenium/webdriver/edge:service-edge-bidi
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-bidi
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-beta-bidi
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-beta-remote
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-bidi
-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-remote
-//rb/spec/integration/selenium/webdriver/remote:driver-chrome-remote
-//rb/spec/integration/selenium/webdriver/remote:driver-edge-remote
-//rb/spec/integration/selenium/webdriver/remote:driver-firefox-beta-remote
-//rb/spec/integration/selenium/webdriver/remote:driver-firefox-remote
-//rb/spec/integration/selenium/webdriver/remote:element-chrome-remote
-//rb/spec/integration/selenium/webdriver/remote:element-edge-remote
-//rb/spec/integration/selenium/webdriver/remote:element-firefox-beta-remote
-//rb/spec/integration/selenium/webdriver/remote:element-firefox-remote
-//rb/spec/integration/selenium/webdriver:element-chrome
-//rb/spec/integration/selenium/webdriver:element-chrome-bidi
-//rb/spec/integration/selenium/webdriver/firefox:driver-firefox-beta-bidi
-//rb/spec/integration/selenium/webdriver:element-chrome-remote
5 changes: 4 additions & 1 deletion rb/spec/integration/selenium/webdriver/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
module Selenium
module WebDriver
describe Driver, exclusive: {bidi: false, reason: 'Not yet implemented with BiDi'} do
it_behaves_like 'driver that can be started concurrently', exclude: {browser: %i[safari safari_preview]}
it_behaves_like 'driver that can be started concurrently', exclude: [
{browser: %i[safari safari_preview]},
{driver: :remote, rbe: true, reason: 'Cannot start 2+ drivers at once.'}
]

it 'creates default capabilities', exclude: {browser: %i[safari safari_preview]} do
reset_driver! do |driver|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ module Firefox
end
end

it 'is able to use the same profile more than once' do
it 'is able to use the same profile more than once',
exclude: {driver: :remote, rbe: true, reason: 'Cannot start 2+ drivers at once.'} do
reset_driver!(profile: profile) do |driver1|
expect { wait(5).until { driver1.find_element(id: 'oneline') } }.not_to raise_error
reset_driver!(profile: profile) do |driver2|
Expand Down
1 change: 1 addition & 0 deletions rb/spec/integration/selenium/webdriver/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
guards.add_condition(:platform, WebDriver::Platform.os)
guards.add_condition(:headless, !ENV['HEADLESS'].nil?)
guards.add_condition(:bidi, !ENV['WEBDRIVER_BIDI'].nil?)
guards.add_condition(:rbe, GlobalTestEnv.rbe?)

results = guards.disposition
send(*results) if results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,24 @@ def app_server
end

def remote_server
args = if ENV.key?('CHROMEDRIVER_BINARY')
["-Dwebdriver.chrome.driver=#{ENV['CHROMEDRIVER_BINARY']}"]
elsif ENV.key?('MSEDGEDRIVER_BINARY')
["-Dwebdriver.edge.driver=#{ENV['MSEDGEDRIVER_BINARY']}"]
elsif ENV.key?('GECKODRIVER_BINARY')
["-Dwebdriver.gecko.driver=#{ENV['GECKODRIVER_BINARY']}"]
else
%w[--selenium-manager true --enable-managed-downloads true]
end

@remote_server ||= Selenium::Server.new(
remote_server_jar,
java: bazel_java,
port: random_port,
log_level: WebDriver.logger.debug? && 'FINE',
background: true,
timeout: 60,
args: %w[--selenium-manager true --enable-managed-downloads true]
args: args
)
end

Expand All @@ -105,6 +115,10 @@ def bazel_java
File.expand_path(File.read(File.expand_path(ENV.fetch('WD_BAZEL_JAVA_LOCATION'))).chomp)
end

def rbe?
Dir.pwd.start_with?('/mnt/engflow')
end

def reset_remote_server
@remote_server&.stop
@remote_server = nil
Expand Down Expand Up @@ -191,7 +205,8 @@ def current_env
driver: driver,
version: driver_instance.capabilities.browser_version,
platform: Platform.os,
ci: Platform.ci
ci: Platform.ci,
rbe: rbe?
}
end

Expand Down Expand Up @@ -255,7 +270,7 @@ def chrome_options(args: [], **opts)
opts[:web_socket_url] = true if ENV['WEBDRIVER_BIDI'] && !opts.key?(:web_socket_url)
opts[:binary] ||= ENV['CHROME_BINARY'] if ENV.key?('CHROME_BINARY')
args << '--headless=chrome' if ENV['HEADLESS']
args << '--no-sandbox' if ENV['NO_SANDBOX']
args << '--no-sandbox' unless Platform.windows?
args << '--disable-gpu'
WebDriver::Options.chrome(args: args, **opts)
end
Expand All @@ -265,7 +280,7 @@ def edge_options(args: [], **opts)
opts[:web_socket_url] = true if ENV['WEBDRIVER_BIDI'] && !opts.key?(:web_socket_url)
opts[:binary] ||= ENV['EDGE_BINARY'] if ENV.key?('EDGE_BINARY')
args << '--headless=chrome' if ENV['HEADLESS']
args << '--no-sandbox' if ENV['NO_SANDBOX']
args << '--no-sandbox' unless Platform.windows?
args << '--disable-gpu'
WebDriver::Options.edge(args: args, **opts)
end
Expand Down
11 changes: 1 addition & 10 deletions rb/spec/tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ BROWSERS = {
}) | select({
"@selenium//common:use_headless_browser": {"HEADLESS": "true"},
"//conditions:default": {},
}) | select({
"@platforms//os:windows": {},
"//conditions:default": {"NO_SANDBOX": "true"},
}),
},
"edge": {
Expand All @@ -56,9 +53,6 @@ BROWSERS = {
}) | select({
"@selenium//common:use_headless_browser": {"HEADLESS": "true"},
"//conditions:default": {},
}) | select({
"@platforms//os:windows": {},
"//conditions:default": {"NO_SANDBOX": "true"},
}),
},
"firefox": {
Expand Down Expand Up @@ -188,10 +182,7 @@ def rb_integration_test(name, srcs, deps = [], data = [], browsers = BROWSERS.ke
"WD_SPEC_DRIVER": "remote",
},
main = "@bundle//bin:rspec",
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + [
"{}-remote".format(browser),
"skip-remote", # Do we want to run remote tests in RBE?
],
tags = COMMON_TAGS + BROWSERS[browser]["tags"] + tags + ["{}-remote".format(browser)],
deps = ["//rb/spec/integration/selenium/webdriver:spec_helper"] + BROWSERS[browser]["deps"] + deps,
visibility = ["//rb:__subpackages__"],
target_compatible_with = BROWSERS[browser]["target_compatible_with"],
Expand Down

0 comments on commit fd5f54e

Please sign in to comment.