How to get node's port that is registered on hub - selenium-grid

I setup a hub with (java -jar selenium-server-standalone-2.32.0.jar -role hub) on a machine A.
I used many machines to setup multiple nodes with random port to hub.
(
java -jar selenium-server-standalone-2.14.0.jar -role node -hub http:///[hub ip]:4444//grid//register [Random port number])
I know that I can see the node information (node's IP and port) that is registered on "
http:///[hub ip]:4444//grid//console"..
How can i get node's IP and port without open page "http:////[hub ip]:4444//grid//console"?.
Are there any API support to get node's ip or port?
Thanks

You can write a Selenium Grid Servlet to obtain this information - however this will run within the Selenium Grid process. Good example to set up a servlet can be found at this sample:
How do you create a /postResults servlet for selenium core
However, I get the sense that you want to expose this information to a third process. In this case, I would recommend 1) writing a servlet which exposes this data as json, 2) your process should make a web request to the servlet on the hub and parse the json response.

Related

What ports does Selenium grid uses for heartbeat signals?

I am trying to setup a testing environment using Selenium grid. The hub is to be running on an AWS computer while the nodes would be executed on AWS Workspaces. At this point, nodes can register in the hub, but about one minute latter, the hub complains stating:
Marking the node http://192.168.x.x:1444 as down: cannot reach the node for 2 tries
I have been doing some research and the problem seems to be that the hub sends heartbeat signals that do not reach the nodes and then it drops the session. Since there is a firewall that might be blocking the heartbeat signals, I need to know which ports are used to send such signals in order to configure the firewall accordingly.
Thank you

Manage Selenium Grid queue

I have 1 grid hub server and 3 selenium nodes.
I would like to execute multiple test suite against one Grid Hub server.
So that each test suite will be executed on all 3 servers and the rest of the test suits (pending) will wait till the current test suite will finish its execution.
Can the Grid Hub manage a queue of the test suits?
If no, is there any workaround or another solution?
TLDR; - Yes. Grid can manage.
Long answer
Selenium Hub doesn't care about whether the requests are coming from 3 different test suites or one. Think about it in this way - Hub will process all the requests that comes to it. When a request comes, hub will see if there is a node that has the capability to execute the request.
If there is one available and free, it will send the command to the node.
If there is a node which can execute the request but is busy now, it will send the command to the queue.
If there are no nodes which has the requested capability, the request is marked as failed.
Hub doesn't check for the source of request anywhere in the above flow.

How to use GFSH to connect peer to peer environment?

I am running Gemfire HTTP session management model within my application as P2P on a WebSphere. I can see the session logs on WAS. However, I could not find a way to connect it through gfsh from my desktop. I am using default seeting without locator. I would like to monitor Gemfire status, how?
Cache_Peer.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cache PUBLIC
"-//GemStone Systems, Inc.//GemFire Declarative Caching 6.5//EN"
"http://www.gemstone.com/dtd/cache6_6.dtd">
<cache>
<!-- This is the definition of the default session region -->
<region name="gemfire_modules_sessions">
<region-attributes scope="distributed-ack" enable-gateway="false" data-policy="replicate" statistics-enabled="false">
</region-attributes>
</region>
</cache>
As mentioned by Jens, Locator by defaults is a JMX manager. Any locator can become a JMX Manager when started. When you start up a locator, if no other JMX Manager is detected in the distributed system, the locator starts one automatically. If you start a second locator, it will detect the current JMX Manager and will not start up another JMX Manager unless the second locator's gemfire.jmx-manager-start property is set to true.
To turn any other member (p2p server) to JMX manager, set jmx-manager=true and jmx-manager-start=true in the server's gemfire.properties file.
To start the member as a JMX Manager node on the command line, provide --J=-Dgemfire.jmx-manager-start=true and --J=-Dgemfire.jmx-manager=true as arguments to either the start server command.
For example, to start a server as a JMX Manager on the gfsh command line:
gfsh>start server --name=<server-name> --J=-Dgemfire.jmx-manager=true \
--J=-Dgemfire.jmx-manager-start=true
Refer http://gemfire80.docs.pivotal.io/7.0.2/userguide/index.html#managing/management/jmx_manager_operations.html for more details.
By default, the locator in a client-server environment, would be a JMX manager. In a p2p setup you need to enable the JMX manager in one of your servers. You can do this by setting the GemFire properties: jmx-manager-enable=true and jmx-manager-start=true. It is also possible to have multiple JMX managers. If your p2p setup only consists of 2 servers, then having both be JMX managers would be OK.
You can use connect command from gfsh, it connects to the jmx manager.
If you have locator, then connect it using connect --locator=host[port] command, the jmx-manager automatically starts on locator. However, if you don't have locator, then you need to explicitly start jmx-manager on servers and connect it using connect --jmx-manager=host[port] command.
Refer http://gemfire.docs.pivotal.io/latest/userguide/index.html#tools_modules/gfsh/command-pages/connect.html for more details.
If the Gemfire cluster is running behind firewall, then use HTTP to connect, refer http://gemfire.docs.pivotal.io/latest/userguide/index.html#deploying/gfsh/gfsh_remote.html

How to unregister a selenium grid node using chef

I have a chef recipe that registers a node to a hub on the default port. But if the recipe is run on the node again , it gives me error which indicates that the port is already in use. So I need to have a check in place which either frees that port (not ideal) or randomly assigns a port while chef-client is running. I would like to unregister a node from the hub using a recipe. How do I do that?
With Selenium 2.53, you can unregister a node with an http command:
http://node_ip_address:port/selenium-server/driver/?cmd=shutDownSeleniumServer
Regards

How do I detect a network timeout of grid requests after starting a Sauce test?

How do I detect a network timeout of grid requests after starting a Sauce test using the RemoteWebDriver client object? I have a scenario that I want my framework to catch and that is that when connectivity outwards to SauceLabs is working but the connectivity back fails. In other words, this is a network scenario where my Selenium test sends a browser .get() and opens a new browser in SauceLabs with a new URL but then, because of a network issue the subsequent JSON packets fail and the tests appears to hang. I know what the problem is but I just want my unit test framework to report the network issue. Right now the RemoteWebDriver will timeout indefinitely when this condition occurs and that is not acceptable.
I know that to solve this will require an understanding of how the client side timeout works when a RemoteWebDriver client initially tries to send JSON commands to the Grid Hub.
I know I can specify the timeout when starting the Grid but similar options do not appear to be on the client side?
Hub start :- java -jar /tools/grid/selenium-server-standalone-2.35.0.jar
-role hub -maxSession 20 -browserTimeout 240
-remoteControlPollingIntervalInSeconds 180 -sessionMaxIdleTimeInSeconds 240
-newSessionMaxWaitTimeInSeconds 250 -timeout 30
Setting an idle timeout on the Sauce end might help with this: http://saucelabs.com/docs/additional-config#idle-timeout
This desired capability (set by default at 90 seconds) times out if no commands are received from your Selenium script.
While it can't detect network issues directly, this could prevent your minutes from being eaten by blocked responses.
You might also benefit from Sauce Connect (https://saucelabs.com/docs/connect), a free, standalone Java utility that enables you to test against firewalled resources. Connect also checks for dropped packets, and will automatically resend them (up to a certain point) in an attempt to re-establish the connection.