TESTING AS A
CONTAINER
DOCKER WITH AND
SELENIUM & FRIENDS TO
SHIP FAST
Irfan Ahmad
@critickerr
SOON AFTER THIS TALK ….
power lies in packaging
OUTLINE
▸Why? - Challenges
▸What? - Containers
▸How? - Testing in Containers
▸Really? -See Demo
▸Next? - Try Hands On Example
CHALLENGES :
TESTING AND
DELIVERY
WHY WE FAIL TO TEST?
45%
15% 5%
35%
▸ Slow-down
deployments
▸ Slow test and setup
▸ Ineffective tests
▸ Not needed
▸ * All of these challenges are linked to
infrastructure underlying tests.
MATRIX FROM HELL - SHIP GOODS?
MATRIX FROM HELL - SHIP SOFTWARE?
CONATINERS
AN APPLICATION, PLUS ALL ITS
DEPENDENCIES, LIBRARIES AND
OTHER BINARIES, AND
CONFIGURATION FILES NEEDED
TO RUN IT, BUNDLED INTO ONE
PACKAGE.
WHAT ARE CONTAINERS?
AN ENTIRE ISOLATED PORTABLE
RUNTIME ENVIRONMENT
DOCKER
▸ Docker is an open platform for developers and
sysadmins to build, ship, and run distributed
applications.
INSIDE DOCKER
▸ Docker Image :static snapshot of the containers’
configuration.
▸ Docker Engine: a lightweight runtime and
robust tooling that builds and runs your Docker
containers.
▸ Docker Registry :a repository of images
DOCKER HUB
CONTAINERS VS VM
HOW COMPONENTS FITS TOGETHER
DOCKER LIFECYCLE
HOW DOCKER WORKS
DOCKER RUN
DOCKER LOOKS
FOR LOCAL
IMAGES
IS IT INSTALLED
DOCKER LOOKS
REGISTRY FOR
IMAGES
NO
IS IT AVAILABLE
DOCKER
DOWNLOADS THE
IMAGE
IMAGE
INSTALLED
LOCALLY
DOCKER
CREATES NEW
CONTAINER AND
STARTS
PROGRAM
CONTAINER IS
RUNNING
YES
DOCKERFILE
▸ configuration file with build instructions for
Docker images
DOCKER-COMPOSE
▸ Compose is a tool for defining and running
multi-container Docker applications
DEMO
https://www.youtube.com/watch?v=kXlS69PXX68
PRE-REQUISITES
▸ virtual-box
▸ download docker
toolbox
▸ https://
www.docker.com/
products/docker-
toolbox
VOTING APP : APP UNDER TEST
▸ Simple Real Time voting app
▸ Runs with Docker Compose and multiple
containers in network
VOTING APP : COMPONENTS
Deliver Below Test as Container to Test Voting App Docker
Image
1.API
2.Web
3.Web with Selenium Grid
PROBLEM STATEMENT
TESTING:
IN CONTAINERS,
ON CONTAINERS
DOCKERS ANSWERS TO TESTING CHALLENGES
Problem Solution
Automation Dockerfile for setup
Agility &
Reliability
Ship and Share Images
DevOps Infrastructure as Code
Scale Docker Compose
Tools
Diversity
Docker support by and
from vendors.
DOCKER - HANDS ON
‣ clone https://github.com/irfanah/teststack
docker-compose up #for starting example-web app
‣ To run any test inside docker containers
‣ rake docker["api"] #for api tests
‣ rake docker["web"] #web tests on headless browse
‣ rake docker["webapp"] #web tests on selenium grid
BEST PRACTICES
▸ Ship Images , not just code
▸ One container one process
▸ Add only Required packages
▸ Group common operations
▸ Use Specific tags with Images
TRY A SIMPLE CI WORKFLOW
Q
&
A
THANK
YOU
Open Sourced - For Hands On
Github
https://github.com/irfanah/TestStack
https://github.com/irfanah/example-voting-app
Docker hub
https://hub.docker.com/u/irfanah/
IRFAN AHMAD
Email irfan@critick.io
Web http://critick.io
Twitter @critickerr

Testing as a container