Installing and configuring Docker

Docker is a full development platform for creating containerized applications. Instead of reading through the system requirements list, you can now deploy the Docker containers on any computer and get started with testing. You can install and configure Docker on the same system where HCL OneTest™ API is running.

Before you begin

You must have completed the tasks in Creating and running a stub. You must use the stub that you created in that task.

You must learn about testing with Docker before you start this task. See Testing with Docker.

Procedure

  1. You must prepare your system to use Docker. See Preparing to use Docker.
  2. Install Docker.

What to do next

You must return to HCL OneTest API and configure the pass-through behavior of the stub. See Configuring the pass-through behavior of the stub.

Configuring the pass-through behavior of the stub

You must configure the pass-through behavior of the stub. By configuring the pass-through behavior, you can enable the stub to determine whether it can handle a received request if it is matching or, when possible, send the traffic to the real system that is, if the received request does not match.

Procedure

  1. Open the Pass-Through window on the Properties tab of the Stub Editor.
  2. Enable the stub to use pass-through action.
  3. Save the stub.

What to do next

You must publish the stubs to a Dockerfile. See Publishing the stub to Docker.

Publishing the stub to Docker

You can publish stubs that are created in HCL OneTest API to a Dockerfile and build context if the stub is based on a supported transport.

Before you begin

You must stop the stub if the stub is still running. You must return to the Test Factory perspective if it is not already open.

About this task

You can publish the stub to a Dockerfile by using a build context directory. Running a stub in Docker involves the following steps:

Procedure

  1. In the Test Factory perspective, right-click the stub and click Publish Stubs to Docker.

    Image of the Test Factory window.

  2. Select an environment for HCL OneTest API to use while running the stubs.

    Image of the Publish Stubs window.

  3. Click Next.
  4. Select a template.

    By default, HCL OneTest API provides a template, which is based on Ubuntu. This template provides the runtime and files that are necessary to run the stub. Optionally, you can provide a comment.

    Image of the Dockerfile template window.

  5. Click Next.
  6. In the Output Directory dialog, click Browse to select an empty folder to publish the Dockerfile and the other supporting files.

    If the folder does not exist already, HCL OneTest API creates it.

    Image of the Output directory window.

  7. Click Finish.

    A status message informs you that the Docker artifacts were published to the output directory specified.

  8. Click OK.

    For more details about the contents of the directory to which the stub was published, see Dockerfile and build context.

Results

You have published stubs to a Dockerfile.

What to do next

You must build a Docker image of the published stub. See Building a Docker image of the stub.

Building a Docker image of the stub

After you publish one or more stubs to a Dockerfile and build context, you must build a Docker image from those files. You can use the docker run command to run the image in a container.

About this task

You will learn how to build a Docker image of the stub from the files in the output directory.

Procedure

  1. Open the Docker Quickstart Terminal.
  2. Run the following command:
    docker build -t gs4stub c:\Users\IBM_ADMIN\GS4

    Image of the command window showing the command run.

    If the image is built successfully, you can see a message similar to the following at the end of the status message:
    Successfully built 914d41372c5e

  3. To verify that the Docker image of the stub is successfully built, run the following command:
    docker images

    Image of the command window showing the docker images.

  4. Optional: To verify that it is the additionStub that has been built into the gs4stub image, run the following command:
    docker run --entrypoint cat gs4stub /stubs.info

    Image of the command window showing the command run.

Results

You have built a Docker image of the published stub.

What to do next

You must run the published stub that is in a Docker container. See Running the stub in a Docker container.

Running the stub in a Docker container

After publishing the stub and building a Docker image, you can now run the stub in a Docker container. You can run the stub anywhere that you have a Docker environment, whether on a private cloud or public cloud.

Before you begin

You must have built a Docker image of the published stub.

Procedure

  1. Run the following command:
    docker run --name stub1 -dP gs4stub

    Image of the command window showing the command run.

    The long string that is displayed is the unique ID that Docker has assigned to the container in which the stub is running.

  2. To verify that the stub is running, run the following command:
    docker ps

    Note down the port specified under the PORTS column. You need it later.

  3. Optional: To check the logs while the stub is running, run the following command:
    docker logs -f stub1

Results

You have run the stub in a Docker container.

What to do next

You must verify if the stub running the in the Docker container is called by the client you used, in this example it is the Add Numbers client. See Verifying that the Add Numbers client is calling the stub.

Verifying that the Add Numbers client is calling the stub

After running the sample WSDL document such as the Add Numbers client, you must verify that the client is calling the stub that is running in the Docker container.

Before you begin

You must have successfully completed running the stubs in a Docker container.

Procedure

  1. Find the IP address of the Docker machine on which the stub is running. To do so, run the following command:
    docker-machine ip.

    Note down the IP address, for example, 192.168.99.100.

  2. Open the Add Numbers client.
  3. In the Host Address field, enter the IP address you noted down in Step 1.
  4. In the Port Number field, enter the port number you have noted down in Step 2 of Running the stub in a Docker container, for example, 32768.
  5. Click the equal sign to run the add operation and verify the result.

    Image of the Add Numbers client window.

Results

You have verified that the Add Numbers client is calling the stub running in the Docker container.

What to do next

You must stop the running stub and remove the Docker container. See Stopping the stub and remove the Docker container.

Stopping the stub and remove the Docker container

After verifying that the Add Numbers client is calling the stub running in the Docker container, you must stop the stub by using the Docker stop command. You must also remove the Docker container.

Procedure

  1. To stop the stub, run the following command:
    docker stop stub1

    Image of the command window showing the command run.

  2. To remove the Docker container, run the following command:
    docker rm stub1

    Image of the command window showing the command run.

Results

You have stopped the stub running in the Docker container and also removed the Docker container.

What to do next

You can run the stub in Docker containers on a private or public cloud. See Running the stub in Docker containers on private or public cloud.

Running the stub in Docker containers on private or public cloud

You can also run the stub in Docker containers on a private cloud or public cloud. After you configure Docker on cloud, you can use publish and run the stubs in the Docker cloud.

Before you begin

You must have set up and configured Docker on a public or private cloud. For details, see Introducing Docker Cloud.

Procedure

  1. Configure the stub to connect to the services that are running in the enterprise and the stub is running on the public cloud. For details, see Configuring stubs to connect to HCL Quality Server and the HTTP proxy.
  2. Publish the stub to the Docker cloud following the steps in Publishing the stub to Docker.
  3. Run the stub in the Docker cloud following the steps in Running the stub in a Docker container.
  4. Verified that the Add Numbers client is calling the stub running in the Docker cloud following the steps in Verifying that the Add Numbers client is calling the stub.

Results

You have configured a Docker cloud and published and run a stub in the Docker cloud.

What to do next

For more information about working with stubs in Docker, use the following resources:

Feedback