yanne / api-test

0 stars 0 forks source link

New keyword `Get Connection` for getting the current connection information #72

Closed yanne closed 10 years ago

yanne commented 10 years ago

The following workflow should be possible:

${id} =    Get Current Connection Id
Open Connection    ...
Do Something With The Connection
Close The Connection
Switch Connection    ${id}

From email discussions on users-list

This should work so that if there are no connections, Get Current Connection Id returns None. Switch Connection should, naturally, handle None as id too. Basically it should deactivate the current connection if there is one.

See email on Thursday, June 20, 2013 2:30 AM for further specifications

This issue was originally opened at Google Code on Jun 25, 2013.

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Jul 1, 2013.

This should be done in commit https://code.google.com/p/robotframework-sshlibrary/source/detail?r=12603262296b047abc88a3f5b49571a07f552f5f .

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Sep 9, 2013.

We rather decided to implement a new keyword Get Connection, which retuns an object describing the connection, similarly as Get Connections returns a list of these objects.

Besides the new keyword, the connection objects now have index attribute in addition to the old ones. This was done by commit https://code.google.com/p/robotframework-sshlibrary/source/detail?r=574a4bb2f0cdb96fb58b624536033228f34e8790 .

So using this keyword the following behaviour is possible:

Open Connection far.host.com alias=far Open Connection near.host.com

Do something with near.host.com...

${farhost}= Get Connection far # OR: Get Connection 1 Switch Connection ${farhost.index}

Do something with far.host.com

See library documentation ( https://robotframework-sshlibrary.googlecode.com/git-history/master/doc/SSHLibrary.html#Get%20Connection ) for more examples.

yanne commented 10 years ago

Original comment by pekka.klarck on Oct 17, 2013.

We have agreed to do following enhancements to this keyword:

1) Return a result object also when there is no connection open. This object MUST have index None. Other values can either be None or defaults, depending which is easier to implement.

With this change it is possible to use the result object to reset the previous connection with Switch Connection even when there are no connections. This was discussed in the initial description.

2) Allow returning only some information about the connection using arguments. This ought to work something like this:

${index} =    Get Connection    index=yes
${alias}    ${port} =    Get Connection    alias=true    port=yep

The main motivation is to support the remote library interface. The custom connection object cannot, at least currently, be transferred over the remote connection, but individual values can.

3) Available attributes in the returned object need to be documented better. Most likely a table with attribute names and explanations is the best approach.

The main reason is that custom object do not

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Oct 21, 2013.

This issue was updated by revision d6de03b15eec .

Added a table explaining the object attributes to the documentation of Get Connection.

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Oct 21, 2013.

This issue was updated by revision dddc18b4bd5c .

Get Connection now returns an object having its index and hostname as None if there is no connection.

ihe other attribute values of the object are the configuration defaults.

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Oct 21, 2013.

This issue was updated by revision 5aa8e56634b8 .

Documented Get Connection behaviour when there is no connection.

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Oct 21, 2013.

This issue was updated by revision b61877300836 .

The Get Connection keyword now allows returning plain connection attribute values instead of the whole object. This is done by adjusting the keyword arguments, as agreed.

Also Get Connection and Get Connections acceptance tests were moved to a separate suite from the connection tests for clarity.

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Oct 22, 2013.

This issue was updated by revision 0210f2a1291d .

Changed 'similar' to 'identical' in Get Connections keyword documentation.

yanne commented 10 years ago

Original comment by pekka.klarck on Oct 22, 2013.

Looks very good.

Now that this keyword takes a big list of arguments, I would consider removing the log_level argument altogether, though. The message can never be so big that logging it would be a problem. The message could, in my opinion, be always logged using INFO level and be logged also if only certain attributes are returned. What do you think Anssi?

I also enhanced the documentation related to returning only certain attributes a little. That will be pushed shortly.

yanne commented 10 years ago

Original comment by robotframework@gmail.com on Oct 22, 2013.

This issue was updated by revision 6a393dbab01c .

Enhanced docs of returning only certain attributes a little.

yanne commented 10 years ago

Original comment by anssi.sy...@eficode.com on Oct 22, 2013.

Support for configuring loglevel was dropped in revision e3c4cfb4d0c6 (as part of issue 79 ). Otherwise everything seems done so closing this.