TestingGeek

Learn, Share and Keep Learning

Home Testing Tools Test Execution Distributed Automated Testing - Hudson, Maven & Selenium
Distributed Automated Testing - Hudson, Maven & Selenium
Testing Tools - Test Execution

Selenium Grid allows you to distribute your tests on multiple machines so that you can run your tests in parallel on different browsers. The same results could be achieved using Hudson slaves and maven builds. In this article we will talk about using Hudson to kick off your automated tests on different machines and on different browsers. Before we go on and start talking about setting up slave build machines we will first understand what is Hudson and what is meant by Hudson slaves.


What is Hudson ?

Hudson in simple terms is continuous integration engine which allows developers to continuously integrate their work and allow other users to obtain the build when needed. More information on hudson could be obtained here

Why do we need slaves in Hudson?
Hudson supports distributed builds which simply means 'division of labor'. If there are a  large number of projects then hudson could be configured to use some machines as slaves and start using those machines for build distribution.If you want to read more details about distributed builds you could definitely go to the Hudson wiki page

Good...but how is Selenium related to this
You must be wondering where does Selenium fit into all this. Then let us clear this confusion. Hudson suports Maven 2 for building the projects . There is a seperate a job type for Maven 2 in hudson. Before I keep on ranting about Maven let us get a brief understanding of what maven is? . Maven is an open source build tool for Java projects just like ant, make fille etc. It uses a simple easy to undersatnd 'DECLARATIVE' language making it easier for you to manage builds and reporting from a centralised place. The heart of maven is POM (Process Object Model).

Still no signs of selenium. Well you could run your selenium tests as maven builds and specify the version of selenium RC to use to run the tests. Please ses a sample POM file structure for running the selenium tests as maven builds.

 

In this POM file you have specifed you need SELENIUM server and its version 0.9.2 to run. For understanding more about the Maven POM files you could use this resource.

 

In a nutshell, you could use the maven 2 task of Hudson for building your Selenium RC tests written in java.

 

Then why cannot we run the tests on Hudson server itself?

You must be scratching your head about why cannot we run these tests on the hudson server itself where you are running all the builds. The answer is yes you can  in a very limited manner and no we can not for more comprehensive cross browser tests. Most of the times Hudson servers are set up on unix machines where there is only one common browser 'firefox ' is available. This firefox is also running headless (without any windows in simple terms) so you could run only a sub set of automated tests especially those which does not involve any flash. Another issue is that you cannot run any tests on other commonly used browsers such as Internet Explorer.
We need other machines to:
1. Run a full comprehensive set of tests for Flash objects
2. Run the tests on other commonly used browsers such as Internet Explorer(IE).

This leads us to another hurdle 'How to set up your windows slaves for Unix masters?' In the next section we will specify the steps to do that

Hudson Linux Master and Windows Slave machine

You could set up different slave machines with different browsers and build/run your tests there.

 

This section would give you the step by step guide to setup windows Slave for unix master. You need to configure the master machine to use external executors of the builds

Set up executors and create projects on master machine

1. Go to hudson url('/ http://build..com/hudson/ ')

2. Now click on "Manage Hudson"

3. It should take you to a page where you could configure husdon and mange slaves

4. Click on "Configure Executors"

5. Use this page to configure your slaves

  • "Add" - This will add a new slave
  • "Name" - Enter a name for the slave, ex "WindowsXP" or "MacOSTiger"
  • "# of executors" - Enter the number of executors for the slave, that is the number of concurrent builds allowed on the slave. A good value to start with would be the number of processors. Just give 1 to start with :)
  • "remote FS root" - Enter the absolute path of this work directory on the slave, such as '/export/home/hudson'. The directory will be created on the slave and all data needed in a build will be stored there. ex "c:\dev\hudson_slave".Make sure you share the directory.
  • "usage" - Set it to "Use this slave for tied projects only"
  • "labels" - Enter any number of labels for the slave, ex "windows","Mac"

6 . Press Save.

7. Go to the main page

8. Create a new project or use the existing project and configure it as:

  • Check the "Tie this project to node" check box
  • Select one of the slaves in the combo box in the "Tie this project to node" section
  • Check the "Execute via JNLP"
  • Save the configuration by pressing "Save"
9. Press "Save" to store all slave configurations

Configuring the slave machine:

You need to configure your slave machines environment so that it could be used for running the selenium tests using the maven builds

  1. Start a web browser and go to the Hudson main page (located on the master machine)
  2. Click on the slave's name in the Build executor list, and a page describing the slave is shown
  3. Launch the slave agent by clicking on the "Launch slave agent" link or just save the JNLP on you machine and launch it from the commandline
  4. Wait until the web start application has started and shown a window stating that the slave is connected to the master server ("Connected")
  5. Go to the Hudson main page on the master server
  6. Verify that the slave is no longer marked as offline
  7. Start the build that was tied to the slave (ie step 5 above). This will start a build on the slave, you can verify that it was executed on the slave by going to the "remote FS root" that was specified for the slave. It should now contain a folder called "workspace".
  8. Go to the build history and verify that it was executed on the slave.

Configuring Projects:

Another important piece missing in this whole master slave is configuring the projects. The selenium tests should be treated as seperate project in Hudson as it will have a separate POM file. As mentioned earlier hudson allows building of maven 2 projects and in maven projects are build by specifying the different profiles. Generally maven projects build using this command
mvn -P clean verify

This build profile plays and importan role when you want to run your selenium tests on different browsers. Please see the sample build profile for running the tests on IE.
 
 

Stay in touch

Enter your email address:

Delivered by FeedBurner

Your Opinion Matters

Defect found by testers is
 

Follow Me - Twitter

Follow me on Twitter @ TestingGeek

Services.

Do you need reliable and efficient testing services covering all aspects of software testing? Contact Atlantis Software for all your software testing needs.

Check Websites

If you are looking for easy and cost effective way of checking and monitoring your web application and websites - try iCheckWebsite