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

Add explicit reference to cdp types #15194

Merged

Conversation

RenderMichael
Copy link
Contributor

@RenderMichael RenderMichael commented Jan 30, 2025

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.

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.

PR Type

Enhancement, Tests


Description

  • Added configurable purge interval for dead nodes in Selenium Grid.

  • Updated Bazel dependencies to newer versions.

  • Enhanced .NET DevTools code generation with snake-case type names.

  • Improved test coverage for distributor and router functionalities.


Changes walkthrough 📝

Relevant files
Enhancement
7 files
Hub.java
Added purge nodes interval to Hub handlers.                           
+2/-1     
Standalone.java
Added purge nodes interval to Standalone handlers.             
+2/-1     
DistributorFlags.java
Introduced purge nodes interval configuration flag.           
+9/-0     
DistributorOptions.java
Added default and getter for purge nodes interval.             
+12/-0   
LocalDistributor.java
Integrated purge nodes interval into LocalDistributor logic.
+14/-4   
TypeInfo.cs
Added snake-case type name generation for .NET.                   
+13/-0   
DevToolsSessionDomains.hbs
Enhanced .NET templates with snake-case type serialization.
+5/-0     
Tests
13 files
AddingNodesTest.java
Updated tests to include purge nodes interval.                     
+10/-5   
DistributorDrainingTest.java
Enhanced tests for node draining with purge interval.       
+8/-4     
DistributorNodeAvailabilityTest.java
Added tests for node availability with purge interval.     
+12/-6   
DistributorTest.java
Improved distributor tests with purge interval.                   
+14/-7   
SessionSchedulingTest.java
Enhanced session scheduling tests with purge interval.     
+8/-4     
LocalDistributorTest.java
Updated LocalDistributor tests for purge interval.             
+14/-7   
GraphqlHandlerTest.java
Added GraphQL handler tests for purge interval.                   
+12/-6   
JmxTest.java
Enhanced JMX monitoring tests with purge interval.             
+2/-1     
NewSessionCreationTest.java
Updated session creation tests with purge interval.           
+6/-3     
RouterTest.java
Improved router tests with purge interval.                             
+2/-1     
SessionCleanUpTest.java
Enhanced session cleanup tests with purge interval.           
+4/-2     
SessionQueueGridTest.java
Updated session queue grid tests for purge interval.         
+2/-1     
SessionQueueGridWithTimeoutTest.java
Enhanced session queue grid timeout tests with purge interval.
+2/-1     
Dependencies
1 files
MODULE.bazel
Updated Bazel dependencies to newer versions.                       
+4/-4     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Potential Race Condition

    The new configurable purge interval for dead nodes is initialized after node health check service. Consider initializing purge service first to avoid potential race conditions with node health checks.

    // Disable purge dead nodes service if interval is set to zero
    if (!this.purgeNodesInterval.isZero()) {
      purgeDeadNodesService.scheduleAtFixedRate(
          GuardedRunnable.guard(model::purgeDeadNodes),
          this.purgeNodesInterval.getSeconds(),
          this.purgeNodesInterval.getSeconds(),
          TimeUnit.SECONDS);
    }
    Input Validation

    The getPurgeNodesInterval() method allows zero interval which disables purge service. Consider adding validation to ensure minimum reasonable interval.

    public Duration getPurgeNodesInterval() {
      // If the user sets 0s or less, we default to 0s and disable the purge dead nodes service.
      int seconds =
          Math.max(
              config
                  .getInt(DISTRIBUTOR_SECTION, "purge-nodes-interval")
                  .orElse(DEFAULT_PURGE_NODES_INTERVAL),
              0);
      return Duration.ofSeconds(seconds);
    }

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add null check for TypeName

    Add input validation to ensure TypeName and Namespace are not null before accessing
    Replace() method to prevent potential NullReferenceException.

    third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs [18-29]

     public string FullSnakeTypeName
     {
         get
         {
    +        if (string.IsNullOrEmpty(TypeName))
    +        {
    +            throw new ArgumentNullException(nameof(TypeName));
    +        }
    +        
             if (string.IsNullOrEmpty(Namespace))
             {
                 return TypeName.Replace(".", "_");
             }
     
             return $"{Namespace.Replace(".", "_")}_{TypeName.Replace(".", "_")}";
         }
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion adds important null validation for TypeName to prevent potential NullReferenceException, which could cause runtime crashes. This is a critical defensive programming practice for a property that's used in code generation.

    8

    @RenderMichael
    Copy link
    Contributor Author

    Failures on Ruby are unrelated, merging

    @RenderMichael RenderMichael changed the title Dotnet devtools aot Add explicit reference to cdp types Jan 30, 2025
    @RenderMichael RenderMichael merged commit a1f47e8 into SeleniumHQ:dotnet-devtools-aot Jan 30, 2025
    33 of 34 checks passed
    @RenderMichael RenderMichael deleted the dotnet-devtools-aot branch January 30, 2025 15:50
    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.

    4 participants