SlideShare a Scribd company logo
Stop Being Lazy and Test Your Software!
Laura Frank
Software Engineer, Codeship
0.7.0
ImageLayers
Panamax
Berlin
Agenda
Continuous Delivery
Why Do We Test?
Testing with Docker Compose
Faster Testing with Docker
Why Do We Test?
Motivations and frustrations
Testing software has been
a practice since the very
first machines were used
for computing.
Stop Being Lazy and Test Your Software
The women who
programmed the ENIAC to
calculate trajectories
periodically checked the
results with a correct,
hand-computed table.
working software
in production
testing
code reviews
version control
pair programming
high-availability architecture
Motivators
Update application without breaking things!
Validate functionality of updates
Be able to trust deployment checks (in CI/CD workflow)
Confirm that refactoring didn’t break existing functionality
Why do you skip tests?
45%
15%
5%
35% Too slow to run suite 35%
Annoying extra step 15%
Don’t see the point 5%
Slows down deployment 45%
10
Frustrators
It takes me an hour to write a single test
My new tests just duplicate existing coverages so there’s no
point (integration overlapping with unit)
My suite fails all the time for no apparent reason…?
It takes my test suite over 20 minutes to run, so I don’t run it
locally
Testing distracts me from my normal development workflow
Setting up a testing environment is a huge pain
It takes too long to deploy when I have a huge test suite
Frustrators
It takes me an hour to write a single test
My new tests just duplicate existing coverages so there’s no
point (integration overlapping with unit)
My suite fails all the time for no apparent reason…?
It takes my test suite over 20 minutes to run, so I don’t run it
locally
Testing distracts me from my normal development workflow
Setting up a testing environment is a huge pain
It takes too long to deploy when I have a huge test suite
Using Docker can alleviate
some frustrations
associated with testing.
Testing with Docker
Compose
It’s easy, I promise
Docker and testing are a great pair.
❌ ✔
With Docker Compose, it is incredibly
easy to create consistent,
reproducible environments.
❌ ✔
Many of us already use
Docker Compose to set
up dev environments.
…But we stop there.
Use your Docker Compose
environment for testing
as well.
app:
build: .
command: rails server -p 3000 -b '0.0.0.0'
volumes:
- .:/app
ports:
- '3000:3000'
links:
- postgres
postgres:
image: postgres:9.4
A simple Rails app
?!
git clone && docker-compose up
hackity hack
How do I make tests happen?
Development workflow
app:
build: .
command: rails server -p 3000 -b '0.0.0.0'
volumes:
- .:/app
ports:
- '3000:3000'
links:
- postgres
postgres:
image: postgres:9.4
A simple Rails app
app:
build: .
command: rspec spec
volumes:
- .:/app
ports:
- '3000:3000'
links:
- postgres
postgres:
image: postgres:9.4
A simple Rails app
Stop Being Lazy and Test Your Software
In most cases, we need to
do a bit of setup
before running tests.
You might even need a
different Dockerfile.
Docker Compose makes this easy
app:
build: .
dockerfile: Dockerfile.test
command: rake test
volumes:
- .:/app
🚨 A word of warning! 🚨
🚨 Race conditions! 🚨
You can also run one-off
commands against a service
with Docker Compose.
docker-compose run -e "RAILS_ENV=test" 
app rake db:setup
docker-compose run -e "RAILS_ENV=test" 
app test-command path/to/spec.rb
docker-compose up #-d if you wish
Usual Docker Compose development
environment
Run rake task to set up db
Then run tests against Docker services
Additional Docker Compose Testing
Config Options
environment:
RACK_ENV: test
Additional Docker Compose Testing
Config Options
$ docker-compose up -d
$ ./run_tests
$ docker-compose stop
$ docker-compose rm –f
Docker delivers a
predictable, reproducible
testing environment. Period.
Continuous Integration,
Testing, and Docker
Fail fast and not in production!
Continuous integration and
testing go hand in hand.
👯
Stop Being Lazy and Test Your Software
Stop Being Lazy and Test Your Software
Relying on CI/CD without
adequate test coverage
is not a great idea.
Would you rather…
✔
💩
Find out your code is broken by
seeing a failed run of your CI/CD
system?
Find out your code is broken by
seeing 500s on 500s on 500s in
production?
What about running tests
like this…
…inside a container?
Stop Being Lazy and Test Your Software
We run our unit tests in a
conatiner during development,
so we should do that during
deployment too, right?
And if we’re running our
services in containers
during development,
they should be running
in containers in
production, right?
🚨 A word of warning! 🚨
—JérômePetazzoni
“Docker-in-Docker is not
100% made of sparkles,
ponies, and unicorns.
46
Docker in Docker
CAUTION!
YMMV
See https://jpetazzo.github.io
- Mixing file systems == bad time
- Shared build cache == bad time
- Lots of other stuff == bad time
Shared daemon – what we really want
We get this by binding the
Docker socket.
Parallel Testing with
Docker
Break it up.
Why do you skip tests?
45%
15%
5%
35% Too slow to run suite 35%
Annoying extra step 15%
Don’t see the point 5%
Slows down deployment 45%
52
When developing, it’s easy
to think of a container as
a small VM that runs a
specific workload.
✔
But if we change our thinking
to treat containers as just
processes, then we can do
some pretty cool stuff.
✔
A syntax similar to Docker Compose for
service definition…
57
web:
build:
image: my_app
dockerfile_path: Dockerfile
links:
- redis
- postgres
redis:
image: redis
postgres:
image: postgres
And use it to also define testing steps…
58
- type: parallel
steps:
- service: demo
command: ruby check.rb
- service: demo
command: rake teaspoon suite=jasmine
- service: demo
command: rake test
- type: parallel
steps:
- service: demo
command: some-test-command
- service: demo
command: another-test-command
- service: demo
command: yet-another-test-command
Each step is run independently in
a container
59
- service: demo
command: some-test-command
- service: demo
command: another-test-command
- service: demo
command: yet-another-test-command
And each container may be located in a
range of availability zones
60
Test compose context
Test runner
jet
test-1
test-0
test-3
Docker makes this possible by
providing the means to create
a predictable, reproducible
testing environment.
Super Cool Tip™
Because quality is everyone’s problem.
Add an additional
pipeline to fail builds if
quality decreases.
Two good examples are
code coverate and
linting errors.
#!/bin/bash
set –e
ALLOWED_WARNINGS=100 #some arbitrary threshold
warnings=`grep "offenses detected" rubocop.txt | cut -d " " –f4`
if [ $warnings -gt $ALLOWED_WARNINGS ]
then
echo -e "033[31mallowed warnings $ALLOWED_WARNINGS033[0m"
echo -e "033[31mactual warnings $warnings033[0m"
echo -e "033[31mToo many rubocop warnings033[0m"
echo -e "033[31mTry running 'bin/check_rubocop_against_master’033[0m"
exit 1
else
echo $warnings/$ALLOWED_WARNINGS is close enough ಠ_ಠ
exit 0
fi
✔
✔
❌
❌
—Solomon(moreorless)
“Improving quality is a
lot of unglamourous
work that really adds up.”
68
Resources
#keepshipping
Highly recommended talks about development, testing,
and lots of interesting stuff: https://speakerdeck.com/searls
Ruby gem for parallel tests: grosser/parallel_tests
Parallel Docker testing: Jet (from Codeship)
CI/CD with Docker: http://pages.codeship.com/docker
Running commands with Docker Compose:
http://docs.docker.com/compose
The perils of Docker-In-Docker: https://jpetazzo.github.io
This talk: slideshare.net/rheinwein
—EdsgerDijkstra
“Testing can be a very
effective way to show the
presence of bugs, but is
hopelessly inadequate for
showing their absence.”
71
Testing does not
guarantee that
our software works.
We test to know
when our software is
definitely broken.
Work harder to know
when you’re wrong.
Thank you!
Laura Frank
@rhein_wein
laura@codeship.com

More Related Content

What's hot (20)

PDF
From Zero Docker to Hackathon Winner - Marcos Lilljedahl and Jimena Tapia
Docker, Inc.
 
PDF
CI/CD with Docker on AWS
Hart Hoover
 
PPTX
Developer South Coast 2018: Docker on Windows - The Beginner's Guide
Elton Stoneman
 
PDF
Introduction to Docker
Jirayut Nimsaeng
 
PDF
Exploring Docker in CI/CD
Henry Huang
 
PPTX
Simply your Jenkins Projects with Docker Multi-Stage Builds
Eric Smalling
 
PDF
Docker and the Container Revolution
Romain Dorgueil
 
PDF
Continuous Integration using Docker & Jenkins
B1 Systems GmbH
 
PDF
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
Steffen Gebert
 
PDF
Automate App Container Delivery with CI/CD and DevOps
Daniel Oh
 
PPTX
Developer South Coast 2018: Modernizing .NET Apps with Docker
Elton Stoneman
 
PPTX
Jenkins, pipeline and docker
AgileDenver
 
PDF
Docker for Devs - John Zaccone, IBM
Docker, Inc.
 
PDF
Deployment Automation with Docker
Egor Pushkin
 
PPTX
7 Habits of Highly Effective Jenkins Users
Jules Pierre-Louis
 
PDF
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
Docker, Inc.
 
PPTX
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
PDF
Continuous Delivery Pipeline with Docker and Jenkins
Camilo Ribeiro
 
PPTX
Docker, LinuX Container
Araf Karsh Hamid
 
PPTX
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Bamdad Dashtban
 
From Zero Docker to Hackathon Winner - Marcos Lilljedahl and Jimena Tapia
Docker, Inc.
 
CI/CD with Docker on AWS
Hart Hoover
 
Developer South Coast 2018: Docker on Windows - The Beginner's Guide
Elton Stoneman
 
Introduction to Docker
Jirayut Nimsaeng
 
Exploring Docker in CI/CD
Henry Huang
 
Simply your Jenkins Projects with Docker Multi-Stage Builds
Eric Smalling
 
Docker and the Container Revolution
Romain Dorgueil
 
Continuous Integration using Docker & Jenkins
B1 Systems GmbH
 
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
Steffen Gebert
 
Automate App Container Delivery with CI/CD and DevOps
Daniel Oh
 
Developer South Coast 2018: Modernizing .NET Apps with Docker
Elton Stoneman
 
Jenkins, pipeline and docker
AgileDenver
 
Docker for Devs - John Zaccone, IBM
Docker, Inc.
 
Deployment Automation with Docker
Egor Pushkin
 
7 Habits of Highly Effective Jenkins Users
Jules Pierre-Louis
 
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
Docker, Inc.
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
Continuous Delivery Pipeline with Docker and Jenkins
Camilo Ribeiro
 
Docker, LinuX Container
Araf Karsh Hamid
 
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Bamdad Dashtban
 

Similar to Stop Being Lazy and Test Your Software (20)

PDF
Containerised Testing at Demonware : PyCon Ireland 2016
Thomas Shaw
 
PPTX
Containerize your Blackbox tests
Kevin Beeman
 
PDF
Continuous Integration Testing in Django
Kevin Harvey
 
PDF
AWS Lambda from the trenches
Yan Cui
 
PDF
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
PDF
DCEU 18: Building Your Development Pipeline
Docker, Inc.
 
PDF
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Richard Bullington-McGuire
 
PPTX
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Борис Зора
 
PPTX
Anatomy of a Build Pipeline
Samuel Brown
 
PDF
Comment améliorer le quotidien des Développeurs PHP ?
AFUP_Limoges
 
PPTX
DevOps, A brief introduction to Vagrant & Ansible
Arnaud LEMAIRE
 
PDF
Serverless in production, an experience report (CoDe-Conf)
Yan Cui
 
PDF
Testing as a container
Irfan Ahmad
 
PDF
Automate Thyself
Ortus Solutions, Corp
 
PDF
Agile Bodensee - Testautomation & Continuous Delivery Workshop
Michael Palotas
 
PDF
DevOps Workflow: A Tutorial on Linux Containers
inside-BigData.com
 
PPTX
Linuxing in London: Docker Intro Workshop
Elton Stoneman
 
PDF
November 15 cloud bees clusterhq meetup fli, flockerhub, and jenkins
Ryan Wallner
 
PDF
Troubleshooting tips from docker support engineers
Docker, Inc.
 
PDF
Serverless in production, an experience report (Going Serverless, 28 Feb 2018)
Domas Lasauskas
 
Containerised Testing at Demonware : PyCon Ireland 2016
Thomas Shaw
 
Containerize your Blackbox tests
Kevin Beeman
 
Continuous Integration Testing in Django
Kevin Harvey
 
AWS Lambda from the trenches
Yan Cui
 
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
DCEU 18: Building Your Development Pipeline
Docker, Inc.
 
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Richard Bullington-McGuire
 
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Борис Зора
 
Anatomy of a Build Pipeline
Samuel Brown
 
Comment améliorer le quotidien des Développeurs PHP ?
AFUP_Limoges
 
DevOps, A brief introduction to Vagrant & Ansible
Arnaud LEMAIRE
 
Serverless in production, an experience report (CoDe-Conf)
Yan Cui
 
Testing as a container
Irfan Ahmad
 
Automate Thyself
Ortus Solutions, Corp
 
Agile Bodensee - Testautomation & Continuous Delivery Workshop
Michael Palotas
 
DevOps Workflow: A Tutorial on Linux Containers
inside-BigData.com
 
Linuxing in London: Docker Intro Workshop
Elton Stoneman
 
November 15 cloud bees clusterhq meetup fli, flockerhub, and jenkins
Ryan Wallner
 
Troubleshooting tips from docker support engineers
Docker, Inc.
 
Serverless in production, an experience report (Going Serverless, 28 Feb 2018)
Domas Lasauskas
 
Ad

More from Laura Frank Tacho (7)

PDF
The Container Shame Spiral
Laura Frank Tacho
 
PDF
Using Docker For Development
Laura Frank Tacho
 
PDF
Deploying a Kubernetes App with Amazon EKS
Laura Frank Tacho
 
PDF
Scalable and Available Services with Docker and Kubernetes
Laura Frank Tacho
 
PDF
SwarmKit in Theory and Practice
Laura Frank Tacho
 
PDF
Everything You Thought You Already Knew About Orchestration
Laura Frank Tacho
 
PDF
Happier Teams Through Tools
Laura Frank Tacho
 
The Container Shame Spiral
Laura Frank Tacho
 
Using Docker For Development
Laura Frank Tacho
 
Deploying a Kubernetes App with Amazon EKS
Laura Frank Tacho
 
Scalable and Available Services with Docker and Kubernetes
Laura Frank Tacho
 
SwarmKit in Theory and Practice
Laura Frank Tacho
 
Everything You Thought You Already Knew About Orchestration
Laura Frank Tacho
 
Happier Teams Through Tools
Laura Frank Tacho
 
Ad

Recently uploaded (20)

PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 

Stop Being Lazy and Test Your Software