Example: Using docker-compose

This topic provides an example of how you can use Docker containers to run a Silk4J test set on Google Chrome on a Linux machine with Apache Ant. Before you can run the test set, you have to perform the following tasks:
  • Install Docker on your machine.
  • Run the "Hello, World" program from the command line to verify that your basic Docker setup is configured correctly:
    docker run hello-world
  • Prepare your Silk4J project for executing tests with Ant. For additional information, see Replaying Tests with Apache Ant.
  • Copy the project to your Linux machine, for example to /home/<user name>/projects/InsuranceWeb.
To run the tests in the Silk4J project on Google Chrome.
  1. Create the docker-compose .yml file.
    version: '3'
    services:
      chrome:
        image: selenium/standalone-chrome:latest
        environment:
          - JAVA_OPTS=-Dselenium.LOGGER.level=WARNING
      agent:
        image: functionaltesting/silktest:latest
        environment:
          - SILK_LICENSE_SERVER=lnz-lic1.microfocus.com
          - SILK_LOG_FILE_PATH=/logs
        depends_on:
          - chrome
        links:
          - chrome
        volumes:
          - /home/<user name>/projects/logs:/logs
      tests-runner:
        image: webratio/ant:1.10.1
        volumes:
          - /home/<user name>/InsuranceWeb:/tmp/project
        command: ["ant", "-DagentRmiHost=agent:22902", "-Dsilktest.configurationName=host=http://chrome:4444/wd/hub;platformName=Linux - GoogleChrome", "-buildfile", "/tmp/project/build.xml", "runTests"]
        depends_on:
          - agent
        links:
          - agent
    Note: In order for the agentRmiHost system property to work, your test script must create a Desktop object by calling the constructor with no arguments. Additionally, in order for the silktest.configurationName system property to work, your test script must create a BrowserBaseState object by calling the constructor with no arguments.
  2. Pull the latest version of the involved images to your registry.
    docker-compose pull
  3. Execute the tests and stop all containers when the first container, in this case the Ant container, stops.
    docker-compose up --abort-on-container-exit
  4. View the test results under /home/<user name>/projects/logs.
  5. Optional: Cleanup your test environment.
    docker-compose down
You could combine the commands for pulling the latest versions, executing the tests, and cleaning up the test environment into a single command.
docker-compose pull && docker-compose up --abort-on-container-exit && docker-compose down