24. Appendix 6: Running Vitaq AI in a Docker container

24.1. Introduction and assumptions

We deliver Vitaq AI in a docker container, which you can run on MacOS, Linux or Windows operating systems.

Docker (https://docs.docker.com/) is an application that simplifies the process of managing application processes in containers. Containers let you run the Vitaq AI application in resource-isolated processes. They’re similar to virtual machines, but containers are more portable and more resource-friendly. We provide Vitaq AI in a pre-built Ubuntu linux container with its necessary clients, example test activities and a stand-alone Selenium server.

In order to run Vitaq in a Docker container, you will need to have Docker installed and running and be able to execute Docker commands at a command prompt. If you do not have Docker installed, then please follow the installation guides at the Docker website.

Once you have docker installed. Check that it is installed correctly by typing the following command in your shell (cmd) window:

run -dp 80:80 docker/getting-started

24.2. Nomenclature

In command examples wherever there is a value enclosed by acute brackets, this indicates that the value and the acute brackets should be replaced with the value indicated by the text within the brackets, for example <docker image tag> might be replaced with vitaq_evaluation:4.1.5

24.3. Quick Start

Start Docker on your host computer and make sure it is running.

You will have been sent a link to download your Vitaq AI docker image. The name of the download will be <image name>_<image_tag>.tar.gz For example: vitaq_evaluation_4.1.5.tar.gz.

You need to load this downloaded docker image into docker. You can load the file as a tar.gz file. You do not need to untar or uncompress it.

Open a shell terminal window on your host computer:

Note

You need to replace the <downloaded file> part of this next command with the name of the Vitaq Ai downloaded image file. For example: vitaq_evaluation_4.1.5.tar.gz

See Notes on loading the docker image

docker load -i <downloaded file>
docker image ls

Now we are ready to ‘spin up’ the Vitaq AI container using docker run. Once running you can manage the container (stop, start, restart etc) using either your docker dashboard or docker terminal commands.

The next sections are operating system specific, so please follow the one appropriate for you.

see Notes on preparing to run the docker image

24.4. Docker run commands

Note

You are mounting your host disk to the docker image disk at /host. If you want to just mount a folder on your host machine, (i.e. where your working directory for VitaqAI files will be stored, then you can change src: to <PathTo><FolderName>. In this example you have to change <PathTo> to your host machine path to your working directory (remember: if your user name has a space in WIndows then you have to ‘escape’ the space character. Also you will need to change <Foldername> to the folder you will store your Vitaq AI files on your disk.)

Note

You will also need to replace the <image name> and <image tag> with the one you have downloaded and loaded into docker. You can find the image name and tag from the docker image ls command.

Note

Make sure you have created the directory (for example named VitaqWorking) on your host computer you want to store your Vitaq AI files into.

docker run --name VitaqAI -p 6080:80 --mount src=pgdata,dst=/var/lib/postgresql/9.6/main --mount type=bind,src=c:\,dst=/host --privileged --shm-size 512m <image name>:<image tag>
docker run --name vitaq -p 6080:80 --mount src=pgdata,dst=/var/lib/postgresql/9.6/main --mount type=bind,src=/Users/<MacOsUserName>/Documents/VitaqWorking,dst=/host --privileged --shm-size 512m <image name>:<image tag>
docker run --name vitaq -p 6080:80 --mount src=pgdata,dst=/var/lib/postgresql/9.6/main --mount type=bind,src=/home/<LinuxUserName>/VitaqWorking,dst=/host --privileged --shm-size 512m <image name>:<image tag>

24.5. Vitaq AI in the running docker container

Navigate to 127.0.0.1:6080 and then in the Ubuntu desktop start menu Go to Programming and select Vitaq Test Automation

_images/31_dockerdesktop.png

Note

Going to the local host URL in a new tab will cause the container desktop to fill the tab, so make sure your browser is in full screen mode because docker will default the window size from first opening. You can stop the VitaqAI docker container from the dashboard (or command line). Restart it and open it in a full size browser, if you get this wrong.

Test that you docker installation and VitaqAI is working correctly by trying the Installation test. From the Vitaq AI Test Automation window, use File -> Open which will open the File browser. Click on Home and then the folder examples. Then click on the InstallationTestActivity.vtq file (not the folder InstallationTestActivity) and select Open in the bottom right corner.

You will now see a two action Test Activity. Click the Run button in the top menu bar. Vitaq will start executing the Test Action Scripts (in this case written in Python) and show in the Script Output window, the execution log. It should finish with stdout: Participant Name is: Bart and then VITAQ TEST ACTIVITY SCRIPT HAS STOPPED. STOPPED VITAQ TEST ACTIVITY.

Now let’s try a more complicated example with Selenium, JavaScript and Scriptworks.

Click on File -> Close in VitaqAI to clear the Test Activity. Then click on File -> Open Go to the examples directory again and select the SauceDemoSelenium. And select Open in the bottom right corner.

Then select preferences in VitaqAI and select use Srciptworks. Put in your username and password and then select Connect. If your user name and password are correct it will turn green. Then click Load and select the Onboarding project (a default project preloaded into your scriptworks account). Then click load on the Run setting and select the standard Chrome browser driver settings.

Then click on use coverage and use AI and select OK.

Open a terminal from System Tools, LXTerminal, to start scriptworks-vitaq-client using the command:

./scriptworks_vitaq_client.js

Then open another terminal from System Tools, LXTerminal, to start Selenium in the docker container using:

./selenium_server.sh

Now go back to VitaqAI and click run. As Vitaq AI runs the shopping APP tests you will be able to explore the results in Scriptworks log and the coverage results as Vitaq runs. You will see about a dozen machine learning passes for VitaqAI to achieve 100% QA coverage, which will take about 12 minutes to complete.

24.6. Running Appium or Selenium on host machine

If you want to run Selenium or Appium on your host machine, rather than the docker container you need to specify the location of the Selenium/Appium server in the Scriptworks run settings, so that the IP address is replaced with the locator “host.docker.internal”.

24.7. Using additional JavaScript libraries for JS Test Actions

if you want to use JavaScript libraries in your JavaScript Test Action Scripts, then you will have to npm (node package manager) install them into the client directory in the container. E.g.

cd /sw/client

sudo npm install xmlhttprequest

You cannot do a global -g install in the container (JS Libraries have to be installed into the client directory).

24.8. Notes on loading the docker image

You will have been provided with a download link to a Docker container, which will be a gzipped tar file which can be read directly by Docker. Download the file to a location on your hard drive and then open a command prompt/terminal and navigate to the location where you saved the image file. Then import the file using the following command:

docker load -i <downloaded file>

This command will load the image as can be verified by using the command:

docker image ls

Looking at the output of the above command you should be able to see an entry with the image name, the tag and the image id. You will need these in the next step.

24.9. Notes on preparing to run the docker image

Data within a docker container is lost when the container is stopped. In order to save work, a mapping needs to be made from the host file system into the docker container, where we will find existing .vtq files and scripts or where we will save them. We recommend that you create a working directory called Vitaq in your Documents folder. Then you can use the Docker bind mounting in the following way:

Windows:

--mount type=bind,src=c:\User\<WindowsUserName>\Documents\VitaqWorking,dst=/host

MacOs:

--mount type=bind,src=/Users/<MacOsUserName>/Documents/VitaqWorking

Linux:

--mount type=bind,src=/home/Vitaq

(NOTE: This is a snippet of code that is part of the run command)

This specifies that the type is a bind mounting, that the source on the host machine is the D: drive and this will be mapped to the container filesystem at /host. The source can be changed to any required directory on the host machine using the standard path format for the host OS. Likewise, the destination can be mapped to any location in the container. This command is part of the run command which is used to start the Docker container. As many mount commands as required can be used.

24.10. Functional Coverage Database

Vitaq uses PostgreSQL to store functional coverage results. If the user wishes to have the coverage results persist after the container has been stopped, then disk space will also need to be mapped for the Postgres data file. A bind mounting can be used as explained above if a specific location is required e.g. for Windows:

–-mount type=bind,src=c:\postgres_data,dst=/var/lib/postgresql/9.6/main

(NOTE: This is a snippet of code for Windows that is part of the run command)

Except here the mapping must be to the destination folder as shown above.

If the user does not care where the Postgres data is stored, then a volume mount can be used. This is preferable for a number of reasons. In order to use this a docker volume needs to be created by using the command:

docker volume create <volume name>

e.g. docker volume create pgdata

A volume is then mounted in the run command using the following in the run command

–-mount src=pgdata,dst=/var/lib/postgresql/9.6/main

(NOTE: This is a snippet of code that is part of the run command)

24.11. Running the docker image

You can now run the Docker image using the following command. For example in Windows:

docker run --name vitaq -p 6080:80 --mount src=pgdata,dst=/var/lib/postgresql/9.6/main --mount type=bind,src=c:\User\<WindowsUserName>\Documents\VitaqWorking,dst=/host  --privileged --shm-size 512m <image name>:<image tag>

This command should be a single line, not separate lines as shown above.

To explain the above command a little, –name - specifies a name for the running container, can then be used to stop the container, -p - maps the port 6080 on the host machine to the port 80 in the container –mount - two mount commands as already explained in the section above