Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to analyze low-level OSGi problems during tycho test execution?

Tags:

tycho

When executing JUnit test with tycho-surefire-plugin, tycho forks an equinox runtime. In rare cases it may happen that some bundles in the OSGi test runtime cannot be resolved/started (e.g. package uses conflicts). If you read the debug log (maven CLI option -X), you will find something like

!ENTRY org.eclipse.osgi 2 0 2012-10-08 16:41:31.635
!MESSAGE The following is a complete list of bundles which are not resolved, see the prior log entry for the root cause if it exists:
!SUBENTRY 1 org.eclipse.osgi 2 0 2012-10-08 16:41:31.635
An error has occurred. See the log file
C:\mytestproject.tests\target\work\configuration\1349705136008.log.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:03.181s
[INFO] Finished at: Mon Oct 08 16:17:16 CEST 2012
[INFO] Final Memory: 20M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-surefire-plugin:0.15.0:test (default-test) on project mytestproject.tests: An unexpected error occured (return c
ode 13). See log for details. -> [Help 1]

The eclipse console log does not provide enough information in case of package uses conflicts.

How can I analyze the bundles in the OSGi test runtime forked by tycho?

like image 248
jsievers Avatar asked Oct 08 '12 14:10

jsievers


1 Answers

start tests in remote debug mode (simply specify -DdebugPort=8000 on the CLI) and start the OSGi console on a local port, e.g. 1234:

        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tycho-version}</version>
            <configuration>
                <systemProperties>
                  <osgi.console>1234</osgi.console>
                </systemProperties>
            </configuration>
        </plugin>

Set a breakpoint in one of your test classes or in org/eclipse/tycho/surefire/osgibooter/OsgiSurefireBooter if tests are not even started. Then,

 telnet localhost 1234

and you can use the usual OSGi console commands like ss, diag, bundle etc. to analyze the problem "in vivo".

like image 136
jsievers Avatar answered Dec 06 '22 22:12

jsievers