Goal
We have an Hudson server (to be the master) in a Linux (centOs) environment
We want to have Hudson slaves in a separated Windows virtual machines in order to run Selenium tests
We want to set up a Selenium Cluster
We want the master to launch the slaves automatically
How to set up an Hudson Cluster automatically
Ingredients
- an Hudson server up and running (mine was launch by running java -jar hudson-2.2.1.war --ajp13Port=8010 --httpPort=8011 on VM http://192.168.1.157)
- an Hudson slave configured such that "Launch slave agents via JNLP" (instructions here) (in this example the name of the slave is "MyWindowsMachine")
- slave.jar (you can find it in the folder /root/.hudson/war/WEB-INF: use this because it needs to be of the same version as the hudson-x.x.x.war)
- a separated Windows VM (the ip address in the example is 192.168.1.79)
- winexe (source here)
Recipe
1. place slave.jar in a folder in the slave Windows VM (in this example, C:\Users\andrea.ferraresi\Downloads\hudsonSlave)
2. create a batch file with the following 2 instructions and place it in the same folder as above (in this example, C:\Users\andrea.ferraresi\Downloads\hudsonSlave)
cd C:\Users\andrea.ferraresi\Downloads\hudsonSlave\
java -jar slave.jar -jnlpUrl http://192.168.1.157:8011//computer/MyWindowsMachine/slave-agent.jnlp
Notes: cd + folder where the batch file is placed. The jnlpUrl url is http://<remote ip address on the linux server><port where you can access hudson>//computer/<name of the hudson slave node set in the ingredients>/slave-agent.jnlp
3. place winexe in a folder of the linux VM (I place the uncompressed file winexe-static-081123 in
/home/andrea.ferraresi/winexe/winexe3/withoutSource) and make it executable (I've used chmod 777 *)
4. Create an Hudson job on the Hudson master: just choose "Add build step" -> execute shell -> and add the following instructions:
cd /home/andrea.ferraresi/winexe/winexe3/withoutSource
./winexe-static-081123 -U andrea.ferraresi%password -W POLESTAR //192.168.1.79
"C:\Users\andrea.ferraresi\Downloads\hudsonSlave\cdJjnlp.bat"
Notes: cd <folder where winexe was placed>. Then the command line according to the winexe syntax: ./<winexe program name> -U <username>%<password> -W <pc domain> //<ip address of the slave Windows VM> "<launch the batch file on the slave Windows VM>"
5. Build the Hudson job and the Hudson slave on Windows VM will be connected to the Hudson Master, so now we can configure Hudson job in the master to be run by the Hudson slave
Conclusions
Following this procedure we can encounter an issue:
no matter if we stop the winexe program execution, somehow (I didn't discover how) the hudson master is able to connect to the hudson slave in a matter of seconds (when we configured the slave we have chosen the option "Keep this slave online as much as possible". This doesn't seem a great issue, until the moment we decide to modify the master-slave connection: we need to devise ways to shut it down completely and definitely, what about deleting the slave node configured in the Hudson master?
This blog is sponsored by Italian Aurora e da Veni Vidi Vici Bici! da 0 a 139 anni. Puoi guardare il video della presentazione di Veni Vidi Vici Bici! da 0 a 139 anni