[JAVA] JMX support for Selenium Grid

This article is the second day article of Selenium / Appium Advent Calendar 2017.

Hello! Are you watching! !! Have you been! !! !! Please forgive me for leaving it for 2 months without anyone noticing that the server was down! !! !! !!

When a new version of Selenium is released, I try to check the updated contents for the time being, but the updated contents of the Java part of Selenium 3.8.0 have new items and it is eye-catching. It was.

https://github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG

* Added initial support for managing Grid Hubs and Nodes via JMX

What about JMX? ?? ??

Starting with Selenium 3.8.0, Selenium Grid supports JMX

Who gets it! ?? Looking at the issue on GitHub, it seems that the story was occasionally raised ...

What is JMX in the first place?

It is a public standard about how to manage various states of Java applications. You use SNMP to manage the state of your server, right? That's how JMX is used to manage the state of Java apps.

Let's actually see the state of Selenium Grid hubs and nodes with JMX

What information can you see at this point? Let's try it as much as you can easily.

Start up the hub and node of Selenium Grid properly.

In this article, I'll give you as good a system property as possible as a label to help you identify the role later.

$ java -D roll cake=Koyama roll\
       -jar selenium-server-standalone-3.8.0.jar \
       -role hub
$ java -D roll cake=Dojima roll\
       -jar selenium-server-standalone-3.8.0.jar \
       -role node

Check the process IDs of Selenium Grid hubs and nodes with the jps command.

It will be easier to understand if you add the l option and the v option.

$ jps -lv

32999 selenium-server-standalone-3.8.0.jar -D roll cake=Koyama roll
33001 selenium-server-standalone-3.8.0.jar -D roll cake=Dojima roll

Found. Looks delicious.

Try monitoring a specific process with the jconsole command

Let's start with the hub process. The label is Koyama Roll. In addition, Koyama Roll is said to be a moist and delicate sponge made by whipping plenty of honey and egg yolk and slowly baking the dough that carefully embraced the air. [^ 1]

$ jconsole 32999

I'm told something, but this time I just want to check it, so I don't care too much and proceed with "unprotected connection".

セキュアな接続が失敗しました。非セキュアで再試行しますか。

The jconsole screen is displayed. Click on the tab "MBeans".

jconsoleの画面

On the left side of the MBeans tab is a list of what you can monitor. ʻOrg.selenium.grid` is the new part of Selenium 3.8.0. Let's take a look at the contents.

MBeansタブ

Oh, there are many things that seem like that ~ "Hub" is the information of the hub itself, and "Remote Proxy" is the information of the connected node.

org.selenium.gridの中身

There has been an API for acquiring all items for a long time, but I think that the threshold has been lowered because acquisition via JMX has become possible as standard. If you use it in combination with a monitoring tool that can use JMX such as ZABBIX, it seems that you can operate Selenium Grid in a different way.

Next, let's look at the process of the node. The label is Dojima Roll. In addition, Dojima Roll is a custom-made cream made by carefully selecting several types of raw milk from Hokkaido and finishing it with a unique manufacturing method that is unique in the world, and it seems that it has a fresh taste like freshly squeezed milk. [^ 2]

$ jconsole 33001

Oh? You can't see anything here. JMX support seems to be designed so that if you monitor the hub, you can see everything, including the nodes.

ノード側の中身

Up to here for this time

Next time ... someone! Someone come! !! !! Selenium / Appium Advent Calendar 2017 is still waiting for your challenge!

Recommended Posts

JMX support for Selenium Grid
Extend Selenium Grid (Hub side)
Remedy for Selenium InvalidSelectorException error
Exception catch coverage support for Thread.sleep
[For beginners] Run Selenium in Java
Add image selector to Selenium Grid
Tips for handling pseudo-elements in Selenium