SmartBear / docker-soapui-testrunner

Customizable ReadyAPI Test runner docker image
5 stars 4 forks source link

Docker ReadyAPI Test Runner

Table of contents

About

Use this project to create custom Docker images to run ReadyAPI functional tests. The project contains a sample Dockerfile that you use to extend the base ready-api-soapui-testrunner image.

Required license

To use a Docker image, you must have a ReadyAPI Test floating license. When you run a container, it connects to the specified license server and obtains the license. The license server must be available to the container and must be properly configured. See Configure License Server.

Build an image

To build an image:

  1. Install Docker.
  2. Clone this repository to a local folder. To do this by using Git, run the following command:
    git clone https://github.com/smartbear/docker-soapui-testrunner
  3. Edit the Dockerfile to customize the image.
  4. Execute the following command in the repository root folder:
    docker build -t mycompany/docker-soapui-testrunner .\
  5. After the image has been built, you can run a container.

Required arguments

To run a ReadyAPI functional test in a Docker container, you need to pass the following data to the container:

Optionally, you may need to pass:

There are two ways to pass this data to a container: add it to the base image or specify it in the command line when you run the container.

Typically, you add data that is not changed from test to test to the image and specify variable data in the command line when you run a container.

Configure an image

To add data to an image, edit your Dockerfile. A Dockerfile is a set of instructions for Docker on how to build an image. To learn how to build images, see Docker documentation.

Below, you can find several examples with typical tasks:

Add files to an image

If you add files to an image, the files will be available to each container when they start. To add files, use the ADD command. For example:

ADD my-folder $PROJECT_FOLDER

This command copies all the files from the my-folder directory to the project directory in an image.

Important: The directory you want to add must be in the folder containing the Dockerfile.

To learn more about the $PROJECT_FOLDER environment variable, see below.

Tip: Make sure you use the relative path to these files in the project. To learn more about it, see ReadyAPI documentation.

Specify a license server

If your containers use the same license server, you can add its address to an image. To do this, assign the license server address to the LICENSE_SERVER environment variable in the Dockerfile:

ENV LICENSE_SERVER=License server address

For example:

ENV LICENSE_SERVER=10.0.21.14:1099

Integrate external libraries

If you use external libraries in your project, you need to add them to the ReadyAPI installation folder. For example, if you use databases in a test, you need to install JDBC drivers. Most likely, you will use the same driver in all your test runs, so it is reasonable to include it in a Docker image. To do this:

  1. Copy the needed libraries to the ext folder that contains the Dockerfile.
  2. Add the following instruction to the Dockerfile:
    ADD ext $READYAPI_FOLDER/bin/ext

To learn more about the READYAPI_FOLDER environment variable, see below.

Install plugins

If you use plugins in your test, you must install them to ReadyAPI in a container. For example, if you run your test by using the MQTT or AMQP protocols, you must install the related plugins. It is possible to add them to a Docker image. In this case, you can omit -v="Plugins folder":/root/.soapui/plugins in the command line. Note that the plugin files you want to add must be in the build context.

To add plugins to a Docker image, do the following:

  1. Copy the needed plugins to the plugin folder that contains the Dockerfile. You can find the plugins installed in ReadyAPI in the \<User folder>/.soapui/plugins folder.
  2. Add the following instruction to the Dockerfile:
    ADD plugins /root/.soapui/plugins

Specify a command line

If your containers use the same command line, you can add it to an image. To do this, modify the COMMAND_LINE environmental variable:

ENV COMMAND_LINE="-f/%reports% '-RJUnit-Style HTML Report' -FHTML '-EDefault environment' '/%project%/sample-readyapi-project.xml'"

Note: The command line in the example above commands ReadyAPI to generate reports. To copy this report to your host machine, you need to specify the folder to which you want to copy it. See below for more information.

Run a Docker container

To run a ReadyAPI functional test in a Docker container, use the following command line:

docker run -v="Project Folder":/project -v="Report Folder":/reports -v="Extensions Folder":/ext -v="Plugins Folder:/root/.soapui/plugins -e LICENSE_SERVER="License Server Address" -e COMMAND_LINE="Test Runner Arguments" -it mycompany/docker-soapui-testrunner

Depending on the data you added to the image, you can omit some arguments.

Arguments

Full command sample

docker run -v="C:\readyapi\projects\sample-readyapi-project":/project -v="C:\readyapi\reports":/reports -v="C:\readyapi\ext":/ext -e LICENSE_SERVER="10.0.10.1:1099" -e COMMAND_LINE="-f/%reports% '-RJUnit-Style HTML Report' -FHTML '-EDefault environment' '/%project%/sample-readyapi-project.xml'" -it mycompany/docker-soapui-testrunner

Environment variables

The base ready-api-soapui-testrunner image uses the following environment variables:

Exit codes

Besides the standard Docker exit codes (see the Docker documentation) the ready-api-soapui-testrunner image uses the following codes:

Code Description
101 ReadyAPI running in a container cannot start due to a license issue. Make sure the license server is properly configured and the Docker image can access it. See information on other possible issues with a floating license.
102 The ReadyAPI project was not found. Make sure you specified the correct folder for the project volume, and this folder contains the specified project.
103 An error occurred during the test run. See the test log for more information.

Troubleshooting

If you cannot run Docker due to the Drive has not been shared error, perform the following steps:

  1. Right-click the Docker icon in the notification area and select Settings.
  2. On the Shared Drives page of the Settings dialog, select all the drives you use to run the Docker image.
  3. Click Apply. You may need to enter the credentials of your system account to apply the changes.

Note: If your drives have already been shared, but the error occurs anyway, turn off sharing. After you apply the changes, repeat these steps to share the drives again.