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

2

8

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?

Kroon answered 8/10, 2012 at 14:45 Comment(0)
K
8

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".

Kroon answered 8/10, 2012 at 14:45 Comment(1)
I had to add one additional systemProperty: <osgi.console.enable.builtin>true</osgi.console.enable.builtin>. With that it worked. Thanks.Ardellaardelle
U
0

Alternatively you can run with -consolelog or set the eclipse.consoleLog property to true property. If you're running with Tycho, you can use <argLine>-Declipse.consoleLog=true</argLine>.

Unmeant answered 1/4, 2016 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.