Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rb] Ensure server is started with Bazel JDK #13882

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from
Open

Conversation

p0deje
Copy link
Member

@p0deje p0deje commented Apr 26, 2024

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Type

enhancement


Description

  • Added support for launching Selenium server using Bazel JDK launcher if specified in the environment variable SELENIUM_BAZEL_SERVER_LAUNCHER.
  • Updated test configurations to use the Bazel server launcher and modified the relevant environment settings.
  • Maintained backward compatibility by using the default Java command if the Bazel launcher is not specified.

Changes walkthrough

Relevant files
Enhancement
server.rb
Support Bazel JDK Launcher for Server Command                       

rb/lib/selenium/server.rb

  • Modified server command construction to support Bazel JDK launcher.
  • Added conditional to use SELENIUM_BAZEL_SERVER_LAUNCHER environment
    variable if present.
  • Retained default Java command if the environment variable is not set.
  • +6/-2     
    Configuration changes
    test_environment.rb
    Configure Test Environment for Bazel JDK Launcher               

    rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

  • Added conditional to modify SELENIUM_BAZEL_SERVER_LAUNCHER environment
    variable for test setup.
  • +4/-0     
    tests.bzl
    Update Test Configurations for Bazel Server                           

    rb/spec/tests.bzl

  • Updated test configuration to use Bazel server instead of the jar
    file.
  • Added environment variable for Bazel server launcher in test
    configurations.
  • +5/-2     

    PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    PR Description updated to latest commit (a57778f)

    Copy link

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are moderate in size and scope, involving environment variable checks and command construction adjustments. The logic is straightforward, but careful attention is needed to ensure the new environment configurations are handled correctly.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The use of ENV.fetch('SELENIUM_BAZEL_SERVER_LAUNCHER', '') in rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb might lead to unexpected behavior if the environment variable is not set, as it defaults to an empty string which is then attempted to be split. This should be handled more gracefully.

    🔒 Security concerns

    No


    ✨ Review tool usage guide:

    Overview:
    The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

    The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

    • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
    /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
    
    [pr_reviewer]
    some_config1=...
    some_config2=...
    

    See the review usage page for a comprehensive guide on using this tool.

    Copy link

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Improve code safety by avoiding in-place modification of shared arrays.

    To avoid potential issues with mutable state, create a new array for server_command
    instead of modifying properties in-place. This ensures that the original properties array
    remains unchanged, which can prevent side effects if it's used elsewhere in the code.

    rb/lib/selenium/server.rb [245]

    -server_command = [ENV['SELENIUM_BAZEL_SERVER_LAUNCHER']] + properties + args + @additional_args
    +server_command = [ENV['SELENIUM_BAZEL_SERVER_LAUNCHER']] + properties.dup + args + @additional_args
     
    Bug
    Prevent duplication of command line arguments in the server command.

    Ensure that the @additional_args are not duplicated in the server_command when
    constructing the command for the Selenium server. This can be achieved by removing
    @additional_args from the concatenation since it's already included in properties.

    rb/lib/selenium/server.rb [247]

    -server_command = ['java'] + properties + ['-jar', @jar] + args + @additional_args
    +server_command = ['java'] + properties + ['-jar', @jar] + args
     
    Correct the formatting of the path in the environment variable to avoid potential path resolution issues.

    Ensure that the path specified in SELENIUM_BAZEL_SERVER_LAUNCHER is correctly formatted
    without unnecessary single quotes, which might be interpreted literally in some contexts,
    leading to path resolution issues.

    rb/spec/tests.bzl [179]

    -"SELENIUM_BAZEL_SERVER_LAUNCHER": "'$(rootpaths //java/src/org/openqa/selenium/grid:selenium_server)'",
    +"SELENIUM_BAZEL_SERVER_LAUNCHER": "$(rootpaths //java/src/org/openqa/selenium/grid:selenium_server)",
     
    Maintainability
    Use a local variable instead of modifying an environment variable in-place.

    Instead of modifying the SELENIUM_BAZEL_SERVER_LAUNCHER environment variable in-place,
    consider using a local variable to hold the modified value. This prevents unintended side
    effects across different parts of the application that might rely on the original
    environment variable.

    rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb [39]

    -ENV['SELENIUM_BAZEL_SERVER_LAUNCHER'] = ENV.fetch('SELENIUM_BAZEL_SERVER_LAUNCHER', '').split(' ').first
    +selenium_bazel_server_launcher = ENV.fetch('SELENIUM_BAZEL_SERVER_LAUNCHER', '').split(' ').first
     
    Possible issue
    Add a check to ensure the JAR file path is provided when not using Bazel.

    To ensure that the server command is correctly constructed regardless of the environment,
    add a check to ensure that @jar is not nil or empty when not using Bazel to launch the
    server. This prevents runtime errors when attempting to launch the server without a
    specified JAR file.

    rb/lib/selenium/server.rb [247]

    +raise 'JAR path must be provided' if @jar.nil? || @jar.empty?
     server_command = ['java'] + properties + ['-jar', @jar] + args + @additional_args
     

    ✨ Improve tool usage guide:

    Overview:
    The improve tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on a PR.

    • When commenting, to edit configurations related to the improve tool (pr_code_suggestions section), use the following template:
    /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
    
    [pr_code_suggestions]
    some_config1=...
    some_config2=...
    

    See the improve usage page for a comprehensive guide on using this tool.

    Copy link

    codiumai-pr-agent-pro bot commented Apr 26, 2024

    CI Failure Feedback

    (Checks updated until commit afaf1c2)

    Action: Test / All RBE tests

    Failed stage: [❌]

    Failure summary:

    The action failed due to the cancellation of the operation. This is indicated by the log message at
    line 10286, which explicitly states "The operation was canceled." The reasons for the cancellation
    are not specified in the provided log excerpt.

    Relevant error logs:
    1:  ##[group]Operating System
    2:  Ubuntu
    ...
    
    973:  Package 'php-symfony-debug-bundle' is not installed, so not removed
    974:  Package 'php-symfony-dependency-injection' is not installed, so not removed
    975:  Package 'php-symfony-deprecation-contracts' is not installed, so not removed
    976:  Package 'php-symfony-discord-notifier' is not installed, so not removed
    977:  Package 'php-symfony-doctrine-bridge' is not installed, so not removed
    978:  Package 'php-symfony-doctrine-messenger' is not installed, so not removed
    979:  Package 'php-symfony-dom-crawler' is not installed, so not removed
    980:  Package 'php-symfony-dotenv' is not installed, so not removed
    981:  Package 'php-symfony-error-handler' is not installed, so not removed
    ...
    
    10278:  Web shell: https://tmate.io/t/R38b3MUspMhbs6SRddLdmDn32
    10279:  SSH: ssh R38b3MUspMhbs6SRddLdmDn32@sfo2.tmate.io
    10280:  Web shell: https://tmate.io/t/R38b3MUspMhbs6SRddLdmDn32
    10281:  SSH: ssh R38b3MUspMhbs6SRddLdmDn32@sfo2.tmate.io
    10282:  Web shell: https://tmate.io/t/R38b3MUspMhbs6SRddLdmDn32
    10283:  SSH: ssh R38b3MUspMhbs6SRddLdmDn32@sfo2.tmate.io
    10284:  Web shell: https://tmate.io/t/R38b3MUspMhbs6SRddLdmDn32
    10285:  SSH: ssh R38b3MUspMhbs6SRddLdmDn32@sfo2.tmate.io
    10286:  ##[error]The operation was canceled.
    

    ✨ CI feedback usage guide:

    The CI feedback tool (/checks) automatically triggers when a PR has a failed check.
    The tool analyzes the failed checks and provides several feedbacks:

    • Failed stage
    • Failed test name
    • Failure summary
    • Relevant error logs

    In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:

    /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
    

    where {repo_name} is the name of the repository, {run_number} is the run number of the failed check, and {job_number} is the job number of the failed check.

    Configuration options

    • enable_auto_checks_feedback - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
    • excluded_checks_list - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
    • enable_help_text - if set to true, the tool will provide a help message with the feedback. Default is true.
    • persistent_comment - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.
    • final_update_message - if persistent_comment is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true.

    See more information about the checks tool in the docs.

    @p0deje p0deje force-pushed the rb-use-jdk-bazel branch 3 times, most recently from c7f3f8f to b75cf82 Compare April 26, 2024 23:10
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    1 participant