You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Dominik Süß <do...@gmail.com> on 2015/10/06 10:59:42 UTC

Debugging Implementation when running ITs

Hi everybody,

I currently want to hook in a debugger to the implementation of the
installer when running the corresponding ITs as I want to inspect the
implementation behavior and see if I could add a patch that helps in
upgrade scenarios.

Yet I had no success getting the IT start in a way that I could hook in a
remote debugger.
If I get the documentation right it should be

mvn test
-Djar.executor.vm.options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"

(picked up from
https://sling.apache.org/documentation/development/sling-testing-tools.html)

Yet the tests just run through (and just fyi failed for
BundleInstallStressTest.testSemiRandomInstall) without waiting for a remote
connection.

Cheers

Dominik

Re: Debugging Implementation when running ITs

Posted by Dominik Süß <do...@gmail.com>.
Thanks Konrad & Bertrand,

Bertrands commands for the Pax Exam tests worked for me as well :)

Cheers
Dominik

On Tue, Oct 6, 2015 at 12:26 PM, Bertrand Delacretaz <bdelacretaz@apache.org
> wrote:

> Hi,
>
> On Tue, Oct 6, 2015 at 10:59 AM, Dominik Süß <do...@gmail.com>
> wrote:
> > ...I currently want to hook in a debugger to the implementation of the
> > installer when running the corresponding ITs...
>
> The sling/installer/it module uses Pax Exam and runs the tests with
> surefire.
>
> A simple way to debug the server-side code is to disable surefire
> forking so that the MAVEN_OPTS are used to configure the jvm
> debuggging:
>
>   $ export MAVEN_OPTS="-Xmx1G  -XX:MaxPermSize=256m
> -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=y"
>
>   $ mvn -o clean test -Dtest=BundlePrioritiesTest -DforkCount=0
>
> You can then connect to the VM on port 30303 to debug the
> OsgiInstallerImpl, for example. And of course replace the
> BundlePrioritiesTest name with whatever makes sense.
>
> -Bertrand
>

Re: Debugging Implementation when running ITs

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Tue, Oct 6, 2015 at 10:59 AM, Dominik Süß <do...@gmail.com> wrote:
> ...I currently want to hook in a debugger to the implementation of the
> installer when running the corresponding ITs...

The sling/installer/it module uses Pax Exam and runs the tests with surefire.

A simple way to debug the server-side code is to disable surefire
forking so that the MAVEN_OPTS are used to configure the jvm
debuggging:

  $ export MAVEN_OPTS="-Xmx1G  -XX:MaxPermSize=256m
-agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=y"

  $ mvn -o clean test -Dtest=BundlePrioritiesTest -DforkCount=0

You can then connect to the VM on port 30303 to debug the
OsgiInstallerImpl, for example. And of course replace the
BundlePrioritiesTest name with whatever makes sense.

-Bertrand

Re: Debugging Implementation when running ITs

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Oct 6, 2015 at 11:22 AM, Konrad Windszus <ko...@gmx.de> wrote:
> ...this does only work, if you provision a new server instance, but not if your
> a connecting to an already running server....

But in the latter case one just needs to start that server with JVM
debugging options and connect to it before running integration tests.

(which I think is what you meant - it just had the potential of being
wrongly understood ;-)

-Bertrand

Re: Debugging Implementation when running ITs

Posted by Konrad Windszus <ko...@gmx.de>.
Just set a breakpoint to org.apache.sling.testing.tools.jarexec.JarExecutor.start() and then start the debugging on the client side (also documented at https://sling.apache.org/documentation/development/sling-testing-tools.html).
You should see now which JVM options are used to start the instance.
The problem usually is, that Surefire itself forks Maven and therefore does not inherit the original system properties. Just set the configuration option forkCount from http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html to 0 to prevent forking. Otherwise you have to set the jar.executor.vm.options through the configuration option args.

Remember that this does only work, if you provision a new server instance, but not if your a connecting to an already running server.
Konrad
 
> On 06 Oct 2015, at 10:59, Dominik Süß <do...@gmail.com> wrote:
> 
> Hi everybody,
> 
> I currently want to hook in a debugger to the implementation of the
> installer when running the corresponding ITs as I want to inspect the
> implementation behavior and see if I could add a patch that helps in
> upgrade scenarios.
> 
> Yet I had no success getting the IT start in a way that I could hook in a
> remote debugger.
> If I get the documentation right it should be
> 
> mvn test
> -Djar.executor.vm.options="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
> 
> (picked up from
> https://sling.apache.org/documentation/development/sling-testing-tools.html)
> 
> Yet the tests just run through (and just fyi failed for
> BundleInstallStressTest.testSemiRandomInstall) without waiting for a remote
> connection.
> 
> Cheers
> 
> Dominik