While working on my integration tests for the PCIC Data Portal, I decided to do a quick aside of piping my test output to somewhere “useful”. One can use a command line option to pipe to pastebin, which is kinda nice. However, there is also an option (–junitxml) to generate XML output for use in continuous integration servers. That sounds cool. I want a dashboard that shows me if all of my tests are working.

It didn’t take more than about 15 minutes to deploy Hudson on my desktop, and set up a job to run the intergration tests. Cool! Here’s a brief description of what I did.

Step 1: Download the Hudson the war file and deploy it to Tomcat. This was standard procedure for deploying webapps, except for the fact that you have to set the HUDSON_HOME environment variable via system environment.

basalt pdp integration tests # cat /etc/env.d/35tomcat
HUDSON_HOME=/var/lib/tomcat-7-thredds/webapps/hudson-3.0.1

Pretty simple, though slightly annoying.

Step 2: Create a job. Name it something, anything. Select the option “Monitor an external job”.

Step 3: Run the tests on the shell and send the output to Hudson.

basalt pdp # java -jar /var/lib/tomcat-7-thredds/webapps/hudson-3.0.1/WEB-INF/lib/hudson-core-3.0.1-b2.jar "pdp integration tests" /tmp/testenv/bin/python -m pytest -v --junitxml=-

Notice that you have to point it to the hudson-core jar file, you have to use the same name as the external job that you just created, and then the rest of the command line is the exection string for py.test.

Step 4: Profit!

That’s it. Now Hudson shows you the status of your job.

And you can even get an RSS feed of all the test results.



blog comments powered by Disqus

Published

20 August 2013

Category

work

Tags