-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Enriching Hub Status to include Node info #6127
Conversation
Currently the end-point /grid/api/hub/status does not provide information about the nodes attached to it and also the busy/free status per browser flavor on each of the nodes. Enriching the end-point to provide node info when invoked with the option /grid/api/hub/status?configuration=nodes Sample payload as below: { "nodes": [ { "Id": "http://192.168.1.6:5555", "browsers": [ { "browser": "safari", "slots": { "busy": 0, "total": 1 } }, { "browser": "chrome", "slots": { "busy": 0, "total": 5 } }, { "browser": "firefox", "slots": { "busy": 0, "total": 5 } } ] } ], "success": true }
For my own clarity, would this provide essentially what |
@luke-hill,
* I am not aware of an end-point "/get_node_config" available in the Hub
that is currently doing this. Can you please help point me to it. I am
currently just enriching this
<https://github.com/SeleniumHQ/selenium/blob/master/java/server/src/org/openqa/grid/web/Hub.java#L134>
endpoint
* To answer to your question, no it does not because we aren't getting hold
of the configuration of the node (which is static), but this is dynamic
information and will reflect exactly how many sessions are in use vs free
per browser flavor on each of the nodes at any given point in time.
|
The top url I mentioned might be an SGE addon (Not sure). Rightio. But sorry to be a pain. Isn't that provided (I hope this isn't SGE as well!), by |
Yes the console ( url-to-grid/grid/console) provides you with this info.
But it's html and not JSON. So you would need to screen scrape to get this
data. This PR makes it easy to extract out that info.
|
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.
LGTM.
My only minor suggestion -- "free" and "busy" could be statically declared strings.
@mach6 - Thanks for the comments. I have extracted out all repeating strings in that class and converted them into private constants. Please take a look. |
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.
If I was a man who asked for unicorns, I'd ask for a test of some description to ensure that this continues working....
I think we're nearly there. Thank you for all the work so far.
@@ -167,4 +185,57 @@ protected void process( | |||
throw new IOException(e); | |||
} | |||
} | |||
|
|||
private static boolean IsKeyPresentIn(List<String> keys, String key) { |
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.
Nit: java method names begin with a lower-case letter. We can fix this once the PR is merged in.
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.
My bad. That should have been caught by me (I guess its the after effects of toggling between Java and Golang from work). Fixed it.
if (request.getParameter("configuration") != null && !"".equals(request.getParameter("configuration"))) { | ||
keysToReturn = Arrays.asList(request.getParameter("configuration").split(",")); | ||
} else if (requestJSON != null && requestJSON.containsKey("configuration")) { | ||
if (request.getParameter(CONFIGURATION) != null && !"".equals(request.getParameter(CONFIGURATION))) { |
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.
You can use !Strings.isNullOrEmpty(request.getParameter(CONFIGURATION))
here for a slightly clearer check here (I realise that this wasn't done before)
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.
Fixed
keysToReturn = Arrays.asList(request.getParameter("configuration").split(",")); | ||
} else if (requestJSON != null && requestJSON.containsKey("configuration")) { | ||
if (request.getParameter(CONFIGURATION) != null && !"".equals(request.getParameter(CONFIGURATION))) { | ||
keysToReturn = Arrays.asList(request.getParameter(CONFIGURATION).split(",")); |
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.
Are empty values allowed in the list? If not Splitter.on(",").trimResults().omitEmptyStrings().splitToList()
may be a better fit.
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.
Fixed
|
||
private Map<String, Object> getNodeInfo(RemoteProxy remoteProxy) { | ||
return ImmutableSortedMap.of( | ||
"Id", remoteProxy.getId(), |
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 Id
capitalised, but browser
not? Maybe leave both lower case?
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.
fixed.
} | ||
|
||
private static <T> Collector<T, ?, Integer> counting() { | ||
return reducing(0, e -> 1, Integer::sum); |
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 looks like an IntStreams sum
method, but presumably that isn't appropriate to use here
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.
Yes. Collectors.counting()
returns a long. I didn't want to make use of a long just to count a bunch of proxies. That is why I resorted to creating this reducing function
65a2016
to
b231f90
Compare
I have now added required tests for this changeset and also addressed all the other review feedback. Please help take a look. |
b231f90
to
4f9d089
Compare
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.
Looks great. I'll merge this now.
Currently the end-point /grid/api/hub/status does not provide information about the nodes attached to it and also the busy/free status per browser flavor on each of the nodes. Enriching the end-point to provide node info when invoked with the option /grid/api/hub/status?configuration=nodes Sample payload as below: { "nodes": [ { "Id": "http://192.168.1.6:5555", "browsers": [ { "browser": "safari", "slots": { "busy": 0, "total": 1 } }, { "browser": "chrome", "slots": { "busy": 0, "total": 5 } }, { "browser": "firefox", "slots": { "busy": 0, "total": 5 } } ] } ], "success": true }
This appears to be a breaking change when using an existing grid for < 3.14 as it is expected the enhanced metadata. A graceful fall back could have been nice as the update was getting pulled in transitively via other dependencies. Just wanted to mention to save anybody else a day trying to figure out why the all their automated test suites start to fail :/ |
Currently the end-point /grid/api/hub/status
does not provide information about the nodes
attached to it and also the busy/free status
per browser flavor on each of the nodes.
Enriching the end-point to provide node info
when invoked with the option
/grid/api/hub/status?configuration=nodes
Sample payload as below:
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement