Tuesday, October 06, 2009

Continuous integration of Platform UI tests

With the work I was doing for e4 builds I've had the opportunity to set up a PDE build and test environment. So I thought I would setup the Platform UI automated tests to run in a continuous build cycle on a machine in the lab.

I think it's interesting because:
  1. The tests need to run against the latest I build for that week
  2. I need to patch 2 features to install my plugins from HEAD. I just followed Andrew's instructions.
  3. I wanted to use p2 to configure the tests, not the Automated Test Framework
As there's no real packaging or reuse involved, I just set up 3 features to drive the build. My 2 patch features, which include all of the Platform UI plugins that need to be replaced in org.eclipse.rcp and org.eclipse.platform. And my test feature, which includes the 2 patch feature, all of the Platform UI test plugins that contain my automated tests, and the automated test framework plugins:
  • org.eclipse.core.tests.harness
  • org.eclipse.test.performance
  • org.eclipse.test
  • org.eclipse.ant.optional.junit
Setting up PDE build involves copying the headless build templates (build.properties, customTargets.xml) and setting the parameters to match your build environment. Then creating a map project that's pointing to the correct features/plugins, and away you go.

For continuous builds you tend to want to build from HEAD. The best way (especially if you have a real map that's is regularly tagged for something else) is to set to properties:

forceContextQualifier=v${buildId}
fetchTag=HEAD

That way you don't end up with a lot of plugins that look like com.example.plugin_HEAD :-)

I also want to generate a p2 repo so I can consume my build easily. That's the standard set of p2 properties at the bottom of the build.properties file.

Once that's up (and a few tweaks to the customTargets.xml to use the latest I-build I will provide) and then you can build with the org.eclipse.ant.core.antRunner application.

Now I want to use p2 to run my automated tests. First I had to use XSLT to fix the content.xml and relax the feature patch version ranges (feature patches will target a very specific feature qualifier combination). There's a potential p2 fix in the works, but simple XSL will do for now.

I'm running the automated tests in my postBuild, with modified code I swiped from the Eclipse SDK automated test framework. The difference is that instead of having to generate a test.properties with the correct test plugin to test plugin version mapping and trying to unzip the build plugins into the eclipse test instance, the setup to run the tests now involve:
  1. unzip the eclipse test instance
  2. Call the director to install the plugin under test, the support plugins, and the patch features
  3. call the plugin's test.xml
It manages all of the version numbers and dependencies for free, so your list of IUs looks like:

-installIUs ${testPlugin}, org.eclipse.test, org.eclipse.ant.optional.junit, org.eclipse.ui.test.platform.patch.feature.group, org.eclipse.ui.test.rcp.patch.feature.group

And now I have my headless automated test environment :-) The relevant build files and map files can all be found in CVS.

  • :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse
  • platform-incubator/ui/org.eclipse.ui.automated.build/org.eclipse.ui.releng
There are a lot of opportunities for improvement in this environment (continually updating the build target from http://download.eclipse.org/eclipse/updates/3.6-I-builds for example) but this is enough to get me started.

PW