From 49357923da8971a841408450cc3ff558a79fbfb1 Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Fri, 3 May 2024 13:05:14 -0700 Subject: [PATCH 1/8] [rb] Run remote tests on RBE --- .github/workflows/ci-ruby.yml | 9 --------- .skipped-tests | 13 +++++++++++++ rb/.ruby-version | 2 +- .../webdriver/spec_support/test_environment.rb | 16 +++++++++++++--- rb/spec/tests.bzl | 11 +---------- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index 653034f947f45..7c3eed49b46ba 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -75,16 +75,11 @@ jobs: - firefox - safari os: - - ubuntu - windows - macos exclude: - - browser: edge - os: ubuntu - browser: edge os: macos - - browser: safari - os: ubuntu - browser: safari os: windows with: @@ -111,10 +106,6 @@ jobs: include: - browser: edge os: windows - - browser: chrome - os: ubuntu - - browser: firefox - os: ubuntu - browser: safari os: macos with: diff --git a/.skipped-tests b/.skipped-tests index 674c795e2c3a0..e59ae8c317803 100644 --- a/.skipped-tests +++ b/.skipped-tests @@ -23,7 +23,20 @@ -//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-remote -//rb/spec/integration/selenium/webdriver/edge:service-edge +-//rb/spec/integration/selenium/webdriver/edge:service-edge-remote -//rb/spec/integration/selenium/webdriver/firefox:service-firefox +-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-remote -//rb/spec/integration/selenium/webdriver/firefox:service-firefox-beta +-//rb/spec/integration/selenium/webdriver/firefox:service-firefox-beta-remote -//rb/spec/integration/selenium/webdriver:element-chrome +-//rb/spec/integration/selenium/webdriver:element-chrome-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-remote +-//rb/spec/integration/selenium/webdriver/remote:driver-firefox-beta-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-remote +-//rb/spec/integration/selenium/webdriver/remote:element-firefox-beta-remote diff --git a/rb/.ruby-version b/rb/.ruby-version index 818bd47abfc91..1a40db2721535 100644 --- a/rb/.ruby-version +++ b/rb/.ruby-version @@ -1 +1 @@ -3.0.6 +jruby-9.4.6.0 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 aafa63bcd17bb..2dba129383c48 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -85,6 +85,16 @@ def app_server end def remote_server + if ENV.key?('CHROMEDRIVER_BINARY') + args = ["-Dwebdriver.chrome.driver=#{ENV['CHROMEDRIVER_BINARY']}"] + elsif ENV.key?('MSEDGEDRIVER_BINARY') + args = ["-Dwebdriver.edge.driver=#{ENV['MSEDGEDRIVER_BINARY']}"] + elsif ENV.key?('GECKODRIVER_BINARY') + args = ["-Dwebdriver.gecko.driver=#{ENV['GECKODRIVER_BINARY']}"] + else + args = %w[--selenium-manager true --enable-managed-downloads true] + end + @remote_server ||= Selenium::Server.new( remote_server_jar, java: bazel_java, @@ -92,7 +102,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 @@ -250,7 +260,7 @@ def safari_preview_driver(**opts) def chrome_options(args: [], **opts) 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(browser_version: 'stable', args: args, **opts) end @@ -258,7 +268,7 @@ def chrome_options(args: [], **opts) def edge_options(args: [], **opts) 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(browser_version: 'stable', args: args, **opts) end diff --git a/rb/spec/tests.bzl b/rb/spec/tests.bzl index 9c0f1596de6e9..ce5013b974fec 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"], From f302ffac0d736ccaed89e26a6e79f4c5ffe718be Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sat, 11 May 2024 14:11:24 -0700 Subject: [PATCH 2/8] wip on bzl --- MODULE.bazel | 2 +- rb/.ruby-version | 2 +- .../webdriver/spec_support/shared_examples/concurrent_driver.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 93578f833b573..e22b4dfeb04fe 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -18,7 +18,7 @@ bazel_dep(name = "rules_oci", version = "1.0.0") bazel_dep(name = "rules_pkg", version = "0.9.1") bazel_dep(name = "rules_python", version = "0.31.0") bazel_dep(name = "rules_proto", version = "5.3.0-21.7") -bazel_dep(name = "rules_ruby", version = "0.8.1") +bazel_dep(name = "rules_ruby", version = "0.10.0") linter = use_extension("@apple_rules_lint//lint:extensions.bzl", "linter") linter.configure( diff --git a/rb/.ruby-version b/rb/.ruby-version index 1a40db2721535..c4b55a7895d10 100644 --- a/rb/.ruby-version +++ b/rb/.ruby-version @@ -1 +1 @@ -jruby-9.4.6.0 +jruby-9.4.5.0 diff --git a/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb b/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb index e3728572e5efd..675b67d29f5d7 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb @@ -30,7 +30,7 @@ create_driver! end - it 'starts multiple drivers sequentially', guard do + fit 'starts multiple drivers sequentially', guard do expected_count = WebDriver::Platform.ci ? 2 : 4 expected_count.times do thread = Thread.new do From abe368dd58aba7325a0747618b809ad60ec8284d Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sat, 22 Jun 2024 13:00:10 -0700 Subject: [PATCH 3/8] Guard some specs --- .../selenium/webdriver/driver_spec.rb | 4 +++- .../selenium/webdriver/firefox/profile_spec.rb | 3 ++- .../selenium/webdriver/spec_helper.rb | 1 + .../shared_examples/concurrent_driver.rb | 2 +- .../webdriver/spec_support/test_environment.rb | 18 +++++++++--------- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/rb/spec/integration/selenium/webdriver/driver_spec.rb b/rb/spec/integration/selenium/webdriver/driver_spec.rb index 748fcc1ff6cb1..4645a7490d3ed 100644 --- a/rb/spec/integration/selenium/webdriver/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/driver_spec.rb @@ -22,7 +22,9 @@ 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]}, + except: {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..2c5fcd29df9ac 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', + except: {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..863e6e21bd528 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, Dir.pwd.start_with?('/mnt/engflow')) results = guards.disposition send(*results) if results diff --git a/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb b/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb index 675b67d29f5d7..e3728572e5efd 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/shared_examples/concurrent_driver.rb @@ -30,7 +30,7 @@ create_driver! end - fit 'starts multiple drivers sequentially', guard do + it 'starts multiple drivers sequentially', guard do expected_count = WebDriver::Platform.ci ? 2 : 4 expected_count.times do thread = Thread.new do 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 e2a05dcaa70f9..d324eb00fc861 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -88,15 +88,15 @@ def app_server end def remote_server - if ENV.key?('CHROMEDRIVER_BINARY') - args = ["-Dwebdriver.chrome.driver=#{ENV['CHROMEDRIVER_BINARY']}"] - elsif ENV.key?('MSEDGEDRIVER_BINARY') - args = ["-Dwebdriver.edge.driver=#{ENV['MSEDGEDRIVER_BINARY']}"] - elsif ENV.key?('GECKODRIVER_BINARY') - args = ["-Dwebdriver.gecko.driver=#{ENV['GECKODRIVER_BINARY']}"] - else - args = %w[--selenium-manager true --enable-managed-downloads true] - end + 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, From 37c7031588e9da7cf91b452962fc7e8a0f518721 Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sat, 22 Jun 2024 13:54:17 -0700 Subject: [PATCH 4/8] fix --- rb/.ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rb/.ruby-version b/rb/.ruby-version index c4b55a7895d10..818bd47abfc91 100644 --- a/rb/.ruby-version +++ b/rb/.ruby-version @@ -1 +1 @@ -jruby-9.4.5.0 +3.0.6 From 7266e77d9c7225f83930d65fea1d51f55cd3f427 Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sat, 22 Jun 2024 14:23:11 -0700 Subject: [PATCH 5/8] use exclude --- rb/spec/integration/selenium/webdriver/driver_spec.rb | 7 ++++--- .../integration/selenium/webdriver/firefox/profile_spec.rb | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rb/spec/integration/selenium/webdriver/driver_spec.rb b/rb/spec/integration/selenium/webdriver/driver_spec.rb index 4645a7490d3ed..487fbabe9017f 100644 --- a/rb/spec/integration/selenium/webdriver/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/driver_spec.rb @@ -22,9 +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]}, - except: {driver: 'remote', rbe: true, reason: 'Cannot start 2+ drivers at once.'} + 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 2c5fcd29df9ac..2e52ac7a69a35 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb @@ -37,7 +37,7 @@ module Firefox end it 'is able to use the same profile more than once', - except: {driver: 'remote', rbe: true, reason: 'Cannot start 2+ drivers at once.'} do + 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| From dbabc044a699fed10fa8cd5198fff2aca548e368 Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sat, 22 Jun 2024 16:17:31 -0700 Subject: [PATCH 6/8] fix --- rb/spec/integration/selenium/webdriver/driver_spec.rb | 2 +- .../integration/selenium/webdriver/firefox/profile_spec.rb | 3 ++- rb/spec/integration/selenium/webdriver/spec_helper.rb | 2 +- .../selenium/webdriver/spec_support/test_environment.rb | 7 ++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/rb/spec/integration/selenium/webdriver/driver_spec.rb b/rb/spec/integration/selenium/webdriver/driver_spec.rb index 487fbabe9017f..b5b03c662b0d5 100644 --- a/rb/spec/integration/selenium/webdriver/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/driver_spec.rb @@ -24,7 +24,7 @@ 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]}, - {driver: 'remote', rbe: true, reason: 'Cannot start 2+ drivers at once.'} + {driver: :remote, rbe: true, reason: 'Cannot start 2+ drivers at once.'} ] it 'creates default capabilities', exclude: {browser: %i[safari safari_preview]} do diff --git a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb index 2e52ac7a69a35..5266bd093611a 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb @@ -37,7 +37,8 @@ module Firefox end it 'is able to use the same profile more than once', - exclude: {driver: 'remote', rbe: true, reason: 'Cannot start 2+ drivers at once.'} do + exclude: {driver: :remote, rbe: true, reason: 'Cannot start 2+ drivers at once.'} do + abort 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 863e6e21bd528..560f2fe3199c3 100644 --- a/rb/spec/integration/selenium/webdriver/spec_helper.rb +++ b/rb/spec/integration/selenium/webdriver/spec_helper.rb @@ -57,7 +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, Dir.pwd.start_with?('/mnt/engflow')) + 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 d324eb00fc861..517a10ce1e909 100644 --- a/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb +++ b/rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb @@ -115,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 @@ -201,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 From 4db0a43058f4efd44f27130279120b66567ecd74 Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sat, 22 Jun 2024 16:43:56 -0700 Subject: [PATCH 7/8] fix --- rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb index 5266bd093611a..d385a5eb08ab9 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/profile_spec.rb @@ -38,7 +38,6 @@ module Firefox it 'is able to use the same profile more than once', exclude: {driver: :remote, rbe: true, reason: 'Cannot start 2+ drivers at once.'} do - abort 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| From 700ee6d8810e09c6d6ada3dec2f3192fa7cca7bd Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Mon, 24 Jun 2024 08:01:06 -0700 Subject: [PATCH 8/8] remove safari --- .github/workflows/ci-ruby.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci-ruby.yml b/.github/workflows/ci-ruby.yml index 803c015213a0f..419e17df5065c 100644 --- a/.github/workflows/ci-ruby.yml +++ b/.github/workflows/ci-ruby.yml @@ -79,8 +79,6 @@ jobs: exclude: - browser: edge os: macos - - browser: safari - os: windows with: name: Local Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} @@ -106,8 +104,6 @@ jobs: include: - browser: edge os: windows - - browser: safari - os: macos with: name: Remote Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }}