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

[grid][java]: apply protocol version in relay session factory #13880

Merged
merged 4 commits into from
May 4, 2024

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 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

A missing in part of last PR #13849 for a workaround in the relay node with Appium

To ensure the fix works, I set up an end2end test where able to execute and verify the session can be created successfully based on the dev package built locally. Result as below

image

Tested TOML

[server]
port = 5556

[node]
detect-drivers = false

[relay]
url = "http://localhost:4723"
status-endpoint = "/status"
protocol-version = "HTTP/1.1"
configs = [
    '1', '{"platformName": "android", "appium:platformVersion": "14", "appium:deviceName": "emulator-5554", "appium:automationName": "uiautomator2", "appium:browserName": "chrome", "browserName": "chrome"}'
]

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

Bug fix


Description

  • The PR addresses an issue where the serviceProtocolVersion was not being applied to the clientConfig in RelaySessionFactory.
  • This change ensures that if serviceProtocolVersion is provided, it is set in the clientConfig which is used to create a new session.

Changes walkthrough

Relevant files
Enhancement
RelaySessionFactory.java
Apply Protocol Version in RelaySessionFactory                       

java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java

  • Added conditional application of serviceProtocolVersion to
    clientConfig if it is not empty.
  • +3/-0     

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

    Copy link
    Contributor

    PR Description updated to latest commit (eed2f81)

    Copy link
    Contributor

    PR Review

    ⏱️ Estimated effort to review [1-5]

    2, because the changes are localized and straightforward, involving only a conditional addition of a protocol version to the client configuration. The logic is simple and the impact is limited to a specific part of the code.

    🧪 Relevant tests

    No

    🔍 Possible issues

    Possible Bug: The check for serviceProtocolVersion.isEmpty() assumes that serviceProtocolVersion is not null. If serviceProtocolVersion can be null, this could lead to a NullPointerException. It would be safer to include a null check.

    🔒 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
    Contributor

    PR Code Suggestions

    CategorySuggestions                                                                                                                                                       
    Best practice
    Use a local variable for the modified client configuration to ensure thread safety.

    To ensure thread safety and immutability, consider using a local variable for the modified
    clientConfig when setting the version, instead of reassigning the existing clientConfig
    variable. This approach avoids potential issues in a multi-threaded environment where
    clientConfig might be shared or reused.

    java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java [162-164]

    +ClientConfig updatedClientConfig = clientConfig;
     if (!serviceProtocolVersion.isEmpty()) {
    -  clientConfig = clientConfig.version(serviceProtocolVersion);
    +  updatedClientConfig = clientConfig.version(serviceProtocolVersion);
     }
    +HttpClient client = clientFactory.createClient(updatedClientConfig);
     

    ✨ 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
    Member

    @diemol diemol left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Thank you, @VietND96!

    @diemol
    Copy link
    Member

    diemol commented May 3, 2024

    I cannot update the fork because maintainers have no permission, this is missing

    image

    @VietND96
    Copy link
    Member Author

    VietND96 commented May 4, 2024

    @diemol probably the fork in an org and something restricted that I can't remove. Anyhow, I just rebased the branch

    @diemol diemol merged commit fe2edbd into SeleniumHQ:trunk May 4, 2024
    35 of 36 checks passed
    @VietND96 VietND96 deleted the node-appium branch May 4, 2024 12:48
    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Oct 29, 2024
    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.

    2 participants