Maven Plugin with SSH Library

701 views
Skip to first unread message

Tatu aalto

unread,
Jun 26, 2012, 7:00:42 AM6/26/12
to robotframe...@googlegroups.com
Ugh

I am using maven plugin (version 1.1.2) to run robot framework (2.7.3) tests and now I would like to use the SSHLibrary to login remote machines. I did try the SSHLibrary first with pybot and did work like a charm. But when moving to maven plugin I did run in to some problems.

To try out new stuff, I did set up a dummy project. To set up, I did use the Maven Integration instructions [1] (which seems to work like a charm). Then I did place SSHLibrary-folder, form SSHLibrary-1.0.tar.gz file [2], to the libraries-folder and also placed trilead-ssh2-build213.jar [3] to the libraries- and SSHLibrary-folders. In practice I have folders like this:

C:\Data\test\smoke-test\src\test\resources\robotframework>ls *
libraries:
SSHLibrary  trilead-ssh2-build213.jar

tests:
Smoke_suite.txt

C:\Data\test\smoke-test\src\test\resources\robotframework>ls libraries\SSHLibrary
__init__$py.class  connectioncache$py.class  pythonclient.py
__init__.py        connectioncache.py        trilead-ssh2-build213.jar
client$py.class    javaclient$py.class
client.py          javaclient.py

The test suite is an easy, it uses only the open connection keyword:
*** Settings ***
Library  SSHLibrary

*** Test Cases ***
use ssh
    Open Connection    192.168.1.1    \    2025

When I run the mvn clean verify, I get the following error:
==============================================================================
Tests
==============================================================================
[ ERROR ] Error in file 'C:\Data\test\smoke-test\src\test\resources\robotframework\tests\Smoke_suite.txt' in table 'Settings': Importing test library
'SSHLibrary' failed: ImportError: Importing Trilead SSH classes failed. Make sure you have the Trilead jar file in CLASSPATH.
Traceback (most recent call last):
  File "C:\Data\test\smoke-test\src\test\resources\robotframework\libraries\SSHLibrary\__init__.py", line 26, in <module>
    from javaclient import SSHClient
  File "C:\Data\test\smoke-test\src\test\resources\robotframework\libraries\SSHLibrary\javaclient.py", line 22, in <module>
    raise ImportError('Importing Trilead SSH classes failed. '
PYTHONPATH:
  C:\Data\test\smoke-test\src\test\resources\robotframework\libraries
  C:\Data\test\smoke-test\target\classes
  C:\Users\aaltat\.m2\repository\org\robotframework\robotframework\2.7.3\robotframework-2.7.3.jar\Lib\robot\libraries
  C:\Users\aaltat\.m2\repository\org\robotframework\robotframework\2.7.3\robotframework-2.7.3.jar\Lib
  C:\Users\aaltat\.m2\repository\org\robotframework\robotframework\2.7.3\Lib
  __classpath__
  __pyclasspath__/
  .
  C:\Data\test\smoke-test
CLASSPATH:
  C:\Program Files (x86)\apache-maven-3.0.4\bin\..\boot\plexus-classworlds-2.4.jar
Tests.Smoke suite
==============================================================================
use ssh                                                               | FAIL |
No keyword with name 'Open Connection' found.
------------------------------------------------------------------------------
....

Basically what I did gather from error message that it does not found the trilead-ssh2-build213.jar. Based on the SSHLibrary instructions, the jar file should be placed to a folder that is defined under the CLASSPATH. But with maven plugin, I can only use PYTHONPATH. So I suck in the this and could someone point me to right direction how to use SSHLibrary with Maven plugin?

-Tatu

[1] http://code.google.com/p/robotframework/wiki/MavenIntegration
[2] robotframework-sshlibrary.googlecode.com/files/SSHLibrary-1.0.tar.gz
[3] robotframework-sshlibrary.googlecode.com/files/trilead-ssh2-build213.jar

Tatu Aalto

unread,
Jun 26, 2012, 7:27:46 AM6/26/12
to Janne Härkönen, robotframe...@googlegroups.com
Ugh

The pom.xml contains that, it is pointing to to here:

<extraPathDirectories>
<extrapathDirectory>src/test/resources/robotframework/libraries</extrapathDirectory>

Should I define an absolute path and not a relative?

-Tatu


On 26.6.2012 14:23, Janne H�rk�nen wrote:
> On 06/26/2012 02:00 PM, Tatu aalto wrote:
>> Basically what I did gather from error message that it does not found
>> the trilead-ssh2-build213.jar. Based on the SSHLibrary instructions, the
>> jar file should be placed to a folder that is defined under the
>> CLASSPATH. But with maven plugin, I can only use PYTHONPATH. So I suck
>> in the this and could someone point me to right direction how to use
>> SSHLibrary with Maven plugin?
>
> You should be able to use the `extraPathDirectories` in maven plugin
> configuration to get the trilead.jar into the jybot class path.
>
> --J
>


Janne Härkönen

unread,
Jun 26, 2012, 7:39:10 AM6/26/12
to Tatu Aalto, robotframe...@googlegroups.com
On 06/26/2012 02:27 PM, Tatu Aalto wrote:
> Ugh
>
> The pom.xml contains that, it is pointing to to here:
>
> <extraPathDirectories>
> <extrapathDirectory>src/test/resources/robotframework/libraries</extrapathDirectory>
>
>
> Should I define an absolute path and not a relative?

Relative should work, but it should point to the actual jar file, not to
the directory.

--J


--
Janne H�rk�nen | http://ww.reaktor.fi
https://twitter.com/#!/janneharkonen


Tatu Aalto

unread,
Jun 26, 2012, 8:25:55 AM6/26/12
to Janne Härkönen, robotframe...@googlegroups.com
Ugh

That I did not know, nor I did not find it anywhere in the
documentation. At least for me (non java programmer) this could be nice
hint in somewhere. Anyway I did add the this to the pom.xml
<extraPathDirectories>
<extrapathDirectory>src/test/resources/robotframework/libraries</extrapathDirectory>
<extrapathDirectory>src/test/resources/robotframework/libraries/trilead-ssh2-build213.jar</extrapathDirectory>

The original problem has disappeared, but I am not still able to use the
SSHLibrary with maven plugin. When I use the this test suite:
*** Settings ***
Library SSHLibrary

*** Test Cases ***
use ssh
Open Connection ${HOST} foobar 2025 20
login ${USER NAME} ${PASSD}

With the maven command: "mvn clean verify" The execution of the test
suite freezes, even when I wait for long time. In practice I see this:
==============================================================================
Tests
==============================================================================
Tests.Smoke suite
==============================================================================
use ssh

When I run the same suite with pybot all works fine.

When I press Ctrl+c to stop the command, I see that the output.xml
contains this:
<?xml version="1.0" encoding="UTF-8"?>
<robot generator="Robot 2.7.3 (Jython 2.5.2 on java1.7.0_03)"
generated="20120626 15:18:40.652">
<suite
source="c:\Data\test\SSHLibrary-test\src\test\resources\robotframework\tests"
id="s1" name="Tests">
<metadata>
</metadata>
<suite
source="c:\Data\test\SSHLibrary-test\src\test\resources\robotframework\tests\Smoke_suite.txt"
id="s1-s1" name="Smoke suite">
<metadata>
</metadata>
<test id="s1-s1-t1" timeout="" name="use ssh">
<kw type="kw" timeout="" name="SSHLibrary.Open Connection">
<doc>Opens a new SSH connection to given `host` and `port`.</doc>
<arguments>
<arg>XXXXXXXX</arg>
<arg>foobar</arg>
<arg>2025</arg>
<arg>20</arg>
</arguments>

Any idea what could be the reason for this?

NOTE: I idid hide the correct IP address for security reasons

-Tatu

Pekka Klärck

unread,
Jun 26, 2012, 9:29:55 AM6/26/12
to aalto...@gmail.com, Janne Härkönen, robotframe...@googlegroups.com
2012/6/26 Tatu Aalto <aalto...@gmail.com>:
>
> With the maven command: "mvn clean verify" The execution of the test suite
> freezes, even when I wait for long time.
[snip]
> When I run the same suite with pybot all works fine.

Could you try running tests with Jython without Maven? If that works,
then the issue is somehow Maven related, otherwise it is just Jython
issue.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Tatu Aalto

unread,
Jun 26, 2012, 3:10:00 PM6/26/12
to Pekka Klärck, Janne Härkönen, robotframe...@googlegroups.com
Ugh

I did try this out with my PC and nto from work. But from my PC, result
shows that the this command: c:\temp\SSHLibrary>jybot --pythonpath
C:\temp\SSHLibrary\lib --pythonpath
c:\temp\SSHLibrary\lib\trilead-ssh2-build213.jar ssh_test.txt works like
a charm, with the test case presented in the previous mail.

With some time around (and something else too :-), I did install Maven
and did build same kind of temp project. Just to try out the issue with
Robot Framework Maven plugin. And to my surprise, with my setup in my
PC also the Maven plugin works like a charm with SSH library.

Of course, there are lot of differences in my setup (I did install the
SSH Server to my PC and I do ssh connection to localhost, windows is not
identical and so on) in home and work. So I have to look this again at
work, see what is the problem. All good leads and hints how to produce
more output are mostly welcomed.

-Tatu

Tatu Aalto

unread,
Jun 27, 2012, 4:53:27 AM6/27/12
to Pekka Klärck, Janne Härkönen, robotframe...@googlegroups.com
Ugh

Now I know, what is the difference between work and home. But I do not
know what is the reason of the behavior. The attachment contains two
pom.xml files. The pom_with_dependency.xml causes the SSHLibrary to hang
and pom_without_dependency.xml works just fine.

If I force the Robot Framework Maven Plugin to use newest version of
Robot by adding dependency to the plugin. Like in this way:
<plugins>
<plugin>
<dependencies>
<dependency>
<groupId>org.robotframework</groupId>
<artifactId>robotframework</artifactId>
<version>2.7.3</version>
</dependency>
</dependencies>
<groupId>com.googlecode.robotframework-maven-plugin</groupId>

Then the use of the SSHLibrary with Maven plugin freezes.

If I remove the dependency, then all works well. Also the SSHLibrary
works fine when used with jybot (with version 2.7.3).

This is somewhat strange and I do not have any idea why this is
happening. I use the Robot Framework Maven Plugin with the dependency
pointing to version 2.7.3 in many other projects. That lead me to
think, that it is valid way to use the newest version of Robot. Someone
more capable can look on the issue, if interested. But for me it is ok
like this, if needed I can describe this in a bug report.

-Tatu
pom_with_dependency.xml
pom_without_dependency.xml
Reply all
Reply to author
Forward
0 new messages