Friday, September 20, 2013

Sharing remote screen for Selenium tests monitoring

CASE STUDY
We have a big suite of Selenium tests. It is running on a remote continuous integration server (Jenkins). Some tests are successfully passing on the local machine but are always failing when running on the server. It was really difficult to find a cause of the failure on a remote server using only logs.
Task/goal: Find a way of graphical monitoring of the tests running process on the remote server.


SOLUTION
Short idea & results: We started sharing X display of a remote server over VNC to our local computers. This really helped, because now we can see what is going on with tests when they’re running on the remote machine and it is much easier to fix broken tests.


First of all install:
  • Xvfb (on a remote server) - a server that performs all graphical operations in memory, not showing any screen output. From the point of view of the client, it acts exactly like any other server, serving requests and sending events and errors as appropriate. However, no output is shown.




  • VNC client (on a local machine) - a program that watches, controls, and interacts with a server. The client controls the server.


Follow the steps below:
  1. Open your Jenkins project configuration page and make sure that this check-box is checked.
           Now Xvfb will start every time our project is building. Run a Jenkins project now.


  1. Find a number of display on which your Jenkins job is running.
  • in command prompt launch to your server via SSH and run a command: ps afx | grep vfb
  • you should see something like this (in this case number of display is 2):   
 


  1. Start x11vnc server on a display which you found in a previous step:
                       x11vnc -display :<NUMBER_OF_DISPLAY>


  1. Create an SSH tunnel between your local machine and the server where you tests are running:

  2. Run VNC client on your local machine, create a new connection. With Chicken of the VNC it looks like this:
Now click on Connect, wait for a while…
Woohoo! Now you see what is going on with your tests on a remote machine.