Actions

Testing Area/Behat Testing/Run Behat On Docker

From Mahara Wiki

< Testing Area‎ | Behat Testing
Revision as of 09:46, 11 October 2016 by Sonn (talk | contribs) (Created page with "You can use [https://www.docker.com/what-docker docker] to run mahara behat tests on your local machine without concern for os, php or firefox compatibility. Using docker, you...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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
$ sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --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 echo "https://apt.dockerproject.org/repo ubuntu-trusty main" >> /etc/apt/sources.list.d/docker.list
    • On Ubuntu Xenial 16.04 (LTS)
$ sudo echo "https://apt.dockerproject.org/repo 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 https://cat-prod-dockerregistry.catalyst.net.nz
Username (<your username>): 
Password: 
Login Succeeded
$ sudo docker info

Pull mahara docker images

$ docker pull cat-prod-dockerregistry.catalyst.net.nz/sonn/mahara-dev:trusty64-apache24-php55-postgres-firefox45

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] run_mahara_container.sh help you to run mahara container and run_mahara_tests.sh is for running behat tests.

Run mahara container

$ run_mahara_container.sh <name of container> <port> <path to mahara code> <path to mahara dataroot>

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

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