ATS : Special considerations for file copy in Docker environment

Introduction

This page outlines some specifics when you want to use ATS in a Docker environment. They are related only to some of the file copy operations.

Details

ATS is designed as a network independent tool, i.e. it works in same way both locally and remotely. That is why usually you should not expect test modifications when using Docker. There is just one detail that should be considered and it is related to the fact that containers may need exposing of network ports. Common picture is outlined below.

There the host is on the left and the container C2 is on the right. The needed configuration step is for the incoming link to C2 where internal port 80 is mapped to external (host) port 5000:

Source: docker.com

Affected ATS functionality is when copying files from outside to some Docker container. This is because the accepting part (the ATS agent) should be accessible from the sending part (usually the Test Executor like Eclipse or Maven process). In order to achieve this you need to:

1. Export some port range of the container to be visible from outside. This range could be set for later use for file copy operations in two ways: 

  • programatically, via ActionLibraryConfigurator.getInstance().setCopyFileStartPort() and ActionLibraryConfigurator.getInstance().setCopyFileEndPort();
  • via properties file. These "port range" properties are:
    • actionlibrary.filesystem.copyfile.start.port
    • actionlibrary.filesystem.copyfile.end.port
      You need to load them either via CommonConfigurator.registerConfigFile(fileName) or CommonConfigurator.registerConfigFileFromClasspath(fileName);
  • Then you should to the same in Docker configuration.
    The specific command is not described here. Note that ports mapped should match, i.e. local container port 12345 should be exposed to host with the same port number, 12345. Port ranges should also be the same like: 12345-12349:12345-12349

2. If Test Executor is on the same host where the Docker containers reside then you should do additional configuration. This is because all ATS agent operations have a check whether target agent is on the same IP (host). In such case ATS shortcuts to use operations in same JVM instead of contacting agent remotely via socket. To avoid this ATS team has developed a new method CommonConfigurator.getInstance().setHostLocality(). Note that this method affects all operations to agent with such name/IP.

3. Alternatively you may use FileSystemOperations.setCopyInPassiveMode(true) method. This method ensures that when copying files from the test executor to the container then the data ports are open on the test executor side, instead of the target receiver (container in this case). This method is recently developed and is available since version 4.0.7.


Recommendation

ATS team recommends usage of a homogeneous environment, i.e. all involved test machines to be containers, even test executor. This way all containers will be in same network and will NOT require declaration of open ports or the use of setHostLocality() method.

When this is not possible then you may need the configuration steps mentioned above.

Links




Go to parent page

Go to Table of Contents