Site icon Vinsguru

Selenium WebDriver – Managing Selenium Grid Infrastructure using Arquillian Cube

In the previous article, we saw how easily we could set up the selenium-grid infrastructure using docker.

By using docker-compose file, we can setup the containers for the selenium grid. Then we can start our automated functional tests using the grid. Once the execution is done, we can issue a simple command to bring the entire selenium grid infrastructure down. However these docker containers have to be managed (starting/stopping etc) by us either manually or some custom script.

Can this be simplified further?

Yes, That is what we are going to see in this article!

Arquillian Cube:

Arquillian provides a nice extension – Arquillian-Cube – by which we can integrate docker and Arquillian, so that docker containers life cycle can be managed directly by Arquillian itself.

Arquillian Drone + Cube:

I am going to use one of my existing Arquillian drone project for this article.

I add below maven dependencies in my maven project.

 

Then I define the infrastructure information we need in a docker-compose.yml file as shown here.

Then I add the docker server, compose file and drone information in the Arquillian.xml

That’s it! We are set to control the docker-containers directly as part of our automated tests.

Did you notice? One cool thing here is – I do not have to modify anything in the test. That is the power of Arquillian. It helps us to keep the config completely away from the script. In future, If you do not want to use docker or selenium grid in future, you just need to update the arquillian.xml. Nothing else.  This is cool..Why would I not love Arquillian, then? 🙂

Now If I start my test, Arquillian first launches all the required containers, waits for the containers to be up and running, then it starts my tests.

I tried to record the simple test to show you all how it works – I have my eclipse IDE open where I have my arquillian drone tests + cube. My putty is connected to the remote ubuntu server where docker server is running. I keep on issuing ‘sudo docker ps -a‘ on putty to show all the containers in the remote server.

 

You could see in putty that initially there were no containers. Before the test starts 3 containers were created as given in the docker-compose file.then the test starts. Once the test finishes, there is no sign of any docker containers running in the machine.

Summary:

Docker has already saved us a lot of effort in setting up infrastructure quickly. Arquillian by managing docker’s containers life cycle, it makes our job even more easier. Our Arquillian test itself launches the required containers for the test, runs the test and shuts the containers down!!

 

Happy Testing & Subscribe 🙂

 

Share This:

Exit mobile version