Testing Area/Behat Testing/Run Behat On Docker

From Mahara Wiki

< Testing Area‎ | Behat Testing

You can use docker to run mahara behat tests on your local machine without concern for os, php or firefox compatibility. Using docker, you can run the tests on your Linux, Windows or Mac machine.

Install Docker on your machine

Please read more detailed information for Mac users and for Windows users.

Here are a quick start for Ubuntu users

Install Docker on Ubuntu machine

These instructions are for Ubuntu 14.04 and 16.04 You should have sudo privilege to install.

Update your apt sources

  • Update package info
$ sudo apt-get update
$ sudo apt-get install apt-transport-https ca-certificates
  • Add the new GPG key for Docker’s APT repository
$ sudo apt-key adv --keyserver hkp:// --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
  • Add an line for your Ubuntu to the /etc/apt/sources.list.d/docker.list file
    • On Ubuntu Trusty 14.04 (LTS)
$ sudo bash -c 'echo "deb ubuntu-trusty main" >> /etc/apt/sources.list.d/docker.list'
    • On Ubuntu Xenial 16.04 (LTS)
$ sudo bash -c 'echo "deb ubuntu-xenial main" >> /etc/apt/sources.list.d/docker.list'
  • Update the APT package index and verify APT repository for docker
$ sudo apt-get update
$ apt-cache policy docker-engine

Install linux-image-extra-* packages

$ sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
$ sudo reboot

Install docker

$ sudo apt-get install docker-engine
$ sudo service docker start

Docker images for mahara developers and testers

Catalyst Docker Registry

All internal docker images should be pulled/pushed from/to our catalyst private registry. If you don't have a login credential on it, please make a new request on the WR #245259.

Login to catalyst docker registry

$ sudo docker login
Username (<your username>): 
Login Succeeded
$ sudo docker info

Pull mahara docker images

$ docker pull

The image name '' will be the default image when run the script

Mahara docker images on seafile

For those who haven't got access to catalyst docker registry, the images are available to download via catalyst seafile

  • Download the file ubuntu1404_lappf.tar from catalyst seafile
  • Load it to your local docker
$ sudo docker load <path to ubuntu1404_lappf> <image name>
$ sudo docker images

Run behat tests on docker

Useful scripts

You can download two shell script files from [1] help you to run mahara container;

and is for running behat tests.

Run mahara container

$ <name of container> <port> <path to mahara code> <path to mahara dataroot> [<image name>]

Please make sure <path to mahara code> is readable by user www-data and <path to mahara dataroot> is readable and writable by www-data

Run mahara behat tests

Update behat settings in config.php

  • Create the 'behat' directory inside <path to mahara dataroot>, and make sure it is writable by www-data
$ sudo -u www-data mkdir <path to mahara dataroot>/behat
  • Update behat settings in <path to mahara code>/htdocs/config.php
$cfg->behat_dbprefix  = 'behat_';
$cfg->behat_wwwroot  = 'http://localhost/';
$cfg->behat_dataroot = '/var/lib/sitedata/behat';

Run tests

$ <name of container> run|rundebug [@tag_name|<feature file>]