In this article, we will walk you through how to setup the automation host in Docker environment.
1. Create a Dockerfile in a folder, e.g. ~/agent, enter content as below:
FROM openjdk:9-jdk RUN apt-get update && apt-get install -y git curl wget && rm -rf /var/lib/apt/lists/* ENV AGENT_VERSION $TheAgentHostVersion ENV PACKAGE_NAME agentctl-${AGENT_VERSION}-linux-x64-full.tgz ENV PACKAGE_URL https://s3.amazonaws.com/qtest-storage/qtest-automation/${AGENT_VERSION}/$PACKAGE_NAME ENV AGENT_HOME /usr/local ENV FOLDER_NAME agentctl-${AGENT_VERSION} ENV PORT 6789 WORKDIR $AGENT_HOME RUN set -x \ && wget --no-check-certificate "$PACKAGE_URL" \ && tar xvzf $PACKAGE_NAME -C $AGENT_HOME \ && rm $PACKAGE_NAME \ && mv agentctl-${AGENT_VERSION} agentctl # install a junit sample COPY ./junit-sample ${AGENT_HOME}/junit-sample/ # configure host RUN ./agentctl/agentctl config -Phost=0.0.0.0 -Pport=${PORT} EXPOSE $PORT COPY ./entrypoint.sh /entrypoint.sh RUN chmod u+wrx /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"]
Note:
- $TheAgentHostVersion: replace this value with the automation host version you want to install, e.g. 2.0.2
- This example install junit sample code to demo junit-java plugin, you can download junit-sample to working folder (~/agent) and follow guide to build the sample in this repository: https://github.com/QASymphony/junit-sample
2. Create a file called entrypoint.sh and make it executable
Open entrypoint.sh in your favorite text editor and enter content as below:
#!/usr/bin/env bash /agentctl/agentctl start
3. Build the image:
docker build -t agent:new .
Once the build is successful, you'll see the output like below:
4. Run the container with the desired port and hostname:
$ docker run -d -p 8080:6789 agent:new
When this command finished, wait for a couple of minutes for the automation host to be fully started.
5. Register the automation host with qTest Manager
Open web browser and access to the host via this url: http://[host-ip-address]:8080. You will be presented with a UI like below.
On the host UI, enter the following to register the automation host with qTest Manager:
- Host Name: name of the automation host
- qTest URL: URL of you qTest Manager instance
- Full Name: your full name
- qTest Token: the API token for the host to access to qTest Manager. Follow these instructions to get the API token
- If your environment is behind proxy, click on Configure Proxy link and provide proxy configuration
- Click Register button
When the registration is successfully, you'll be presented with the automation host home page.
6. Create JUnit sample agent
Click Add button.
On the New Agent dialog, enter the information for the new agent.
Click Save & Scan button. The automation host will create your agent and scan for test cases. When the scanning complete, you'll be presented with the Automation Test Case Mapping Wizard dialog as below screenshot.
Select test cases then click Create to create test cases in qTest Manager.
You have completed setup automation host on Docker environment.