Test with Docker activities

Relevant for: API testing

Use UFT's native API testing capabilities to test your applications stored in remote Docker containers.

Docker activities allow UFT to manage Docker, download images from the Docker registry, and run containers based on those images. Docker activities are available in the Toolbox pane under the Docker node.

UFT uses applications packed with Docker as follows, accessing both the image and the container:

  1. UFT first sends a request to Docker to download (pull) the image from the Docker registry.

    If you have a special configuration for how you want a Docker container to run, create a container and load a JSON file with the configuration.

  2. Docker starts the container based on the downloaded image.

  3. While the application is running, UFT performs additional test steps on the application.

  4. When the test run is complete, UFT sends a request to Docker with a request to stop the container.

For general information about Docker, see the Docker documentation.

Configure ports

Before you test, configure ports in the Run Image or Create Container activities to map the container port to the Docker host port.

This enables applications to access the mapped port inside the container.

Update the properties as follows:

Run Image activity

Configure the port in the Port Bindings property in the Properties pane.

For details, see Run an image.

Create Container activity

Specify the port bindings inside the JSON body of the request and then load it into the activity.

For details, see Create a container.

Tip: To make the port accessible from outside a container, use the 'EXPOSE' parameter in the Docker file of the image.

Pull an image from the Docker registry

  1. In the Toolbox pane, from the Docker node, add a Pull Image activity to the canvas.

  2. In the Input/Checkpoints tab of the Properties pane, enter the access details for the Docker container:

    • URL of the Docker server in which the Docker image is stored

    • Image to pull from the Docker hub on the Docker server

    • The tag used to identify the image - optional

  3. If necessary, add checkpoints to validate the activity:

    • Digest: specify the digest identifier of the image to ensure that you imported the correct image

    • Status: the status of the image import operations

Back to top

Create a container

If you have special custom parameters or need advanced configuration for your container, create your own custom container.

This enables you to configure the container creation using any of the parameters provided by Docker.

  1. Ensure that the Docker image already exists on the Docker server.

  2. In the Toolbox pane, from the Docker node, add a Create Container activity to the canvas.

  3. In the Input/Checkpoints tab of the Properties pane, provide the container details:

    • Server URL of the Docker server

    • Container name for the created container. By default this argument should remain empty, as Docker generates the value automatically

  4. In the Advanced Properties tab , click the Load JSON button.

    The .json file body is loaded with a REST request with parameters, ready to be used when the container is created.

Back to top

Run a container

  1. In the Toolbox pane, from the Docker node, add a Start Container activity to the canvas.

  2. In the Input/Checkpoints tab of the Properties pane, provide the container details:

    • Server URL of the Docker server

    • Container ID of the container to start

      Tip: Parameterize this value by linking this property to the Container ID property of a Create Container activity.

Back to top

Run an image

After you have downloaded the image of your application to the Docker server, you can run an image of the application on the container.

Running the image starts the image in its own container, and starts the specified application using the command provided.

  1. In the Toolbox pane, from the Docker node, add a Run Image activity to the canvas.

  2. In the Input/Checkpoints tab of the Properties pane, provide the access details for the Docker container:

    • URL of the Docker server
    • Image to run from the Docker hub on the Docker server

    • The Command used to run the application inside the Docker container
  3. Below the main input properties, in the Port Bindings row, click the Add button to add a port binding array to the step.

  4. In the array, provide the following ports:

    • Container port: the port inside the container that receives the output from the application
    • Host port: the port on the Docker host machine

    Once these ports are mapped to one another, all data that arrives at the container port is forwarded to the host port.

Back to top

Add additional test steps

Once the container is started, the application is available for testing.

From the Toolbox pane, expand any necessary nodes and add activities to the canvas.

Back to top

Stop the Docker container image

When you finish running the test of the application, stop the container that is currently running.

  1. In the Toolbox pane, from the Docker node, add a Stop Container step to the canvas.

  2. In the Input/Checkpoints tab of the Properties pane, set the properties used to identify the container you want to stop:

    • URL of the Docker server
    • Container's ID to stop
    • The Time to delay (in seconds) before stopping the container

Back to top