-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Eliminate vendor-specific handling of extension capabilities #14485
base: trunk
Are you sure you want to change the base?
[grid] Eliminate vendor-specific handling of extension capabilities #14485
Conversation
PR Reviewer Guide 🔍
|
a82c998
to
14999b7
Compare
PR Code Suggestions ✨
|
14999b7
to
dbe50be
Compare
ac4802b
to
2d9609b
Compare
java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java
Outdated
Show resolved
Hide resolved
java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java
Outdated
Show resolved
Hide resolved
2d9609b
to
cca2c28
Compare
java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java
Outdated
Show resolved
Hide resolved
d5aeb2e
to
84b6795
Compare
6a5663f
to
d993e8c
Compare
d993e8c
to
378cb93
Compare
98354f4
to
bd93f46
Compare
@diemol It seems like you're advocating for ignoring all extension capabilities for purposes of slot matching. This approach would mean that custom matchers would be required in all scenarios where matching based on extension capabilities is desired (e.g. - The enhancements I recommended in the PR description provide the outline of a mechanism for vendors to define slot matcher extensions that evaluate their specific matching criteria. This would enable vendors to define their own custom criteria without the need to implement custom slot matchers. |
Not really. Just the ones named |
@diemol I can revise my PR to implement this strategy. It is significantly less complex to implement and much easier to describe. I'll update the unit tests accordingly. Is the concept of a slot matcher extension mechanism worth exploring further? This would be an additional method for the WebDriverInfo interface, which is already being scanned for service providers. |
You can already implement your own SlotMatcher, see |
@diemol Yes, but you can only specify one custom matcher. If you need sessions from multiple vendors, this means running with multiple hubs. With a slot matcher extension mechanism, vendor-specific matching gets activated automatically and standing up a grid that supplies sessions from multiple vendors is much easier. |
The matcher is used both at the Distributor and the Node. You would need to decouple that logic to allow more matchers. |
@diemol The extension would be implemented in DefaultSlotMatcher, which is already integrated with Distributor and Node. |
283dae7
to
7727862
Compare
@diemol I've revised the matcher to only ignore extension capabilities with suffix "options" (case-insensitive) and updated the affected unit test accordingly. I also updated the PR description to indicate the revised implementation. |
376bfb7
to
63f9b9a
Compare
List of prefixed extension capabilities we never should try to match, they should be | ||
matched in the Node or in the browser driver. | ||
*/ | ||
private static final List<String> EXTENSION_CAPABILITIES_PREFIXES = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to keep this because the browser vendors can make changes and we don't want to change things here every time they do it. For example, moz:debuggerAddress
is now being sent from the client side to enable CDP in Firefox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core objective of this PR is to migrate all vendor-specific capabilities that should be ignored for purposes of slot matching into "options" objects. (I had initially implemented this to ignore all extension capabilities with "complex" values.) The current strategy of ignoring all extension capabilities with a small number of "special" prefixes while considering all extension capabilities with "non-special" prefixes produces inconsistent behavior and requires vendors to implement special-case slot matchers, each of which is mutually exclusive to every other custom slot matcher.
In your example of moz:debuggerAddress
, the desire is to ignore this capability for slot matching. What happens if Mozilla adds a new extension capability that should be considered for slot matching? The current strategy doesn't allow for this possibility, forcing Mozilla to implement a custom slot matcher, and for all affected clients to update their Grid configurations to add this matcher. For clients with Grid configurations that supply sessions of browsers from multiple vendors, this could force complete reconfiguration of their automation infrastructure, segregating their session providers into multiple grids by vendor.
With the revised behavior implemented by this PR, moz:debuggerAddress
would be considered for slot matching. To ignore this option for slot matching, it would be migrated into moz:firefoxOptions
, I believe this is a more sensible approach, because this capability truly is an option, not an identity specifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current strategy of ignoring all extension capabilities with a small number of "special" prefixes while considering all extension capabilities with "non-special" prefixes produces inconsistent behavior and requires vendors to implement special-case slot matchers, each of which is mutually exclusive to every other custom slot matcher
This is an assumption.
If Mozilla adds a new capability for matching, we ignore it and pass it along to GeckoDriver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is precisely my point. Outside of mutually exclusive custom slot matchers, vendors have no control over how their extension capabilities are handled. Capabilities with "special" prefixes will always be ignored and capabilities with "non-special" prefixes will always be considered. This PR eliminates the inconsistency and adds the ability for vendors to control whether their extension capabilities will be treated as identifying characteristics or as end-node configuration options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave the prefixes. Then we can merge the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apple does not need to be there; this might change in the future.
However, Appium does need to be considered, except the options
one.
Browser vendors just need to have their capabilities passed along. Why do you keep saying that they will use their capabilities to do matching in Grid when this is not true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appium extension capabilities are most certainly being considered for slot matching. This is still true in the revised functionality implemented by this PR. I think the behavior of the current matcher is what necessitated the merge operation and explicit check for 'appium:app'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my current implementation, all existing Appium extension capabilities are considered except for the four suffixes: "options", "Options", "loggingPrefs", and "debuggerAddress". There's implementation in the Appium server that merges the prefixed capabilities into their "options" collection with no thought to which capabilities are "identity" values and which are configuration options. I don't know if this gets reflected back to Grid in a way that's visible to DefaultSlotMatcher, but their configuration examples indicate that every option can be declared in either place. I'm attempting to engage the Appium folks to see how they feel about deprecating this pattern in favor of clear differentiation between "identity" values and configuration options.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not prefer to leave loggingPrefs
, and debuggerAddress
hardcoded. I prefer to have the 4 prefixes ignored as it was before.
I don't mean to be rude, I am taking your considerations, and I strongly prefer the approach I've been suggesting in previous comments. Please let me know if that works for you or if I should raise the change in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for remaining engaged in this conversation! I understand your hesitation to alter the established behavior. Perhaps the new behavior can be activated by an optional core Selenium capability. That way, the new behavior will only be present when it's explicitly requested.
790f82e
to
1ead41a
Compare
filteredStereotype.setCapability(CapabilityType.BROWSER_NAME, (String) null); | ||
} | ||
|
||
capabilities = capabilities.merge(filteredStereotype); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I remember. This was done because the user can specify something in the stereotype that will be sent to the Node that will receive the request.
List of prefixed extension capabilities we never should try to match, they should be | ||
matched in the Node or in the browser driver. | ||
*/ | ||
private static final List<String> EXTENSION_CAPABILITIES_PREFIXES = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it an inconsistency? Browser vendors just need those capabilities to be passed along. They do not use the Grid and configure stereotypes to do matching.
1ead41a
to
e4762bb
Compare
e4762bb
to
2f55884
Compare
User description
Description
The existing handling of extension capabilities assigns special significance to four recognized prefixes:
goog:
,moz:
,ms:
, andse:
. Capabilities with these prefixes are entirely ignored by the current default slot matcher implementation, but custom prefixes are considered, as well as those for Safari and Appium. This inconsistency means that properties in extension capabilities can cause affectednewSession
requests to fail even though extension capabilities are supposed to be vendor-specific and should probably not be evaluated by the default slot matcher.This PR retains the "special" status of the "se:" prefix and specifically filters out all extension capabilities with names that end with "options", "Options", "loggingPrefs", and "debuggerAddress". This maintains existing behavior while allowing node configurations and
newSession
requests to include extension capabilities that won't affect slot matching.Motivation and Context
Revolves #14461
The strategy employed by the PR is that extension capabilities which should be ignored for matching can be expressed as capabilities with name prefix "se:" or one of the "special" name suffixes. All other extension capabilities will be considered for slot matching. This is a generalization/extrapolation of existing patterns from current use cases.
Recommended slot matcher enhancements
To reduce the need for custom slot matchers, we could extend the WebDriverInfo interface to add a new method that vendors could implement to evaluate their own criteria:
The default implementation would return
null
to indicate that no evaluation has been performed. If the vendor chooses to implement thematches
method, their initial step must be to invoke their ownisSupporting
method, returningnull
if the corresponding driver doesn't support the specified capabilities.The implementation in DefaultSlotMatcher would be updated to iterate over the available WebDriverInfo providers, retaining only those whose
isSupporting
methods returntrue
. Thematches
methods of this filtered list of providers will then be applied to the available nodes to determine which of these satisfies the criteria specified by the client request. The nodes that satisfy these evaluations (if any) would then be evaluated against the remaining common criteria.Another potential enhancement would be to enable vendor-specific
matches
methods to return a weighted integer result instead of a simpleBoolean
. This would enable best-match behavior. Perhaps this is getting too complicated, though.Types of changes
Checklist
PR Type
Bug fix, Tests
Description
DefaultSlotMatcher
, opting to ignore all extension capabilities with names ending in "options" (case-insensitive).RelaySessionFactory
to streamline session creation by removing redundant capability filtering.DefaultSlotMatcherTest
to align with the new handling of extension capabilities.Changes walkthrough 📝
DefaultSlotMatcher.java
Revise extension capabilities handling in DefaultSlotMatcher
java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java
RelaySessionFactory.java
Simplify session creation in RelaySessionFactory
java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java
DefaultSlotMatcherTest.java
Update DefaultSlotMatcher tests for revised capability handling
java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java
handling.