You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Nicolas Brasey <ni...@gmail.com> on 2017/01/25 17:49:47 UTC

Execute commands programmatically from inside Karaf

Hi,

For our internal integration and regression tests tooling / devops, I'm
thinking of writting some code running inside karaf to be able to support
some kind of business profiles management (btw: nothing to do with Karaf
profiles here).

Our application is entirely configurable using karaf commands, I'm talking
about business configuration, not infrastructure or port configuration. At
the moment, we build simple text files that contains a list of commands to
be able to configure an empty system that we execute with the client
script. This is really convenient for us, as we can switch from a
configuration to another by simply executing the text file corresponding to
the specific customer and be able to test the application and its context.
But at the moment, it has some issues because we need to manually copy that
file to the target server, adapt some path, and run the client script. It
is good but not great, as it's not automation friendly.

I'm thinking of a better solution where we would store those profiles in a
profile repository (let say an http server for now...). Assuming that I can
download that text file, I need now to be able to execute it as the client
script would do, but without the ssh communication as I'm running inside
karaf already. That is where I'm stuck at the moment. I have been browsing
the source code of Karaf, but I don't find the place or service I need to
use to be able to execute this list of commands.

Could someone give me a hint or pointer where I should look at ?

Thanks a lot for your help!

Nicolas

Re: Execute commands programmatically from inside Karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Yup.

It's what we are using for the itests command execution.

Regards
JB\u2063\u200b

On Jan 25, 2017, 19:07, at 19:07, Vincent Zurczak <vi...@linagora.com> wrote:
>Hi,
>
>In your command implementation, you can inject a Session object that
>can 
>execute Karaf commands.
>See [0].
>
>Regards,
>
>                 Vincent.
>
>
>[ 0 ] : 
>https://github.com/roboconf/roboconf-platform/blob/master/karaf/roboconf-karaf-commands-dm/src/main/java/net/roboconf/karaf/commands/dm/targets/InstallTargetCommand.java
>
>
>Le 25/01/2017 � 18:49, Nicolas Brasey a �crit :
>> Hi,
>>
>> For our internal integration and regression tests tooling / devops, 
>> I'm thinking of writting some code running inside karaf to be able to
>
>> support some kind of business profiles management (btw: nothing to do
>
>> with Karaf profiles here).
>>
>> Our application is entirely configurable using karaf commands, I'm 
>> talking about business configuration, not infrastructure or port 
>> configuration. At the moment, we build simple text files that
>contains 
>> a list of commands to be able to configure an empty system that we 
>> execute with the client script. This is really convenient for us, as 
>> we can switch from a configuration to another by simply executing the
>
>> text file corresponding to the specific customer and be able to test 
>> the application and its context. But at the moment, it has some
>issues 
>> because we need to manually copy that file to the target server,
>adapt 
>> some path, and run the client script. It is good but not great, as 
>> it's not automation friendly.
>>
>> I'm thinking of a better solution where we would store those profiles
>
>> in a profile repository (let say an http server for now...). Assuming
>
>> that I can download that text file, I need now to be able to execute 
>> it as the client script would do, but without the ssh communication
>as 
>> I'm running inside karaf already. That is where I'm stuck at the 
>> moment. I have been browsing the source code of Karaf, but I don't 
>> find the place or service I need to use to be able to execute this 
>> list of commands.
>>
>> Could someone give me a hint or pointer where I should look at ?
>>
>> Thanks a lot for your help!
>>
>> Nicolas
>
>-- 
>Vincent Zurczak
>Linagora: www.linagora.com <http://www.linagora.com/>
>
>Twitter <https://twitter.com/VincentZurczak> Vincent Zurczak @ LinkedIn
>
><http://fr.linkedin.com/pub/vincent-zurczak/18/b35/6a7> My Skype ID 
><callto://vincent.zurczak> My English blog
><http://vzurczak.wordpress.com>

Re: Execute commands programmatically from inside Karaf

Posted by Vincent Zurczak <vi...@linagora.com>.
Hi,

In your command implementation, you can inject a Session object that can 
execute Karaf commands.
See [0].

Regards,

                 Vincent.


[ 0 ] : 
https://github.com/roboconf/roboconf-platform/blob/master/karaf/roboconf-karaf-commands-dm/src/main/java/net/roboconf/karaf/commands/dm/targets/InstallTargetCommand.java


Le 25/01/2017 � 18:49, Nicolas Brasey a �crit :
> Hi,
>
> For our internal integration and regression tests tooling / devops, 
> I'm thinking of writting some code running inside karaf to be able to 
> support some kind of business profiles management (btw: nothing to do 
> with Karaf profiles here).
>
> Our application is entirely configurable using karaf commands, I'm 
> talking about business configuration, not infrastructure or port 
> configuration. At the moment, we build simple text files that contains 
> a list of commands to be able to configure an empty system that we 
> execute with the client script. This is really convenient for us, as 
> we can switch from a configuration to another by simply executing the 
> text file corresponding to the specific customer and be able to test 
> the application and its context. But at the moment, it has some issues 
> because we need to manually copy that file to the target server, adapt 
> some path, and run the client script. It is good but not great, as 
> it's not automation friendly.
>
> I'm thinking of a better solution where we would store those profiles 
> in a profile repository (let say an http server for now...). Assuming 
> that I can download that text file, I need now to be able to execute 
> it as the client script would do, but without the ssh communication as 
> I'm running inside karaf already. That is where I'm stuck at the 
> moment. I have been browsing the source code of Karaf, but I don't 
> find the place or service I need to use to be able to execute this 
> list of commands.
>
> Could someone give me a hint or pointer where I should look at ?
>
> Thanks a lot for your help!
>
> Nicolas

-- 
Vincent Zurczak
Linagora: www.linagora.com <http://www.linagora.com/>

Twitter <https://twitter.com/VincentZurczak> Vincent Zurczak @ LinkedIn 
<http://fr.linkedin.com/pub/vincent-zurczak/18/b35/6a7> My Skype ID 
<callto://vincent.zurczak> My English blog <http://vzurczak.wordpress.com>

Re: Execute commands programmatically from inside Karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Nicolas,

I mean this:

https://github.com/apache/karaf/blob/master/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java

part of the karaf-test jar.

In the KarafTestSupport, you can see the executeCommand() method 
allowing you to execute shell commands in the running Karaf container 
(started by Pax Exam).

For instance, you can do (in your test code):

executeCommand("feature:install foo");

Regards
JB

On 01/26/2017 03:01 PM, Nicolas Brasey wrote:
> Hi guys,
>
> @Vincent: Thanks for the pointer, exactly what I was looking for!
>
> @Jean-Baptiste: We only did few tests with pax-exam and it is still not
> very clear to me what are all the hidden possibilities of this
> framework, beside the obvious in "container testing". Regarding the
> "karaf-test-support", could you please send me a pointer to what you are
> referring to exactly ? Thanks again!
>
> Best regards,
> Nicolas
>
>
>
>
>
>
> On Wed, Jan 25, 2017 at 7:22 PM, Jean-Baptiste Onofr� <jb@nanthrax.net
> <ma...@nanthrax.net>> wrote:
>
>     By the way why not just use pax-exam and the karaf-test-support ?
>
>     Regards
>     JB
>     On Jan 25, 2017, at 18:49, Nicolas Brasey <nicolas.brasey@gmail.com
>     <ma...@gmail.com>> wrote:
>
>         Hi,
>
>         For our internal integration and regression tests tooling /
>         devops, I'm thinking of writting some code running inside karaf
>         to be able to support some kind of business profiles management
>         (btw: nothing to do with Karaf profiles here).
>
>         Our application is entirely configurable using karaf commands,
>         I'm talking about business configuration, not infrastructure or
>         port configuration. At the moment, we build simple text files
>         that contains a list of commands to be able to configure an
>         empty system that we execute with the client script. This is
>         really convenient for us, as we can switch from a configuration
>         to another by simply executing the text file corresponding to
>         the specific customer and be able to test the application and
>         its context. But at the moment, it has some issues because we
>         need to manually copy that file to the target server, adapt some
>         path, and run the client script. It is good but not great, as
>         it's not automation friendly.
>
>         I'm thinking of a better solution where we would store those
>         profiles in a profile repository (let say an http server for
>         now...). Assuming that I can download that text file, I need now
>         to be able to execute it as the client script would do, but
>         without the ssh communication as I'm running inside karaf
>         already. That is where I'm stuck at the moment. I have been
>         browsing the source code of Karaf, but I don't find the place or
>         service I need to use to be able to execute this list of commands.
>
>         Could someone give me a hint or pointer where I should look at ?
>
>         Thanks a lot for your help!
>
>         Nicolas
>
>
>

-- 
Jean-Baptiste Onofr�
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Execute commands programmatically from inside Karaf

Posted by Nicolas Brasey <ni...@gmail.com>.
Hi guys,

@Vincent: Thanks for the pointer, exactly what I was looking for!

@Jean-Baptiste: We only did few tests with pax-exam and it is still not
very clear to me what are all the hidden possibilities of this framework,
beside the obvious in "container testing". Regarding the
"karaf-test-support", could you please send me a pointer to what you are
referring to exactly ? Thanks again!

Best regards,
Nicolas






On Wed, Jan 25, 2017 at 7:22 PM, Jean-Baptiste Onofré <jb...@nanthrax.net>
wrote:

> By the way why not just use pax-exam and the karaf-test-support ?
>
> Regards
> JB
> On Jan 25, 2017, at 18:49, Nicolas Brasey <ni...@gmail.com>
> wrote:
>>
>> Hi,
>>
>> For our internal integration and regression tests tooling / devops, I'm
>> thinking of writting some code running inside karaf to be able to support
>> some kind of business profiles management (btw: nothing to do with Karaf
>> profiles here).
>>
>> Our application is entirely configurable using karaf commands, I'm
>> talking about business configuration, not infrastructure or port
>> configuration. At the moment, we build simple text files that contains a
>> list of commands to be able to configure an empty system that we execute
>> with the client script. This is really convenient for us, as we can switch
>> from a configuration to another by simply executing the text file
>> corresponding to the specific customer and be able to test the application
>> and its context. But at the moment, it has some issues because we need to
>> manually copy that file to the target server, adapt some path, and run the
>> client script. It is good but not great, as it's not automation friendly.
>>
>> I'm thinking of a better solution where we would store those profiles in
>> a profile repository (let say an http server for now...). Assuming that I
>> can download that text file, I need now to be able to execute it as the
>> client script would do, but without the ssh communication as I'm running
>> inside karaf already. That is where I'm stuck at the moment. I have been
>> browsing the source code of Karaf, but I don't find the place or service I
>> need to use to be able to execute this list of commands.
>>
>> Could someone give me a hint or pointer where I should look at ?
>>
>> Thanks a lot for your help!
>>
>> Nicolas
>>
>>
>

Re: Execute commands programmatically from inside Karaf

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
By the way why not just use pax-exam and the karaf-test-support ?

Regards
JB\u2063\u200b

On Jan 25, 2017, 18:49, at 18:49, Nicolas Brasey <ni...@gmail.com> wrote:
>Hi,
>
>For our internal integration and regression tests tooling / devops, I'm
>thinking of writting some code running inside karaf to be able to
>support
>some kind of business profiles management (btw: nothing to do with
>Karaf
>profiles here).
>
>Our application is entirely configurable using karaf commands, I'm
>talking
>about business configuration, not infrastructure or port configuration.
>At
>the moment, we build simple text files that contains a list of commands
>to
>be able to configure an empty system that we execute with the client
>script. This is really convenient for us, as we can switch from a
>configuration to another by simply executing the text file
>corresponding to
>the specific customer and be able to test the application and its
>context.
>But at the moment, it has some issues because we need to manually copy
>that
>file to the target server, adapt some path, and run the client script.
>It
>is good but not great, as it's not automation friendly.
>
>I'm thinking of a better solution where we would store those profiles
>in a
>profile repository (let say an http server for now...). Assuming that I
>can
>download that text file, I need now to be able to execute it as the
>client
>script would do, but without the ssh communication as I'm running
>inside
>karaf already. That is where I'm stuck at the moment. I have been
>browsing
>the source code of Karaf, but I don't find the place or service I need
>to
>use to be able to execute this list of commands.
>
>Could someone give me a hint or pointer where I should look at ?
>
>Thanks a lot for your help!
>
>Nicolas