[Beaker-devel] Upcoming feature: Running Test harness in a Docker Container

Amit Saha asaha at redhat.com
Fri Oct 3 06:22:34 UTC 2014

Hi all,

We recently merged a new feature into the "develop" branch which allows
running the test harness in a Beaker container [1]. 

During the testing, I used the "restraint" [2] test harness instead of Beaker's
default test harness, "beah". "restraint" is not available from Fedora's repos
so the repository has to be added in the Job XML.

Here is an example recipe which runs the test harness in a container running Fedora 20:


The key points in the above recipe for this feature are:

- "contained_harness" ksmeta variable: This tells beaker that we want to run the test harness
  in a Docker container.
- The restraint repo is added using the <repo/> element.
- The task to be run is added in the <task/> elements.

Since this recipe does not specify which distro image to use for the test harness container,
we default to Fedora 20. 

To specify a different image, use the "harness_docker_base_image" ksmeta
variable. For example, the following recipe will run the test harness in a CentOS 7 container while
the host system is running Fedora 20: https://gist.github.com/amitsaha/aebe0e782a47063e9270

As mentioned in [1], a privileged Docker container is used to run the test harness and by default
we use "systemd" to initialize the test harness. Hence it is the harness's responsibility to
register/install itself in the right target. 

This can however be changed with the "contained_harness_entrypoint" ksmeta variable. 
See [3] for a brief explanation on this and the other ksmeta variables.

This is an experimental feature and currently the following limitations apply:

- Tests which reboot are not supported
- Tests which may want to spawn other containers are not supported as well
- Distros with SysV init hasn't been tested
- Beaker's default test harness, beah hasn't been tested
- .. others I am sure.

[1] https://beaker-project.org/docs-develop/whats-new/next/test-harness-in-container.html
[2] http://restraint.readthedocs.org
[3] https://beaker-project.org/docs-develop/user-guide/customizing-installation.html#kickstart-metadata


Amit Saha 
SED, Hosted & Shared Services
Red Hat, Inc.

More information about the Beaker-devel mailing list