Skip to main content

Hudson Selenium Grid Plugin

Posted by kohsuke on May 16, 2009 at 7:45 AM PDT

I've released href="http://wiki.hudson-ci.org/display/HUDSON/Selenium+Plugin">the
Hudson Selenium plugin, which instantly lets you deploy Selenium
Grid on top of your existing Hudson cluster. By using this plugin, you
can start using Selenium Grid without installing it on individual
machines in the cluster manually. This is the latest addition to the
family of plugins that let you reuse you Hudson cluster infrastructure
for additional purposes.

Once you install this plugin from the update center, Hudson master
will become the Selenium Grid hub, the center of the Selenium Grid
system. Similarly, each slave that you have in your cluster will now
run Selenium RCs. The whole process happens completely automatically,
without any additional configuration.

To connect to this grid from your Selenium tests, create a
DefaultSelenium instance by specifying the host name of your
Hudson master, like this:

new DefaultSelenium("hudson.mydomain", 4444, "*firefox", "http://site.that.iam.testing/");

By default, Selenium Grid randomly chooses a Selenium RC to carry out
the execution, but this behavior makes it difficult to reliably start
a platform dependent browser (like IE and Safari), that needs to be
run on specific computers. As such, it's convenient to be able to
specify the slave that runs the browser. To do this, Hudson Selenium
Grid plugin extends the stock Selenium Grid by extending the browser
identifier. Specifically, you can specify
"label1&label2&...:browser" to tell Selenium Grid to start the
specified browser on a slave that has all the given labels. For
example, if your Windows slaves have the "windows" label, the browser
identifier of "windows:*iexplore" would cause a Selenium RC on some
Windows slave to start the IE.

We are increasingly seeing tools like Hadoop and Selenium, which
requires a cluster of computers to operate. Given the rise of
multi-core systems, cloud computing, and other general shift for
increased parallelism, I expect this trend to continue. Now, the
problem of those tools is that it's harder to set them up and keep
them going. One of the things I want to do with Hudson is to enable
their deployments on the Hudson cluster. I think this is a convincing
value proposition, given that Hudson byitself is pretty easy to
install and maintain (even on a cluster), and that it already has an
update center built-in.

I intend to talk more about this in my JavaOne session, so please drop by!

Related Topics >>

Comments

Job execution as per label logic

Hi Kohsuke,

Thanks for the very useful Selenium Grid contribution.

I was trying to setup Hudson cluster of RCs following your steps, but I am facing issue of job getting executed on undesired RCs/slaves.

I have latest Hudson (version 1.379) and am using Selenium Grid plugin version 1.3

My setup looks like below:
master - label=windows (1 executor)
slave1 on same machine - labels=windows en7 FF (with 2 executors)
slave2 on same machine - labels=windows en7 IE (with 1 executor)
slave3 on remote machine - labels=windows xp FF (with 2 executors)
Now, when I pass browser string as FF:*firefox for a free style job, I observed that job was executed on 4 RCs (2 RCs on slave1, 1 RC on master and 1 RC on slave3). I was expecting that, this job would be executed only on slave2.

Same happened when I passed browser string as windows&en7&FF:*firefox

I tried this with multiconfiguration style job where I selected label group as FF() and when job was run, it got executed on 4 RCs again.

Is something wrong with my understanding about node labels or setup.

Please advise.

Thanks,
Prashant

Hi Kohsuke, I'm trying to

Getting Error while setting up more then 1 executors on slave machine
Hi Kohsuke,
I'm trying to setup selenium grid on hudson and i'm setting up hudson master on windows xp server and slaves also on windows xp server. I'm able to setup 1 executor.
I want to execute more then 1 executor on slave machine, i'm getting problem setting up more then 1 executors.
Can someone help with the steps on how to execute selenium tests on more then 1 executor on slave machine or how to launch more then 1 executor on slave machine
Appreciate your reply.

Thanks,
VJ

Hudson 1.309 + selenium grid

Hi,

I've successfully deployed selenium grid on a Hudson 1.329 - everything is fine.
However I intended to do the same work on a 1.309, and I can't get it to work : installation of the plugin show no errors :

INFO: Starting the installation of Selenium Plugin on behalf of mhicauber
17 nov. 2009 09:48:37 hudson.model.UpdateCenter$UpdateCenterConfiguration download
INFO: Downloading Selenium Plugin
17 nov. 2009 09:48:48 hudson.diagnosis.HudsonHomeDiskUsageChecker doRun
INFO: Not on JDK6. Cannot monitor HUDSON_HOME disk usage
17 nov. 2009 09:50:39 hudson.model.UpdateCenter$DownloadJob run
INFO: Installation successful: Selenium Plugin


But when I restart the hudson server I get the following error :

17 nov. 2009 09:52:09 hudson.PluginManager
GRAVE: Failed to load a plug-in selenium
hudson.util.IOException2: Failed to initialize
at hudson.ClassicPluginStrategy.load(ClassicPluginStrategy.java:224)
at hudson.PluginManager.(PluginManager.java:154)
at hudson.model.Hudson.(Hudson.java:549)
at hudson.WebAppMain$2.run(WebAppMain.java:191)
Caused by: hudson.util.IOException2: Failed to extract input stream
at hudson.FilePath.readFromTar(FilePath.java:1386)
at hudson.FilePath.access$200(FilePath.java:154)
at hudson.FilePath$7.invoke(FilePath.java:475)
at hudson.FilePath$7.invoke(FilePath.java:473)
at hudson.FilePath.act(FilePath.java:635)
at hudson.FilePath.untarFrom(FilePath.java:473)
at hudson.FilePath.installIfNecessaryFrom(FilePath.java:541)
at hudson.plugins.selenium.PluginImpl.install(PluginImpl.java:207)
at hudson.plugins.selenium.PluginImpl.createSeleniumGridVM(PluginImpl.java:185)
at hudson.plugins.selenium.PluginImpl.start(PluginImpl.java:78)
at hudson.ClassicPluginStrategy.startPlugin(ClassicPluginStrategy.java:232)
at hudson.ClassicPluginStrategy.load(ClassicPluginStrategy.java:221)
... 3 more
Caused by: java.io.FileNotFoundException: /root/.hudson/selenium-grid/./Capfile (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:179)
at java.io.FileOutputStream.(FileOutputStream.java:131)
at hudson.FilePath.readFromTar(FilePath.java:1369)
... 14 more


Indeed, Hudson is right : the selenium-grid directory doesn't exist in ~/.hudson


Any idea ?

Thank you,

Mathieu.

Please use the issue tracker

Please use the issue tracker (https:/hudson.dev.java.net/issues/) for support questions.

Browser won't show up on the slave

Hi,
I managed to set up the plugin (well, indeed you did a great work there's not much to do !!).
Now when I try to run a test, the browser doesn't show up on the slave machine. Also, the captures taken into the test will be all black, and the slenium 'type' command will return an 'element not found' exception.
Is there some kind of 'background' mode or something that would make the browser invisible and could be the reason of those errors ?

See below my hudson trace, everything seems to be OK on the hub side :

16:01:57.461 INFO - Command request: getNewBrowserSession[*chrome, http://www.google.fr, ] on session null
16:01:57.461 INFO - creating new remote session
16:01:57.461 INFO - Allocated session 8f6c341d82a04002921017c9204394a7 for http://www.google.fr, launching...
16:01:57.493 INFO - Preparing Firefox profile...
16:01:59.586 INFO - Launching Firefox...
16:02:01.461 INFO - Got result: OK,8f6c341d82a04002921017c9204394a7 on session 8f6c341d82a04002921017c9204394a7
16:02:01.477 INFO - Command request: type[q, bla bla bla] on session 8f6c341d82a04002921017c9204394a7
16:02:01.493 INFO - Got result: ERROR: Element q not found on session 8f6c341d82a04002921017c9204394a7
16:02:01.508 INFO - Command request: testComplete[, ] on session 8f6c341d82a04002921017c9204394a7
16:02:01.508 INFO - Killing Firefox...
16:02:01.633 INFO - Got result: OK on session 8f6c341d82a04002921017c9204394a7

Some notes for others looking to get rolling w/this AWESOME plugin. I'm a php guy, and will do some more substantive documentation at some point, but here are some choice tidbits: The equivalent to DefaultSelenium for PHPUnit would be like this: function setUp() { $this->setHost("hudson.economist.com"); $this->setPort(4444); $this->setBrowser("selenium:*firefox /usr/lib/firefox-3.0.11/firefox"); $this->setBrowserUrl("http://www.yoursite.com/"); } Note I am using the slave label "selenium" to designate a RC-ready node. Other things I had to do to get this working: 1) Add a bit to /etc/profile.d to set the $DISPLAY evn var to :0 2) Add an explicit path to firefox as you see in setBrowser 3) Logged in with the slave user and initialized a first vncserver on :0 to create the .Xauthority file Next steps are getting better XML back and more scripting infrastructure around the job being run. This is good stuff!

Wow -- thanks for the fast response. Browsing through your posts I'm really impressed with what you've done with Hudson. It was my intention to have the master-only build server also run the Selenium tests we have. I saw this selenium plugin for hudson and thought it might be a lot easier to use it rather than go through all the goo of getting selenium installed as a service directly -- I've looked through those tutorials and decided to look for an alternative. If you have any other thoughts I'd be grateful, otherwise I'll look into either setting up a selenium service or else setting up slave and trying a regular grid. Thanks again for these great ideas and plugins! Jason

Right, as it stands now, this plugin only starts RCs on slaves and never on the master. I thought the use case of Selenium Grid pretty much requires a multi-node set up. Are you just evaluating it (and felt it's more convenient if you can test-drive it just with the master), or are you really going to run this with the master-only set up?

Hi there Kohsuke -- this is exactly what I'm looking for. Will this work if I just have one master Hudson node with no slaves? I installed the plugin and it appears to be running just fine. Selenium server appears to be running on that box as well. But clicking in Hudson on Selenium Grid shows, "No RCs have checked in yet. Have you started some slaves?", and I get a Server Error (500) when trying to connect to selenium on the hudson master machine. Maybe it wasn't designed to work on a master-only situation, or do I just have something configured wrong? Thanks for any comments that come to mind, Jason

Turns out this requires a fix in the core. Hudson 1.312 should make the Seleinum plugin (and Hadoop plugin, too) use the master, too.

I'll improve the plugin so that it checks the size of the cluster and if it's small, I'll have the master run a Selenium RC, too.

How does the display get defined for the RCs? I suspect this is why it won't run for me.

Hi there, First of all congratulation for your great work. I'm trying to setup selenium grid plugin for hudson. When I try to startup my selenium slave, i get this message in the hudson console : Connecting to XXX.XXX.XX.XX Copying slave.jar Starting the service Waiting for the service to become ready The service didn't respond. Perphaps it failed to launch? Then if I have a glance at the event viewer console on my windows slave show me that stack : Service cannot be started. System.ComponentModel.Win32Exception: Le fichier spécifié est introuvable at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at winsw.WrapperService.StartProcess(Process process, String arguments) at winsw.WrapperService.OnStart(String[] args) have you ever had a similar issue ? Thank you, Mathieu