Functional Tests in Docker

About

Docker runs applications in light-weight virtual containers. The containers provide you with a consistent environment isolated from other applications. SmartBear provides you with the ready-api-soapui-testrunner docker image you can use to run ReadyAPI functional tests within containers. The image is available in Docker Hub.

Docker image

To run functional tests in Docker, use the following image from Docker Hub:

go.gifhttps://hub.docker.com/r/smartbear/ready-api-soapui-testrunner/

Required license

To use the image, you must have a file-based floating license or a SmartBear ID-based floating license assigned to you.

To specify your license, add the parameters shown below to your docker run command.

Hardware requirements

This topic describes how to use Docker with ReadyAPI on the Hyper-V virtualization platform. To do that, use the same environment you use to run your Docker images. There are no specific requirements for this.

To learn more, see the Docker documentation:

To run ReadyAPI tools in Docker containers on other virtualization platforms, additional configuration may be required. Please see the corresponding documentation.

Important

Known issue: You cannot run the ready-api-soapui-testrunner image by using the Docker toolbox.

Pulling Functional Test Runner image from Docker Hub

To run functional tests by using a Docker image, you need to pull it from Docker Hub. To do this, use the following command:

docker pull smartbear/ready-api-soapui-testrunner

Docker command syntax

To run a 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 -e LICENSE_SERVER="License Server Address" -e COMMAND_LINE="Test Runner Arguments" -it smartbear/ready-api-soapui-testrunner:latest

If you have moved to the new SmartBear ID-based licenses that we’ve introduced in ReadyAPI 3.8.1, you must add the parameters shown below to your docker run command. Specifies the address of the SmartBear license server for our new SmartBear License Management server.

docker run -v="Project Folder":/project -v="Report Folder":/reports -v="Extensions Folder":/ext -e SLM_LICENSE_SERVER="SLM License Server Address" -e COMMAND_LINE="Test Runner Arguments" -e API_KEY="9a######-####-####-####-##########97 -it smartbear/ready-api-soapui-testrunner:latest

Arguments

Sample full command

docker run -v="C:\TestRunner\Project":/project -v="C:\TestRunner\Reports":/reports -v="C:\TestRunner\Extensions":/ext -e LICENSE_SERVER="10.0.21.14:443" -e COMMAND_LINE="-f/%reports% '-RJUnit-Style HTML Report' -FHTML '-EDefault environment' '/%project%/Sample-readyapi-project.xml'" -it smartbear/ready-api-soapui-testrunner:latest

If you have moved to the new SmartBear ID-based licenses that we’ve introduced in ReadyAPI 3.8.1, you must add the parameters shown below to your docker run command. Specifies the address of the SmartBear license server for our new SmartBear License Management server.

docker run -v="C:\TestRunner\Project":/project -v="C:\TestRunner\Reports":/reports -v="C:\TestRunner\Extensions":/ext -e SLM_LICENSE_SERVER="https://api.slm.manage.smartbear.com:443" -e COMMAND_LINE="-f/%reports% '-RJUnit-Style HTML Report' -FHTML '-EDefault environment' '/%project%/Sample-readyapi-project.xml'" -it smartbear/ready-api-soapui-testrunner:latest

Exit codes

After the docker stops running, you can get the exit code by using the following command:

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

101

Contained ReadyAPI cannot start due to a license issue.

Make sure the license server is properly configured and the Docker image can access to it. See other possible issues with Floating licenses.

102

The ReadyAPI project was not found.

Make sure you specify the correct folder for the project volume, and this folder contains the specified project.

103

An error occurs during the test run. See the test log for more details.

How to run a Docker image as a user with root access

When users require root access to the ReadyAPI Docker image, we recommend using this approach:

  • docker run --user root loaduiagent:3.41.1 - This will enable you to create/update/link files.

    • Instead of docker run loaduiagent:3.41.1 (which is the default method to run it, but it does not come with root access)

To add the Functional Test Runner image to your Docker Compose application:

  1. Get the Functional Test Runner image's Dockerfile from GitHub (https://github.com/SmartBear/docker-soapui-testrunner) and put it somewhere in your Docker Compose project directory.

  2. Open Dockerfile in any text editor. Uncomment the line that assigns the license server address to the LICENSE_SERVER environment variable and specify the host and port of your license server.

    Example:

    ENV LICENSE_SERVER=10.0.22.12:443

    Tip

    If you configure other commands in the file, you will not have to specify the corresponding arguments when running the service.

  3. Open the docker-compose.yml file in your Docker Compose project folder and add the command to build a service from Dockerfile:

    <service-name>:
      build: <path>

    Example:

    Tip

    For a reference on the docker-compose.yml file, see https://docs.docker.com/compose/compose-file/.

  4. Use the docker-compose build command to build the services specified in the docker-compose.yml file.

Now, when you run your Docker Compose application, the Functional Test Runner will be run as a part of it.

To run only the Functional Test Runner service, use the following command:

docker-compose run <service-name> -v="Project Folder":/project -v="Report Folder":/reports -v="Extensions Folder":/ext -e -e COMMAND_LINE="Test Runner Arguments" -it

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:

    Docker image: Docker context menu
  2. On the Shared Drives page of the Settings dialog, select all the drives you use to run the Docker container.

    Important

    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.

    To share your drivers, select them in the list and click Apply:

    Docker image: Docker context menu

    You may need to enter the credentials of your system account to apply the changes.

See Also

Publication date: