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.
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.
To build an image:
git clone https://github.com/smartbear/docker-soapui-testrunner
docker build -t mycompany/docker-soapui-testrunner .\
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.
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:
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.
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
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:
ADD ext $READYAPI_FOLDER/bin/ext
To learn more about the READYAPI_FOLDER
environment variable, see below.
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:
ADD plugins /root/.soapui/plugins
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.
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.
-v="Project Folder":/project
Specifies the path to the folder that contains the ReadyAPI project. When a container starts, this folder is copied to the container.
Usage: -v="С:\readyapi\projects\sample-readyapi-project":/project
Note: On some systems, you may need to change the path in the following way:
"C:\readyapi\projects\sample-readyapi-project" -> "/host_mnt/C/readyapi/projects/sample-readyapi-project"
Tip: Alternatively, you can include the needed files in an image (see above).
-v="Extensions Folder":/ext
Specifies the folder whose content will be copied to the /bin/ext folder of the ReadyAPI installation folder in a container. Use this argument if your project requires additional libraries, such as database drivers or plugins.
Usage: -v="C:\readyapi\ext":/ext
Note: On some systems, you may need to change the path in the following way:
"C:\readyapi\ext" -> "/host_mnt/C/readyapi/ext"
Tip: Alternatively, you can include the needed libraries in an image (see above).
-v="Plugins Folder":/root/.soapui/plugins
Specifies the folder with plugins that should be installed to ReadyAPI in the container.
Usage: -v="C:\Users\<User>\.soapui\plugins":/root/.soapui/plugis
Note: On some systems, you may need to change the path in the following way:
"C:\Users\<User>\.soapui\plugins" -> "/host_mnt/C/Users/<User>/.soapui/plugins"
Tip: Alternatively, you can include the needed plugins in an image (see above).
-v="Report Folder":/reports
Specifies the folder on a local machine to which the generated reports will be exported.
Usage: -v="C:\readyapi\reports":/reports
Note: On some systems, you may need to change the path in the following way:
"C:\readyapi\reports" -> "/host_mnt/C/readyapi/reports"
-e LICENSE_SERVER="License Server Address"
Specifies the address of the license server. When a container runs, it connects to the specified server to obtain the ReadyAPI Test floating license.
Usage: -e LICENSE_SERVER="10.0.10.1:1099"
Tip: Alternatively, you can specify the address of the license server in an image (see above).
-e COMMAND_LINE="Test Runner Arguments"
Specifies arguments for the test runner. The %project%
variable refers to the container folder to which the contents of the project folder were copied. To refer to the reports volume, use the %reports%
variable.
Usage: -e COMMAND_LINE="-f/%reports% '-RJUnit-Style HTML Report' -FHTML '-EDefault environment' '/%project%/sample-readyapi-project.xml'"
Tip: Alternatively, you can specify the command line in an image (see an example above)
-it Required. This command enables an interactive command-line interface within a Docker container.
mycompany/docker-soapui-testrunner Required. Specifies the image to create a container from.
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
The base ready-api-soapui-testrunner image uses the following environment variables:
READYAPI_VERSION
Contains the ReadyAPI version.
Example: 2.8.0
READYAPI_FOLDER
Contains the folder where ReadyAPI is installed in a container.
Example: /usr/local/SmartBear/ReadyAPI-2.8.0
PROJECT_FOLDER
Contains the folder where a project and all the dependent files are located in a container.
Default value: /usr/local/SmartBear/project
REPORTS_FOLDER
Contains the folder where reports will be placed in a container. To copy these reports to a folder on a local machine, use the -v="Report Folder":/reports option when you run the container.
Default value: /reports
LICENSE_SERVER
Contains the address of the license server to get a floating license from.
Example: 10.0.10.1:1099
COMMAND_LINE
Contains command-line arguments for the ReadyAPI test runner. See a complete list of possible arguments in ReadyAPI documentation.
Example: -f/%reports% '-RJUnit-Style HTML Report' -FHTML '-EDefault environment' '/%project%/sample-readyapi-project.xml'
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. |
If you cannot run Docker due to the Drive has not been shared error, perform the following steps:
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.