laura frank
play

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


  1. Efficient Parallel Testing with Docker Laura Frank Engineer, Codeship

  2. Agenda 1. Parallel Testing Goals 2. DIY with LXC 3. Using Docker and the Docker Ecosystem

  3. Parallel Testing

  4. GOAL Create a customizable, flexible test environment that enables us to run tests in parallel

  5. Why? • Deploy new code faster • Find out quickly when automated steps fail If you’re still not sure why testing is important, please talk to me in the Codeship booth.

  6. Where? • For local testing, e.g. unit and integration tests run by a development team • On internal CI/CD systems • As part of a hosted CI/CD solution

  7. How? • Performance optimization for serial testing tasks is limited • Split up testing tasks • Run tasks in parallel Optimize the services themselves Use smart finders in integration testing (waiting vs. non-waiting finders) Use a bigger build machine

  8. TASK PARALLELISM Run tasks across multiple processors in parallel computing environments 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

  9. Distributed Task Parallelism 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

  10. Serial test execution

  11. parallel execution

  12. Goal: Shorter Feedback Cycles Spend less time waiting around for your builds to finish • Ship newest code to production faster • Be alerted sooner when tests fail • Allow multiple developers to run builds simultaneously

  13. Goal: More User Control Developers should have full autonomy over testing environments, and the way tests are executed. • Move testing commands to separate pipelines • Designate commands to be run serially or in parallel • Declare specific dependencies for each service

  14. Why not VMs? • Isolation of running builds and Codeship infrastructure • Challenges with dependency management • Not straightforward to impose resource limits • Infrastructure is underutilized which makes it expensive Distributed systems need not include containers

  15. Containers, duh! ✓ 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

  16. DIY with LXC

  17. Codeship has been powered by containers since the very beginning.

  18. 2011: A Brief History Lesson 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

  19. I should use LXC…

  20. Why LXC? • Impose resource limits • Isolation and security of customer code • Consistent build environment and experience across multiple build runs • Can programmatically automate creation and deletion We want to guarantee that - Customer code is isolated - All build runs are identical

  21. Checkbot (Codeship Classic) • Still running in production as our classic infrastructure • Well-suited for users who want 1-click test environments without much customization • Compromise ease of use for flexibility

  22. Checkbot 39K builds per day 7.8M builds per year Peak builds per day

  23. Architecture • Universal Container with provided dependencies • Run builds in isolation from one another • Implement parallel testing pattern using pipelines • Users can have N pipelines, also run in isolation during a build M*N containers in this system, but M is always 1

  24. Deployment Provider Pipeline Heroku Universal Container User Commands Capistrano AppEngine Pipeline Elastic Beanstalk Universal Container User Commands etc…

  25. Limitations • Parity between dev and test • Can’t really debug locally • No useable interface between user and container • Have to compromise ease of use for flexibility • Resource consumption is too high No easy workflow for running a customized service in a lightweight container

  26. While using straight-up LXC solved some of our technical problems, it didn’t solve any of our workflow problems.

  27. We weren’t able to provide the best, most efficient product to our customers (or ourselves)

  28. Using Docker and the Docker Ecosystem

  29. GOAL Create a customizable, flexible test environment that enables us to run tests in parallel

  30. Big Wins with Docker Even before 1.0, Docker was a clear choice • Support and tooling • Standardization • Community of motivated developers

  31. Using Docker allowed us to build a much better testing platform than with LXC alone.

  32. Codeship Jet TODO: find higher res image

  33. Codeship Jet 2.3K builds per day ~250K total builds Peak builds per day

  34. A Docker-based Testing Platform • Development started in 2014 • First beta in 2015 • Official launch February 2016

  35. A Docker-based Testing Platform Built with Docker in order to support Docker workflows

  36. Why Docker? • Docker Compose: service and step definition syntax • Docker Registry: storage for images; remote caching* • Docker for Mac and Windows: give users ability to reproduce CI environments locally

  37. Docker Compose • Provides simplicity and a straightforward interface • Developers can use existing docker-compose.yml files with Codeship • Use similar syntax for testing step definitions to get users up and running faster • Ensure parity in dev, test, and production 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

  38. The workflow tools provided by Docker are indispensable.

  39. Parallel Testing with Docker

  40. Managing containers with Docker allowed us to improve our parallel testing workflow

  41. A New Parallel Workflow • Loosen coupling between steps and services — execute N steps against M services • Parallel and serial steps can be grouped and ordered in any way • Introducing services adds additional layer of flexibility N*M is still true but we don’t control for M anymore

  42. Services • Pull image from any registry or build from Dockerfile • Optimize service for testing tasks • Fully customizable by the user Components of the app are expressed as services Multiple services is the biggest change between Checkbot and Jet

  43. Steps • Each step is executed in an independent environment • Can be nested in serial and parallel groups • Two functions • Run: execute a command against a service • Push: push image to registry • Tag regex matching to run steps on certain branches Tasks are expressed as steps

  44. T 1 T 1 T 1 Pipeline Pipeline Pipeline Universal Container Universal Container Universal Container User Commands User Commands User Commands Different from having one testing service with multiple pipelines Enabled by engine (Dockerfiles/links), Registry, Compose

  45. T 1 T 2 T 3 Step web Step Step command postgres postgres web web redis redis command command Step postgres web redis command Different from having one testing service with multiple pipelines Enabled by engine (Dockerfiles/links), Registry, Compose

  46. codeship-services.yml db: image: postgres:9.5 app: encrypted_dockercfg_path: dockercfg.encrypted build: image: user/some-image dockerfile: Dockerfile.test cached: true links: - db deploy: encrypted_dockercfg_path: dockercfg.encrypted build: dockerfile: Dockerfile.deploy quick explanation of YAML for those who are not familiar

  47. codeship-steps.yml - service: deploy - type: serial type: push steps: image_name: rheinwein/notes-app - type: parallel tag: ^master$ steps: registry: https://index.docker.io/v1/ - name: rspec encrypted_dockercfg_path: dockercfg.encrypted service: app command: bin/ci spec - name: rubocop service: app command: rubocop - name: haml-lint service: app command: haml-lint app/views - name: rails_best_practices service: app command: bin/railsbp

  48. Serial Steps • Maintain order within CI process • A failing step will stop and fail the build, and prevent any other steps from executing • Only one serial step or step group can execute at a time

  49. Parallel Steps • Optimize groupings for speed • First-to-fail will stop and fail build • It’s possible for other steps to be running while a failing step is also running

  50. Pro Tip: Your push step should never be part of a parallel step group.

  51. Demo!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend