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

PDF
Building Efficient Parallel Testing Platforms with Docker
PDF
Rails Applications with Docker
PDF
Efficient Parallel Testing with Docker
PDF
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
PDF
Efficient Parallel Testing with Docker by Laura Frank
PPTX
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
PPTX
CI/CD Pipeline with Docker
PDF
DockerCon SF 2015: Enabling Microservices @Orbitz
Building Efficient Parallel Testing Platforms with Docker
Rails Applications with Docker
Efficient Parallel Testing with Docker
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
Efficient Parallel Testing with Docker by Laura Frank
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
CI/CD Pipeline with Docker
DockerCon SF 2015: Enabling Microservices @Orbitz

What's hot (20)

PDF
From Zero Docker to Hackathon Winner - Marcos Lilljedahl and Jimena Tapia
PDF
CI/CD with Docker on AWS
PPTX
Developer South Coast 2018: Docker on Windows - The Beginner's Guide
PDF
Introduction to Docker
PDF
Exploring Docker in CI/CD
PPTX
Simply your Jenkins Projects with Docker Multi-Stage Builds
PDF
Docker and the Container Revolution
PDF
Continuous Integration using Docker & Jenkins
PDF
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
PDF
Automate App Container Delivery with CI/CD and DevOps
PPTX
Developer South Coast 2018: Modernizing .NET Apps with Docker
PPTX
Jenkins, pipeline and docker
PDF
Docker for Devs - John Zaccone, IBM
PDF
Deployment Automation with Docker
PPTX
7 Habits of Highly Effective Jenkins Users
PDF
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
PPTX
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
PDF
Continuous Delivery Pipeline with Docker and Jenkins
PPTX
Docker, LinuX Container
PPTX
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
From Zero Docker to Hackathon Winner - Marcos Lilljedahl and Jimena Tapia
CI/CD with Docker on AWS
Developer South Coast 2018: Docker on Windows - The Beginner's Guide
Introduction to Docker
Exploring Docker in CI/CD
Simply your Jenkins Projects with Docker Multi-Stage Builds
Docker and the Container Revolution
Continuous Integration using Docker & Jenkins
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
Automate App Container Delivery with CI/CD and DevOps
Developer South Coast 2018: Modernizing .NET Apps with Docker
Jenkins, pipeline and docker
Docker for Devs - John Zaccone, IBM
Deployment Automation with Docker
7 Habits of Highly Effective Jenkins Users
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Continuous Delivery Pipeline with Docker and Jenkins
Docker, LinuX Container
Automated Deployment Pipeline using Jenkins, Puppet, Mcollective and AWS
Ad

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

PDF
Containerised Testing at Demonware : PyCon Ireland 2016
PPTX
Containerize your Blackbox tests
PDF
Continuous Integration Testing in Django
PDF
AWS Lambda from the trenches
PDF
DCSF 19 Building Your Development Pipeline
PDF
DCEU 18: Building Your Development Pipeline
PDF
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
PPTX
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
PPTX
Anatomy of a Build Pipeline
PDF
Comment améliorer le quotidien des Développeurs PHP ?
PPTX
DevOps, A brief introduction to Vagrant & Ansible
PDF
Serverless in production, an experience report (CoDe-Conf)
PDF
Testing as a container
PDF
Automate Thyself
PDF
Agile Bodensee - Testautomation & Continuous Delivery Workshop
PDF
DevOps Workflow: A Tutorial on Linux Containers
PPTX
Linuxing in London: Docker Intro Workshop
PDF
November 15 cloud bees clusterhq meetup fli, flockerhub, and jenkins
PDF
Troubleshooting tips from docker support engineers
PDF
Serverless in production, an experience report (Going Serverless, 28 Feb 2018)
Containerised Testing at Demonware : PyCon Ireland 2016
Containerize your Blackbox tests
Continuous Integration Testing in Django
AWS Lambda from the trenches
DCSF 19 Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
Extensible dev secops pipelines with Jenkins, Docker, Terraform, and a kitche...
Continuous Delivery with Jenkins declarative pipeline XPDays-2018-12-08
Anatomy of a Build Pipeline
Comment améliorer le quotidien des Développeurs PHP ?
DevOps, A brief introduction to Vagrant & Ansible
Serverless in production, an experience report (CoDe-Conf)
Testing as a container
Automate Thyself
Agile Bodensee - Testautomation & Continuous Delivery Workshop
DevOps Workflow: A Tutorial on Linux Containers
Linuxing in London: Docker Intro Workshop
November 15 cloud bees clusterhq meetup fli, flockerhub, and jenkins
Troubleshooting tips from docker support engineers
Serverless in production, an experience report (Going Serverless, 28 Feb 2018)
Ad

More from Laura Frank Tacho (7)

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

Recently uploaded (20)

PDF
Modernizing your data center with Dell and AMD
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Approach and Philosophy of On baking technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Machine learning based COVID-19 study performance prediction
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
A Presentation on Artificial Intelligence
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Modernizing your data center with Dell and AMD
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Advanced methodologies resolving dimensionality complications for autism neur...
Empathic Computing: Creating Shared Understanding
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Approach and Philosophy of On baking technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Machine learning based COVID-19 study performance prediction
NewMind AI Weekly Chronicles - August'25 Week I
A Presentation on Artificial Intelligence
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Agricultural_Statistics_at_a_Glance_2022_0.pdf

Stop Being Lazy and Test Your Software