Skip to content

How to write a Testfile

surya saini edited this page Jan 15, 2019 · 2 revisions

How to write a Testfile

PR-Mod uses prmod/base-image for setting up an isolated environment that is provided to every application that is being deployed on the PR-Mod server.

Each instance of prmod/base-image provides docker, docker-compose installed.

Other dependencies also installed in the environment are curl, wget, zip, git, pip.

Any executable command comprising of the above dependencies can be included in the Testfile.

Commands Supported By Testfile

  • PORT : Where you can the mention Port, using which host interacts with prmod\base-image. Example, assume in your application's docker compose 8088 port is mapped to 80, hence in PORTS cmd we mention 8088 which is mapped to randomly selected free port on the Host machine. Thus creating a link for the tcp\ip port 80.

  • VOL: Space separated list of Volumes to mount inside the prmod\base-image container.

  • CWD : Specify the working directory inside the docker container.

  • GIT : Currently only git clone command is supported inside the Testfile.

  • SHELL : Executable shell commands that will run on tty inside the docker contianer.

  • DOCKER : Commands supported by docker and docker compose are also supported by PR-Mod and can be included in Testfile.

Demo Testfile

# DEMO TESTFILE TO TEST PR-MOD

# Port with which `docker:dind` interacts with app
PORTS 8088/tcp

# Volume mount path inside `docker:dind`
VOL /<repo-name>

# Working directory to ssh inside `docker:dind`
CWD /<current working dir>

# Clone abc code from github
GIT git clone https://github.com/USER/abc.git .

# Execute a shell cmd 
SHELL cp -r ../<dir> .

# Build apache image
DOCKER docker build --file apache/Dockerfile --tag apache-abc .

# Run docker-compose
DOCKER docker-compose up -d

# Build app abc
DOCKER docker exec -it abc /bin/bash /scripts/build.sh