How to debug integration-tests run via maven-nar:

111 views
Skip to first unread message

Pramoth Murali

unread,
Jun 29, 2017, 4:33:13 PM6/29/17
to NAR Maven plugin
For a simple project with a few shared objects dependencies, our solution had been to extract all the dependent nars and post it a location, then change LD_LIBRARY_PATH to point to .so's location, so integration_test could be run/debugged. 

But when the integration-test is dependent on good solid chunk of shared objects, we are looking at an alternative for leveraging maven to suspend on the integration-tests for a remote gdb attach

We have maven-invoker-plugin configured to run integration-tests, 

          <plugin>
           
<artifactId>maven-invoker-plugin</artifactId>
           
<version>${maven-invoker.plugin.version}</version>
           
<configuration>
             
<projectsDirectory>src/it</projectsDirectory>
             
<pomIncludes>
               
<pomInclude>pom.xml</pomInclude>
             
</pomIncludes>
             
<streamLogs>true</streamLogs>
             
<properties>
               
<debug>true</debug>
             
</properties>
             
</configuration>
           
<executions>
             
<execution>
               
<id>integration-test</id>
               
<goals>
                 
<goal>install</goal>
                 
<goal>run</goal>
                 
<goal>integration-test</goal>
               
</goals>
             
</execution>
           
</executions>
         
</plugin>


Using MAVEN_OPTS environment variable, 

mvn -Dinvoker.mavenOpts='-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'  invoker:integration-test

Integration-tests can suspend for an attach from remote debugger,

[INFO] --- maven-invoker-plugin:2.0.0:run (integration-test) @ queue ---
[WARNING] File encoding has not been set, using platform encoding ISO-8859-1, i.e. build is platform dependent!
[INFO] Building: pom.xml
[INFO] Listening for transport dt_socket at address: 8000


 but the maven executable is suspended on the maven process, and the gdb attach on the process id can only pick the Maven (java)  process call-stack,  whereas a gdb remote attach option gets a handshake failure from maven process. 

Our current proposal for a solution is to 

• Use copy-dependencies plugin to copy dependencies in pre-integration-test phase to a specific location. 
• Use maven-exec plugin to unzip nars to a location. 
• Launch gdbserver in mavenExecutable option considering maven invoker plugin can support it or use maven-exec plugin to launch integration-tests via gdbserver so gdb can attach to the session 

offered by gdbserver run via maven. 

We realize this solution is not straight-forward, wondering if there is a better solution out there  put to use by nar community or any general recommendations from the nar community. Or is there a simple way I could get maven-nar-invoker plugin suspend on the integration-test native process executable run? 

Thanks, I am a novice to the maven & maven-nar world, so much appreciated if you can help with any references to pom.xml that was configured for gdb support. 

Reply all
Reply to author
Forward
0 new messages