[infinispan-dev] PSA: How to debug an integration test

Dan Berindei dan.berindei at gmail.com
Wed Nov 21 11:06:50 EST 2018


I had to debug some JMX stuff today and I remembered that Gustavo wanted a
guide for debugging ITs, so here goes:

1. Build the server

mvn install -DskipTests -am -pl server/integration/testsuite

2. Unpack the server in the testsuite module

mvn test -pl server/integration/testsuite

3. Try to run the IT from the IDE, it should fail because it can't find the
server definition

4. Check the @RunningServer references at the top of the IT and search for
them in arquillian.xml. E.g. JmxManagementIT uses "jmx-management-1", which
is defined under

<group qualifier="suite-manual">

5. Add -Darquillian.launch=<group qualifier> to your debug configuration

6. Your test should run now. I got an error about env.JAVA_HOME not being
defined, I just added a JAVA_HOME environment variable in the debug
configuration and it worked.

The Arquillian server configuration may need other system properties.
IntelliJ automatically picks up the system properties set in the failsafe
execution [1] when it imports the project, but you may have to set them
manually in your debug configuration.

Now that the test runs, we can try to debug the server.

7. Define a remote debug configuration. Preferably is should be in listen
mode: IntelliJ 2018.3.Beta1+ can automatically restart listening after a
debug session is over, so you only have to start the remote debug
configuration once.

8. Search for the server in arquillian.xml again and add the connection
string from the remote debug configuration, e.g.

        <container qualifier="jmx-management-1" mode="manual">
            <configuration>
                ...
                <property name="javaVmArguments">
                   ....

-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005

9. Set a breakpoint in the server and start the test debug configuration.
Your remote debug session should stop at the breakpoint.

HTH
Dan

[1]:
https://github.com/infinispan/infinispan/blob/8fb4a6a9d168b0d4fb4d709f524585d8708242ac/server/integration/testsuite/pom.xml#L822
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/infinispan-dev/attachments/20181121/4d29341d/attachment-0001.html 


More information about the infinispan-dev mailing list