Thursday, October 24, 2013

Enabling Tycho tests for P2 - lessons learned

Today's morning, after turning on Eclipse, I got this notification:

I find it to be a big step forward (at least to me), because from now on, all P2 patches pushed to gerrit will be automatically verified in a quite reasonable time - more or less 2 hours - yes, that's the time that is necessary to run the build and execute all P2 tests.

However, the road to the green build was a rather bumpy one - here is the list of issues that may impact more people doing the migration:

Issue #1 - Error code 23.

First reported as Bug 415489 - tycho-surefire occasionally fails with unexpected return code 23. Then after investigation - duplicate opened by me:
Bug 417430 - tycho-eclipserun may interfere with tycho-surefire OSGi runtime.

Tycho builds stops with an unexpected error code 23. The build is not failed, it just exits.

Tycho occasionally assembles and spins Equinox instances, if it is necessary to run OSGi-based tooling during the build. But in one place, Equinox was refusing to start, and was returning error code 23, demanding to be restarted. The sequence that lead to this was pretty simple:
  • Tycho assembled and run Equinox instance based on Kepler versions to generate API description
  • a bit later, tycho assembled and run another Equinox instance based on Luna-Nightly to run tests, but the configuration directory was not cleaned, so Equinox thought an update was happening, and demanded a restart.
  • Update to Tycho 0.19.0 - the issue has been fixed there
  • Change tycho surefire configuration area to avoid collision with api builder:

Issue #2 - Different naming schemas.

One of the tests was failing all the time, returning doubled number of artifacts in a generated P2 repository (expected:3, was:6). What happened was that P2 was copying bundles from a running application, and this Surefire application was using different naming scheme: Regular Eclipse apps use following convention: bundleId_version.qualifier.jar, but Tycho Surefire uses bundleId-version.qualifier.jar. Of course, P2 processed those files properly, and generated valid repo, just the test input was wrong.

Issue #3 - Circular dependencies.

P2 Tests, to run properly, require platform specific filesystem bundles. The only way to add those bundles to Surefire is to add parent feature - and since we are building P2, parent feature (org.eclipse.platform) would be resolved from an update site. Well, almost. The parent feature happened to include one bundle from the reactor (org.eclipse.update.configurator I think). So, almost everything was resolved from the update site, except this one bundle, which came from the reactor, and didn't satisfy feature requirements due to the changed version.

The workaround was to use api (luckily this is all about test case preparation).

Some discussion concerning this issue seems to be happening in Bug 419201 - "mvn clean verify -Pbuild-individual-bundles" fails for Platform Compare.

Side note:
There is an ongoing effort to enable running tests during the build for particular components, under the umbrella  Bug 416904 - Allow to run tests with tycho-surefire-plugin. "In order to lower entry barrier and execution of unit tests [...]".

Best regards,


  1. good to hear there is progress on gerrit voter including unit test execution.
    I was wondering if it's really necessary to do a full eclipse platform build (~2h) just for the sake of a gerrit voter or if a partial build of just p2 (without JDT, PDE, SWT,...) would not be sufficient and much faster?

  2. P2 build is just about 30 minutes. The rest is used by tests, mostly reconciler (multiple eclipse launches to test dropins and shared install are really expensive).

  3. Congratulation. A big step to enable more people to contribute.