Efficient Parallel Testing with Docker
Laura Frank
Engineer, Codeship
Laura Frank Engineer, Codeship Agenda 1. Parallel Testing Goals - - PowerPoint PPT Presentation
Efficient Parallel Testing with Docker Laura Frank Engineer, Codeship Agenda 1. Parallel Testing Goals 2. DIY with LXC 3. Using Docker and the Docker Ecosystem Parallel Testing GOAL Create a customizable, flexible test environment that
Efficient Parallel Testing with Docker
Engineer, Codeship
GOAL
If you’re still not sure why testing is important, please talk to me in the Codeship booth.
by a development team
limited
Optimize the services themselves Use smart finders in integration testing (waiting vs. non-waiting finders) Use a bigger build machine
TASK PARALLELISM
parallel task assignment in heterogeneous distributed computing systems is totally a thing, I promise heterogeny is enabled by containerization hardware specs are all but irrelevant here
A distributed system of containerized computing environments takes the place of a single multiprocessor machine A container is a process, not a small VM
The introductory way of thinking that a container is just a lightweight VM needs to be replaced with a more accurate depiction of a container as a process Distributed computing with containers can’t evolve with Container:VM mapping
Serial test execution
parallel execution
Spend less time waiting around for your builds to finish
Developers should have full autonomy over testing environments, and the way tests are executed.
Distributed systems need not include containers
✓ Impose resource limits and utilize infrastructure at higher
capacity
✓ Isolation and security of customer code ✓ Consistent build environment across many build runs ✓ Enable simultaneous testing jobs
We want a separation of Codeship infrastructure and customer builds Easier and more cost effective to introduce multi-processor build configurations to enable parallelism
Flowing salty water on Mars International Year of Forests Preparations for 12.04 Precise with LXC improvements Codeship was founded Green Bay Packers won Super Bowl XLV
MRO — first initial photographic evidence of salty water (was confirmed later in the year) Precise shipped in early 2012
I should use LXC…
across multiple build runs
deletion
We want to guarantee that
infrastructure
environments without much customization
Peak builds per day
during a build
M*N containers in this system, but M is always 1
User Commands Universal Container Pipeline User Commands Universal Container Pipeline Heroku Deployment Provider Capistrano AppEngine Elastic Beanstalk etc…
No easy workflow for running a customized service in a lightweight container
GOAL
Even before 1.0, Docker was a clear choice
TODO: find higher res image
Peak builds per day
reproduce CI environments locally
with Codeship
users up and running faster
Reuse of docker-compose.yml file is possible but typically not optimal Basic idea: reuse of services in dev, test, production Reduce barrier of entry
execute N steps against M services
in any way
N*M is still true but we don’t control for M anymore
Components of the app are expressed as services Multiple services is the biggest change between Checkbot and Jet
Tasks are expressed as steps
User Commands Universal Container Pipeline User Commands Universal Container Pipeline User Commands Universal Container Pipeline
T1 T1 T1
Different from having one testing service with multiple pipelines Enabled by engine (Dockerfiles/links), Registry, Compose
Step
postgres redis command web
Step
postgres redis command web
Step
command web
Step
postgres redis command web
T1 T2 T3
Different from having one testing service with multiple pipelines Enabled by engine (Dockerfiles/links), Registry, Compose
db: image: postgres:9.5 app: encrypted_dockercfg_path: dockercfg.encrypted build: image: user/some-image dockerfile: Dockerfile.test cached: true links:
deploy: encrypted_dockercfg_path: dockercfg.encrypted build: dockerfile: Dockerfile.deploy
quick explanation of YAML for those who are not familiar
steps:
steps:
service: app command: bin/ci spec
service: app command: rubocop
service: app command: haml-lint app/views
service: app command: bin/railsbp
type: push image_name: rheinwein/notes-app tag: ^master$ registry: https://index.docker.io/v1/ encrypted_dockercfg_path: dockercfg.encrypted
any other steps from executing
time
failing step is also running
/codeship.com/ documentation/docker/installation/
Totally cool, Docker Toolbox also rocks
I’m demoing using Docker for Mac (I’ll have a docker machine backup, as well as a video of my demo) Users not running on Linux are able to locally test and debug in an environment identical to CI
Build allocation
machines
process
Image Caching
and then a rebuild of the service image used the cache
Image Caching
when you save the images via docker save
¯\_()_/¯
service
future
for us
TL;DR