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

纵然是瞬间 提交于 2019-12-04 21:07:59

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12784087/how-to-analyze-low-level-osgi-problems-during-tycho-test-execution

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!