You can now execute RobotFramework Test Suites remotely

Chris Brookes
4 min readApr 28, 2020

I have just published to new package to PyPi: robotframework-remoterunner. This lightweight library allows you to execute RobotFramework Test Suites on a remote host. The library itself comes in the form of two command-line scripts:

  • rfagent - A lightweight agent that initialises an XML-RPC server that you launch on the host you wish to execute tests on.
  • rfremoterun - A script that you use to initiate a remote robot execution. It provides a similar interface to robot.run, but packages up Test Suites & resources before passing them to the rfagent server to execute the run.

This solution is implemented as a lightweight agent, designed to work alongside or instead of other CI Agents (e.g. Jenkins Agent). It is well suited to scenarios that involve downloading and installing applications that are then tested, and where there is a requirement to test across multiple platforms and Operating Systems.

Implementation

The executor script begins by parsing the input arguments and separating them into two categories: arguments for the executor, and arguments bound for robot on the remote host. RobotFramework itself is used to do the heavy lifting of parsing Test Suites via the TestSuiteBuilder class. Once the Test Suite tree has been parsed, the contents of each Suite file is read from disk and added to a dictionary. As the Test Suites are being processed their Library and Resource dependencies are collected and will also be transferred over to the remote host. Once all files have been packaged up, an RPC call is made to the remote agent that is listening on a specific port.

The rfagent script then writes all Test Suites and dependencies to a temporary workspace directory. The Test Suite hierarchy is re-created and all dependencies are placed at the root of the workspace which is then added to the PYTHONPATH. A Robot run is then executed against the workspace directory with the specified arguments. After the Robot execution has finished the test artifacts are read from disk and returned to the the calling host. These artifacts are then saved to disk on the calling host and the robot results are output to the console.

Installation

This library will need to be installed on both the remote host you wish to run the Test Suites on, as well as the host initiating the test execution.

pip install robotframework-remoterunner

Usage

Begin by running the rfagent script on the remote host you wish to execute Robot tests on. You can optionally specify an address and port to bind to:

C:\> rfagent -a 192.168.56.102 -p 1471 Listening on 192.168.56.102:1471

From the host machine run the rfremoterun script. This takes the same arguments as robot.run but requires the IP address of the agent machine as the first argument:

C:\DEV> rfremoterun 192.168.56.102 tests\robot\ --loglevel DEBUG
Connecting to: http://192.168.56.102:1471
Robot execution response:
====================================================================
Root
====================================================================
Root.TS1
====================================================================
TS1.1 | PASS |
— — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
Root.TS1 | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
====================================================================
Root | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
====================================================================
Output: c:\users\user1\appdata\local\temp\tmpy26cmp\output.xml
Log: c:\users\user1\appdata\local\temp\tmpy26cmp\log.html
Report: c:\users\user1\appdata\local\temp\tmpy26cmp\report.html
Local Output: C:\DEV\remote_output.xml
Local Log: C:\DEV\remote_log.html
Local Report: C:\DEV\remote_report.html

The rfremoterun script prints similar results to a normal Robot execution, but also prints the location of where the test artifacts have been written to on the local machine.

Assumptions & Limitations

  • A subset of the robot.run arguments are currently accepted. The plan is to extend these to the full set in due course.
  • __init__.robot files are not currently supported.
  • All Python Keyword libraries must be standalone and may only depend on Python modules that will be present on the remote host.
  • Robot variable files are not supported.

Future enhancements

  • Extend support for:
  • Further robot.run arguments
  • Variable files
  • __init__.robot files
  • Create an asynchronous mode with the ability to poll the remote host for status updates .
  • Provide the ability to run Test Suites on multiple remote hosts concurrently.

How to contribute

I would welcome feature requests and bug reports via GitHub. I also invite you to implement your own features and changes. There is already a CI pipeline configured, with a comprehensive collection of Unit & Integration tests. Please maintain support for Python 2 & 3, and ensure that your new feature is implemented in a robust manner and adequately tested.
You can find the source code on GitHub here, released under the MIT license.

Originally published at https://chris-brookes.blogspot.com on April 28, 2020.

--

--

Chris Brookes

‘Just a tech’. Python & C# Developer. Blog of random technical thoughts that hopefully somebody, somewhere will find useful or interesting one day.