Debugging Itests

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging Itests

Paul Fraser
Hi,

The example itests code has line "KarafDistributionOption.debugConfiguration("8889", true) commented
out.

Presumably, the idea is to uncomment and debug of the itest becomes possible. (for intellij set port
to 5005 and remote debug config set in intellij)

When I try to debug the target connects -

"Connected to the target VM, address: '127.0.0.1:52458', transport: 'socket' " and then

"Listening for transport dt_socket at address:5005"

If I run debugging outside an itest with "bin\karaf debug" , it works.

What am I missing in the debug itests case?

Paul Fraser


Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

jbonofre
Hi Paul,

What Pax Exam version are you using ?

Regards
JB

On 01/06/2019 08:01, Paul Fraser wrote:

> Hi,
>
> The example itests code has line
> "KarafDistributionOption.debugConfiguration("8889", true) commented out.
>
> Presumably, the idea is to uncomment and debug of the itest becomes
> possible. (for intellij set port to 5005 and remote debug config set in
> intellij)
>
> When I try to debug the target connects -
>
> "Connected to the target VM, address: '127.0.0.1:52458', transport:
> 'socket' " and then
>
> "Listening for transport dt_socket at address:5005"
>
> If I run debugging outside an itest with "bin\karaf debug" , it works.
>
> What am I missing in the debug itests case?
>
> Paul Fraser
>
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

Paul Fraser
On 1/06/2019 4:03 pm, Jean-Baptiste Onofré wrote:
> Hi Paul,
>
> What Pax Exam version are you using ?

pax exam 4.13.1 and Karaf  4.2.5

Paul

>
> Regards
> JB
>
> On 01/06/2019 08:01, Paul Fraser wrote:
>> Hi,
>>
>> The example itests code has line
>> "KarafDistributionOption.debugConfiguration("8889", true) commented out.
>>
>> Presumably, the idea is to uncomment and debug of the itest becomes
>> possible. (for intellij set port to 5005 and remote debug config set in
>> intellij)
>>
>> When I try to debug the target connects -
>>
>> "Connected to the target VM, address: '127.0.0.1:52458', transport:
>> 'socket' " and then
>>
>> "Listening for transport dt_socket at address:5005"
>>
>> If I run debugging outside an itest with "bin\karaf debug" , it works.
>>
>> What am I missing in the debug itests case?
>>
>> Paul Fraser
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

jbonofre
Actually, if you run in debug mode directly in intellij, it works,
nothing special is required.

Are you running your itests in IntelliJ ?

Regards
JB

On 01/06/2019 08:09, Paul Fraser wrote:

> On 1/06/2019 4:03 pm, Jean-Baptiste Onofré wrote:
>> Hi Paul,
>>
>> What Pax Exam version are you using ?
>
> pax exam 4.13.1 and Karaf  4.2.5
>
> Paul
>
>>
>> Regards
>> JB
>>
>> On 01/06/2019 08:01, Paul Fraser wrote:
>>> Hi,
>>>
>>> The example itests code has line
>>> "KarafDistributionOption.debugConfiguration("8889", true) commented out.
>>>
>>> Presumably, the idea is to uncomment and debug of the itest becomes
>>> possible. (for intellij set port to 5005 and remote debug config set in
>>> intellij)
>>>
>>> When I try to debug the target connects -
>>>
>>> "Connected to the target VM, address: '127.0.0.1:52458', transport:
>>> 'socket' " and then
>>>
>>> "Listening for transport dt_socket at address:5005"
>>>
>>> If I run debugging outside an itest with "bin\karaf debug" , it works.
>>>
>>> What am I missing in the debug itests case?
>>>
>>> Paul Fraser
>>>
>>>
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

Paul Fraser
On 1/06/2019 7:10 pm, Jean-Baptiste Onofré wrote:
> Actually, if you run in debug mode directly in intellij, it works,
> nothing special is required.
Does this mean it is not necessary to uncomment "KarafDistributionOption.debugConfiguration("5005",
true)"?
> Are you running your itests in IntelliJ ?

Yes. Trying to..

It seems that somewhere the port for the connection to the java vm is not being set to 5005 but a
random high value.

Should the port for the vm be set to 5005 by Karaf when debugging?

Paul


>
> Regards
> JB
>
> On 01/06/2019 08:09, Paul Fraser wrote:
>> On 1/06/2019 4:03 pm, Jean-Baptiste Onofré wrote:
>>> Hi Paul,
>>>
>>> What Pax Exam version are you using ?
>> pax exam 4.13.1 and Karaf  4.2.5
>>
>> Paul
>>
>>> Regards
>>> JB
>>>
>>> On 01/06/2019 08:01, Paul Fraser wrote:
>>>> Hi,
>>>>
>>>> The example itests code has line
>>>> "KarafDistributionOption.debugConfiguration("8889", true) commented out.
>>>>
>>>> Presumably, the idea is to uncomment and debug of the itest becomes
>>>> possible. (for intellij set port to 5005 and remote debug config set in
>>>> intellij)
>>>>
>>>> When I try to debug the target connects -
>>>>
>>>> "Connected to the target VM, address: '127.0.0.1:52458', transport:
>>>> 'socket' " and then
>>>>
>>>> "Listening for transport dt_socket at address:5005"
>>>>
>>>> If I run debugging outside an itest with "bin\karaf debug" , it works.
>>>>
>>>> What am I missing in the debug itests case?
>>>>
>>>> Paul Fraser
>>>>
>>>>

Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

fpapon
Hi,

Don't you have another Karaf instance runing?

Pax-exam will try to find a newer free port

regards,

Francois

Envoyé depuis mon smartphone Samsung Galaxy.

-------- Message d'origine --------
De : Paul Fraser <[hidden email]>
Date : 01/06/2019 16:04 (GMT+04:00)
Objet : Re: Debugging Itests

On 1/06/2019 7:10 pm, Jean-Baptiste Onofré wrote:
> Actually, if you run in debug mode directly in intellij, it works,
> nothing special is required.
Does this mean it is not necessary to uncomment "KarafDistributionOption.debugConfiguration("5005",
true)"?
> Are you running your itests in IntelliJ ?

Yes. Trying to..

It seems that somewhere the port for the connection to the java vm is not being set to 5005 but a
random high value.

Should the port for the vm be set to 5005 by Karaf when debugging?

Paul


>
> Regards
> JB
>
> On 01/06/2019 08:09, Paul Fraser wrote:
>> On 1/06/2019 4:03 pm, Jean-Baptiste Onofré wrote:
>>> Hi Paul,
>>>
>>> What Pax Exam version are you using ?
>> pax exam 4.13.1 and Karaf  4.2.5
>>
>> Paul
>>
>>> Regards
>>> JB
>>>
>>> On 01/06/2019 08:01, Paul Fraser wrote:
>>>> Hi,
>>>>
>>>> The example itests code has line
>>>> "KarafDistributionOption.debugConfiguration("8889", true) commented out.
>>>>
>>>> Presumably, the idea is to uncomment and debug of the itest becomes
>>>> possible. (for intellij set port to 5005 and remote debug config set in
>>>> intellij)
>>>>
>>>> When I try to debug the target connects -
>>>>
>>>> "Connected to the target VM, address: '127.0.0.1:52458', transport:
>>>> 'socket' " and then
>>>>
>>>> "Listening for transport dt_socket at address:5005"
>>>>
>>>> If I run debugging outside an itest with "bin\karaf debug" , it works.
>>>>
>>>> What am I missing in the debug itests case?
>>>>
>>>> Paul Fraser
>>>>
>>>>

François Papon
fpapon@apache.org
Yupiik - https://www.yupiik.com
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

jbonofre
In reply to this post by Paul Fraser
You need debugConfiguration only if you want to specify the port.

By default it's 5005 (not random), so, yes, it should work straight forward.

Regards
JB

On 01/06/2019 14:04, Paul Fraser wrote:

> On 1/06/2019 7:10 pm, Jean-Baptiste Onofré wrote:
>> Actually, if you run in debug mode directly in intellij, it works,
>> nothing special is required.
> Does this mean it is not necessary to uncomment
> "KarafDistributionOption.debugConfiguration("5005", true)"?
>> Are you running your itests in IntelliJ ?
>
> Yes. Trying to..
>
> It seems that somewhere the port for the connection to the java vm is
> not being set to 5005 but a random high value.
>
> Should the port for the vm be set to 5005 by Karaf when debugging?
>
> Paul
>
>
>>
>> Regards
>> JB
>>
>> On 01/06/2019 08:09, Paul Fraser wrote:
>>> On 1/06/2019 4:03 pm, Jean-Baptiste Onofré wrote:
>>>> Hi Paul,
>>>>
>>>> What Pax Exam version are you using ?
>>> pax exam 4.13.1 and Karaf  4.2.5
>>>
>>> Paul
>>>
>>>> Regards
>>>> JB
>>>>
>>>> On 01/06/2019 08:01, Paul Fraser wrote:
>>>>> Hi,
>>>>>
>>>>> The example itests code has line
>>>>> "KarafDistributionOption.debugConfiguration("8889", true) commented
>>>>> out.
>>>>>
>>>>> Presumably, the idea is to uncomment and debug of the itest becomes
>>>>> possible. (for intellij set port to 5005 and remote debug config
>>>>> set in
>>>>> intellij)
>>>>>
>>>>> When I try to debug the target connects -
>>>>>
>>>>> "Connected to the target VM, address: '127.0.0.1:52458', transport:
>>>>> 'socket' " and then
>>>>>
>>>>> "Listening for transport dt_socket at address:5005"
>>>>>
>>>>> If I run debugging outside an itest with "bin\karaf debug" , it works.
>>>>>
>>>>> What am I missing in the debug itests case?
>>>>>
>>>>> Paul Fraser
>>>>>
>>>>>
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

Paul Fraser
Hmm,
Over thinking the problem..I was looking in the wrong place.

When setting up MavenArtifactUrlReference I had the artifact "type" being set AFTER "versionAsInProject"
Fixed this and the Karaf magic worked.

Thanks JB and Francois for your assistance.

Also, https://www.youtube.com/watch?v=qNmBZjJcups&feature=youtu.be Eclipsecon presentation by Łukasz
Dywicki has been very helpful.

In fact, the presentation by Lukasz, fortunately, caused me to take a new look at Karaf, which I
have been ignoring for years.

Support on this list during this learning phase has been outstanding, thanks..

Paul


On 2/06/2019 2:06 am, Jean-Baptiste Onofré wrote:

> You need debugConfiguration only if you want to specify the port.
>
> By default it's 5005 (not random), so, yes, it should work straight forward.
>
> Regards
> JB
>
> On 01/06/2019 14:04, Paul Fraser wrote:
>> On 1/06/2019 7:10 pm, Jean-Baptiste Onofré wrote:
>>> Actually, if you run in debug mode directly in intellij, it works,
>>> nothing special is required.
>> Does this mean it is not necessary to uncomment
>> "KarafDistributionOption.debugConfiguration("5005", true)"?
>>> Are you running your itests in IntelliJ ?
>> Yes. Trying to..
>>
>> It seems that somewhere the port for the connection to the java vm is
>> not being set to 5005 but a random high value.
>>
>> Should the port for the vm be set to 5005 by Karaf when debugging?
>>
>> Paul
>>
>>
>>> Regards
>>> JB
>>>
>>> On 01/06/2019 08:09, Paul Fraser wrote:
>>>> On 1/06/2019 4:03 pm, Jean-Baptiste Onofré wrote:
>>>>> Hi Paul,
>>>>>
>>>>> What Pax Exam version are you using ?
>>>> pax exam 4.13.1 and Karaf  4.2.5
>>>>
>>>> Paul
>>>>
>>>>> Regards
>>>>> JB
>>>>>
>>>>> On 01/06/2019 08:01, Paul Fraser wrote:
>>>>>> Hi,
>>>>>>
>>>>>> The example itests code has line
>>>>>> "KarafDistributionOption.debugConfiguration("8889", true) commented
>>>>>> out.
>>>>>>
>>>>>> Presumably, the idea is to uncomment and debug of the itest becomes
>>>>>> possible. (for intellij set port to 5005 and remote debug config
>>>>>> set in
>>>>>> intellij)
>>>>>>
>>>>>> When I try to debug the target connects -
>>>>>>
>>>>>> "Connected to the target VM, address: '127.0.0.1:52458', transport:
>>>>>> 'socket' " and then
>>>>>>
>>>>>> "Listening for transport dt_socket at address:5005"
>>>>>>
>>>>>> If I run debugging outside an itest with "bin\karaf debug" , it works.
>>>>>>
>>>>>> What am I missing in the debug itests case?
>>>>>>
>>>>>> Paul Fraser
>>>>>>
>>>>>>

Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

Paul Fraser
Hi,

On 2/06/2019 7:20 am, Paul Fraser wrote:
> Hmm,
> Over thinking the problem..I was looking in the wrong place.
>
> When setting up MavenArtifactUrlReference I had the artifact "type" being set AFTER
> "versionAsInProject"
> Fixed this and the Karaf magic worked.
My comments (above) are rubbish.
The order of the build of the MavenArtifactUrlReference does not matter.

Paul Fraser

Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

Paul Fraser
In reply to this post by Paul Fraser

Hi Again,

Is it possible in an itest to debug into the inner karaf runtime?

To try and debug into the "listBundleCommand" test in the Karaf Itest example I tried

  1. Set breakpoint on "String httpPort = ..." in the "public Option[] config()" method in the itest code.
  2. Set breakpoint at first line  in "listBundleCommand" test.
  3. Set a remote configuration in Intellij with port 5005.
  4. start karaf with bin/karaf debug.
  5. console displays "Listening for transport dt at address: 5005
  6. Karaf starts up with branding and prompt.
  7. Shift-F9 in intellij starts a debug session.
  8. Debug console displays "Connected to the target VM, address: 'localhost:5005", transport: 'socket'
  9. Run test (debug)
  10. Debugger stops at breakpoint '1' above.
  11. Does not stop at breakpoint '2' above.
  12. "listBundleCommand" test runs to completion and output as expected.

If it can be done, what am I missing?

Paul Fraser









Reply | Threaded
Open this post in threaded view
|

Re: Debugging Itests

Łukasz Dywicki
Hey Paul,
Within pax exam there are several processes which gets started. One
which you need to debug is Karaf one. All steps you mentioned seems to
be correct.

Debugging of option creation is not subject of debugConfiguration. This
code is executed by maven (surefire) or IDE you run. In order to debug
calculation of runtime configurations you need to debug process which
does that, namely junit executor.
General guide - @Configuration method is called before managed process
is launched thus can't be subject of standard Karaf debugging.
Keep in mind that surefire debugging might be tricky, but IntelliJ
should be rather smooth. Just remember to swap debugger ports.

In terms of exam debug configuration - pax allows you to specify port
but also "hold" flag to wait for debugger to be attached:
See:
org.ops4j.pax.exam.karaf.options.KarafDistributionOption#debugConfiguration(java.lang.String,
boolean)
If you will set second argument to true runtime won't be started until
you attach your debugger. Sometimes it is necessary to catch events
associated with bundles which are starting early.
From what I observed IntelliJ can also skip breakpoints which have
signature mismatches. Make sure you have all versions in sync.

Kind regards,
Łukasz
--
Code-House http://code-house.org

On 11.06.2019 12:07, Paul Fraser wrote:

> Hi Again,
>
> Is it possible in an itest to debug into the inner karaf runtime?
>
> To try and debug into the "listBundleCommand" test in the Karaf Itest
> example I tried
>
>  1. Set breakpoint on "String httpPort = ..." in the "public Option[]
>     config()" method in the itest code.
>  2. Set breakpoint at first line  in "listBundleCommand" test.
>  3. Set a remote configuration in Intellij with port 5005.
>  4. start karaf with bin/karaf debug.
>  5. console displays "Listening for transport dt at address: 5005
>  6. Karaf starts up with branding and prompt.
>  7. Shift-F9 in intellij starts a debug session.
>  8. Debug console displays "Connected to the target VM, address:
>     'localhost:5005", transport: 'socket'
>  9. Run test (debug)
> 10. Debugger stops at breakpoint '1' above.
> 11. Does not stop at breakpoint '2' above.
> 12. "listBundleCommand" test runs to completion and output as expected.
>
> If it can be done, what am I missing?
>
> Paul Fraser
>
>
>
>
>
>
>
>
>