Reputation: 2470
We have the grid console to check whether the nodes status, whether it is running any tests or not. So, if there is any other way to get the status of the hub, to determine if its being used or no?
Actual reason for getting this is to create a job to do a clean up/restart of the hub and node machines.
PS: I did some search, but i couldn't get any way around as of now.
Upvotes: 1
Views: 5135
Reputation: 14746
You don't need to be building a custom servlet for this.
Assuming that your grid is running on localhost
and is listening on port 4444
if you invoke the URL http://localhost:4444/grid/api/hub
(GET operation), you should see a JSON response as below
{
"success":true,
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"newSessionWaitTimeout":-1,
"throwOnCapabilityNotPresent":true,
"cleanUpCycle":5000,
"custom":{
},
"host":"localhost",
"maxSession":1,
"servlets":[
],
"browserTimeout":0,
"debug":false,
"jettyMaxThreads":-1,
"port":4444,
"role":"hub",
"timeout":1800,
"newSessionRequestCount":0,
"slotCounts":{
"free":0,
"total":0
}
}
In the above JSON response, if you parse the values of free
and total
you should be able to get what you need. For e.g., if the values of free
is equal to the value of total
then it means there are no new sessions running.
Upvotes: 6
Reputation: 9058
Look at this link - http://www.seleniumhq.org/docs/07_selenium_grid.jsp -- go to the "Adding custom servlets at the hub and/or node" section.
You can run customized servlets extending org.openqa.grid.web.servlet.RegistryBasedServlet
which will give you the information. This servlet has the Registry
object getter method getRegistry()
.
The Registry object has a getActiveSessions()
method which returns a collection of tests currently running. You can check the size etc for your requirements.
Look at the selenium source code in the org.openqa.grid.web package, there are lots of servlets already coded.
Upvotes: 1