SlideShare a Scribd company logo
1 of 33
Reach Production
Faster with Containers
in Testing
David Xia
Spotify’s Scale
• 150+ people in infrastructure
• Thousands of hosts,
2000+ running containers
• 1500+ deploys in past month,
majority were containers
About David Xia
• Work on deployment infrastructure
• Work on open-source Docker orchestration tool Helios
Prerequisites for This Talk
• You’re familiar with containers
• You like tests
• That’s it!
Prerequisites for This Talk
You don’t need to use containers in
production for this talk to be useful!
Three Problems, Three Ways to Solve with Containers
How can I enable developers to:
• catch container misconfiguration in tests?
• easily install and start non-trivial test dependencies?
• make their tests isolated and reproducible?
“Why did my service pass
integration tests but fail when
I deployed it as a container?”
- Sad Developer 1
Problem 1: Container Misconfiguration
Problem 1: Container Misconfiguration
Solution 1: Container Misconfiguration
“I want to run my project's
integration tests locally. The tests
need a local Cassandra/other
DB. How do I set everything up?”
- Sad Developer 2
Problem 2: Non-trivial dependencies
Problem 2: Non-trivial dependencies
docker run --name foo -d cassandra
- Happy Developer 2
Solution 2: Non-trivial dependencies
Solution 2: Non-trivial dependencies
“How can I easily restore
my test dependencies to
a clean state?”
- Sad Developer 3
Problem 3: Reproducible Tests
docker stop <container ID>
docker run --name foo -d cassandra
- Happy Developer 3
Solution 3: Reproducible Tests
Key Takeaways - Using Containers in Tests Can Help
You:
• Test more of the stack in an env
resembling production
• Easily start real dependencies
• Ensure tests are reproducible
and isolated
Helios in a Nutshell
How helios-testing
was born
• multitenancy
• docker
• container orchestration (helios)
• container testing framework (helios-testing)
What does helios-testing do?
Let’s you write code to start and stop containers.
What does helios-testing do?
Let’s you write code to start and stop containers.
What does helios-testing do?
Let’s you write code to start and stop containers.
Demo! Solution 1: Container Configuration
https://www.youtube.com/watch?v=iWtTFI9zDfk
Demo! Solution 2: Isolated Tests
https://www.youtube.com/watch?v=GInAJSMd9cs
“Testing with a
Cassandra container is
the closest I can get to
testing against Cassandra
in reality.”
Successes
“I especially like the fact that I
can test my image in its final
state and be confident that it
will work in production.”
Successes
“Using helios-testing to run datastores in
containers has made the tests portable
and setup free (by setup I mean no
manual installation of the datastore on
the test machine or locally).”
Successes
Make sure your testing framework and
infrastructure are fast and reliable.
Lessons Learned
Make framework’s interface and implementation as
simple as possible.
Lessons Learned
Provide great test examples.
Lessons Learned
Key Takeaways - Using Containers in Tests Can Help
You:
• Test more of the stack in an env
resembling production
• Easily start real dependencies
• Ensure tests are reproducible
and isolated
When Not to Use Containers in
Tests
• Don’t test functionality unrelated
to containers that you can easily
test separately
• When your container-based tests
overlaps a lot with regular
integration tests
Acknowledgements
Rohan Singh
Matt Brown
Staffan Gimåker
Mats Linander
Nic Cope
Q&A
@davidxia_
github.com/davidxia
github.com/spotify/helios
github.com/davidxia/qcon-demo
Demo videos: example 1 and 2
helios-testing

More Related Content

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

QCon NYC 2016: Reach Production Faster with Containers in Testing

Editor's Notes

  1. early days, tech infrastructure was one small team then Spotify grew [next] today: 100+M users, 30+M subscribers, 55+ countries needed more robust infra, tools, and shared services Infra team grew and split into different teams with different responsibilities [next] Has over 150 people today [next] Help backend devs maintain thousands of hosts We optimize for speed in iterating on product several years ago, we realized we needed to implement and improve CI/CD practices [next] today: over 1500 deploys last month, most were containers
  2. There are very few prereqs for this talk bc concepts are broadly applicable to variety of tools and technologies Poll audience Raise your hand if you’re familiar with containers or Docker. Raise hand if you like tests [familiar with containers] [like tests] #3…[that’s it!] There’s no more pre-reqs [drawing] Tests I’m talking are high level and test overall behavior of a service can be considered more high level than ITs
  3. Raise hand if you use containers in dev testing prod very important [You don’t even need to be using containers in prod for this talk to be useful]
  4. this talk is from POV of devops team talk addresses “How can I create tools to make other devs’ jobs easier?”
  5. [Why did my tests pass…?] [sad dev 1] poll audience, who’s had this problem? bc of mistake in how container was configured to run Bad entrypoint or command Missing file mount Port not exposed weird edge case: Service jar inside container couldn’t start bc maven shade plugin left out a dependency due to setting minimizeJar to true
  6. in this case, dev forgot to expose the port for the service in the container config [explain drawing]
  7. solution was to deploy service + container during IT exactly as it would be deployed for prod We start the container itself exactly as how it will be started at deployment time. Less surprises note that tests are running from outside the container not inside it
  8. imagine a service that talks to cassandra, you want to write an integration test cassandra in this case is a test dependency you’ll inevitably run into this question: [How do I install cassandra?] poll audience
  9. not that easy to do especially for someone who has never set it up before googling, trial and error, banging head against the wall
  10. just docker run! [next] Docker makes installing and starting Cassandra easy Platform independent
  11. poll audience
  12. just stop and start a new instance of the container. Easy!
  13. [Test more of the stack in an env resembling production] if your service is running inside a container in prod, you are testing the container part works as well Ensure configuration is correct [Use containers to easily start real dependencies] Datastores like cassandra and web servers like nginx are a hassle to install and start Containers cut out the work of people figuring out how to install on different platforms no more snowflake testing machines that no one remembers how to setup Don’t have to run `docker` commands. Can provide testing framework that lets users write code to start and stop dependencies [reproducible and isolated] to start with a fresh dependency, just drop the container and start a new one special case: Can have mock data if you bake it into the image. It’s easy to reset it to the original mock data
  14. I’ll walk through high level design of Helios A helios job is a docker image with configuration for how to run it like ports, volumes, etc [next] (talk about it)
  15. helios-testing resulted from what Spotify needed at various times In the beginning, we were running one instance of a service per host. Wasteful but conscious choice since Spotify optimized for speed over costs. [multitenancy] We wanted to be more efficient and save money [docker] We wanted isolation between service instances. Saw Docker as a path to this goal. [container orchestration] We needed this and wrote our own since open-source tools didn’t exist yet Spotify optimizes for speed instead of cost-savings so multi tenancy goal never became top priority. What did become a top priority was faster, more frequent, and automated releases. As a result, we needed great test coverage that built confidence for frequent releases Using Docker helped achieve CI/CD goal because of provided immutability of artifacts. Wanted hosts to be cattle not pets. [container testing framework] Our devs needed a way to test their helios jobs
  16. [let’s you write code to start and stop containers] Take the example of our three problems problem 1 was where port wasn’t exposed and this wasn’t caught in ITs bc we didn’t test the container [helios testing starts the service in a container and then runs the test]
  17. problem 2 was where it was hard to start a test dependency like cassandra on OS X [helios-testing allows you to easily start the cassandra container, then the service (which doesn’t have to be in container), then run the test]
  18. problem 3 was where it was hard to restore test dependency to clean state for next test [just stop the cassandra container, then start a new instance, then run next test] helios-testing is java bc most of company writes java integrated with JUnit because we mostly use JUnit as test framework
  19. These are real quotes from Spotify backend devs
  20. [quote] local testing much harder with complex deps. it just won't happen. helios-testing enabled devs to run tests on laptops before committing and submitting a PR that’d take up a slot in build queue faster feedback, less resources used up no prompting or asking leading questions their off-the-top-of-their-head answers are really close to the key takeaways I spent days thinking how to phrase
  21. [fast and reliable] Networking between remote CI cluster and office networks or docker registry was sometimes flakey and slow this frustrated our users by slowing them down
  22. [interface simple as possible] helios-testing is complex and we spent lots of time on support when users threw their hands in the air bc of complexity Make it easy to troubleshoot otherwise, you’ll spend a lot of time debugging people’s tests Have clear and concise error messages Easy to find logs Relevant logs are those from Docker daemon and Docker containers One idea for making them easily accessible: test framework collects relevant parts of those logs and organize them in an obvious place
  23. [provide great test examples] We had a template that included a very simple test for them, but they never added more Provide images for commonly used dependencies Don’t do these and you’ll incentivize people to delete their tests which is bad
  24. [just read the bullet points to drill home the takeaways]
  25. Disadvantages of container-based tests tests take longer to run More infrastructure has to be available, e.g. image registry More layers to that can potentially break; and then devs have to debug these layers (more cognitive load) What’s the division between non-container tests and container tests? Container tests have more overhead [Don’t test functionality unrelated to containers that you can easily test separately] use them to test things that you couldn’t test with regular integration tests (e.g. realish deps) Test that the container comes up and is configured correctly and can respond to a request that’s representative of what its main purpose [When your container-based tests overlaps a lot with regular integration tests ] Minimize redundancy between container tests and what could simply be covered by regular integration tests
  26. Sangeeta Narayanan (a QCon organizer and Netflix engineering director) Wesley Reisz (QCon Product Manager && Community Advocate) Harry Brumleve (QCon committee member)