Running automated tests with containerized workbench and agents from Docker
To simplify the deployment piece of Continuous Testing, you can use built Docker images to deploy the workbench and the agents and start testing in no time. You need not install the workbench and the agents on different machines. You can deploy the Docker images and use Docker commands to play back tests.
Before you begin
You must have configured the Docker container. See Configuring Docker containers.
You must already have exported the test assets to a location from where Docker can import them. For information about exporting the test assets, see Copying test assets with dependencies.Note: The version number of the
container images and the desktop products must match. If you have previous version of the container
image, uninstall it and install the current version. To uninstall the image, use these commands:
- Stop the container by running
.docker stop "CONTAINER ID"
- Uninstall the image by running
.docker rmi -f "image ID"
Procedure
-
To run the test without using any agents, start the container:
$ docker run --rm -e HCL_ONETEST_LICENSING_URL=<URL> HCL_ONETEST_LICENSING_ID=<server_ID> -v hostTestAssets:/containerTestAssets -v hostImportedData:/containerImportedData imageName:imageVersion cmdline -workspace //containerImportedData/workspace -project projectName -schedule testName -suite TestSuitePathAndName-results autoResults -stdout -exportlog /containerPathExtracted/testlog.txt -protocolinput "distributed.tests=/Tests/AFT_INPUT_XML.xml"
Table 1. Command Description --rm Removes the container after the run completes. -e Sets environment variables. HCL_ONETEST_LICENSING_URL=<URL> Specifies the URL of the license server, usually, https://hclsoftware.compliance.flexnetoperations.com. HCL_ONETEST_LICENSING_ID=<ID> Specifies the cloud license server ID. If you are using a Local License Server (LLS), do not use this variable. The floating license for the product and VT-packs must be on the license server. hostTestAssets:/containerTestAssets Specifies the folder location on the host machine and the container containing the compressed test assets (Zip format). Use both the locations to map one or more shared volumes to transfer data such as test assets, logs, and execution results between the host and the container. hostImportedData:/containerImportedData Specifies the workspace location on the host machine and the container containing the test assets that are not compressed. Results from the test execution are saved to the directory you specify on the host machine. TEST_IMPORT_PATH=<PATH> Specifies the location of the compressed test assets to be imported into the container. The location path is on the container side and not the host. For example, /containerTestAssets/archiveName.zip. The volume and path names are user defined and should be consistent. imageName:imageVersion Specifies the name of the image and its version to run. cmdline Specifies the existing command line arguments to define the location of the workspace, project name, test or schedule name, results file name, and the location of the exported logs. -protocolInput Use this argument to run multiple Web UI tests in parallel on different browsers and locations. The tests are distributed across different agent locations. Specify the path to the XML file that lists the test assets, browsers, and agent locations. After the test run completes, check the hostImportedData on the host machine to view the exported log. -
To run the tests on containerized agents, load the agent images into the Docker
repository:
tar --wildcards --to-command='docker load' -xzf <workbenchImageName> 'images/'*
For example, the workbench image name could be hcl-onetest-<versionNumber>.tar.gz.
When the image is loaded, the following message is displayed - Loaded image: imageFileName:versionNumber - Create an XML file that lists the agents to be used for the distributed run of multiple tests using many browsers on multiple agent locations. For more information, see Running multiple tests simultaneously from command line.
-
Initiate the test runs against the agents in one of the following ways:
- Verify whether the schedule has completed successfully. If you used an option such as -exportlog to output results to the shared volume, check the corresponding directory on your host machine that was mapped to hostImportedData to retrieve the exported data.
What to do next
docker stop containerID
If you used Docker Compose tool
to run the tests, you can stop the agents when the workbench container exits by
running
docker-compose up --abort-on-container-exit