From fd5f54ebd7f859502c4fd5dd3431b4ad8ec2125b Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Mon, 24 Jun 2024 11:34:52 -0700 Subject: [PATCH] [rb] Run remote tests on RBE (#13906) --- .github/workflows/ci-ruby.yml | 11 ++------- .skipped-tests | 23 +++++++++++++++---- .../selenium/webdriver/driver_spec.rb | 5 +++- .../webdriver/firefox/profile_spec.rb | 3 ++- .../selenium/webdriver/spec_helper.rb | 1 + .../spec_support/test_environment.rb | 23 +++++++++++++++---- rb/spec/tests.bzl | 11 +-------- 7 files changed, 47 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index 79f941a23485b..419e17df5065c 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -74,12 +74,9 @@ jobs: - edge - firefox os: - - ubuntu - windows - macos exclude: - - browser: edge - os: ubuntu - browser: edge os: macos with: @@ -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: @@ -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 }} @@ -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/... diff --git a/.skipped-tests b/.skipped-tests index 15dc35e335372..67c89f8d55b35 100644 --- a/.skipped-tests +++ b/.skipped-tests @@ -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 diff --git a/rb/spec/integration/selenium/webdriver/driver_spec.rb b/rb/spec/integration/selenium/webdriver/driver_spec.rb index 748fcc1ff6cb1..b5b03c662b0d5 100644 --- a/rb/spec/integration/selenium/webdriver/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/driver_spec.rb @@ -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| diff --git a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb index 9da5a67e957df..d385a5eb08ab9 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb @@ -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| diff --git a/rb/spec/integration/selenium/webdriver/spec_helper.rb b/rb/spec/integration/selenium/webdriver/spec_helper.rb index cd93fc5eb0aed..560f2fe3199c3 100644 --- a/rb/spec/integration/selenium/webdriver/spec_helper.rb +++ b/rb/spec/integration/selenium/webdriver/spec_helper.rb @@ -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 diff --git a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb index 881a729ebd4b3..517a10ce1e909 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -88,6 +88,16 @@ 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, @@ -95,7 +105,7 @@ def remote_server log_level: WebDriver.logger.debug? && 'FINE', background: true, timeout: 60, - args: %w[--selenium-manager true --enable-managed-downloads true] + args: args ) end @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index bb1604161659a..3aa6dab97c941 100644 --- a/rb/spec/tests.bzl +++ b/rb/spec/tests.bzl @@ -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": { @@ -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": { @@ -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"],