SlideShare a Scribd company logo
Making SoundCloud’s µ-services safe(r) to deploy
Move Fast and Consumer-Driven-
Contract-Test Things
XP Days Ukraine 2017
2.5 years @ SoundCloud Monetization Team Backend Engineer
@alonpeer
About SoundCloud
a cloud full of sounds
135M tracks, 175M listeners, 12 hours/minute
300+ services / 50+ teams
Agenda
● Testing, monolith style
● My first steps @ SoundCloud
● Introducing contract tests
● Pactifying our services
● Caveats
● QA Q&A
Testing, monolith style
● One service, one client
● API changes are easy
● One client team to sync with for migrations
● API deprecation is easy
Testing, monolith style
The good ol’ days
● Different requirements per client
=> Code complexity increases
● Harder to deploy without breaking at least one client
Testing, monolith style
Mo clients, mo problems
● More manual QA
expensive, slow, prone to human error,
doesn’t scale
● More end-to-end tests
Maintenance nightmare, flaky, slow,
creates bottlenecks
Testing, monolith style
Mo clients, mo problems
My first steps @ SoundCloud
My first steps @ SoundCloud
Whoa, micro-services
My first steps @ SoundCloud
Testing strategy
E2E
Unit
Integration
My first steps @ SoundCloud
Digging into post-mortems
© ofsmallthings
My first steps @ SoundCloud
“A lack of trust in the acceptance tests caused us to largely
ignore the warnings they generated.”
“We couldn’t figure out the impact of the broken acceptance
tests, and assumed the only problem was the tests themselves,
rather than the underlying code.”
“The commit went through as there weren't any tests for
the serialisation from the client to the backend.”
Digging into post-mortems
© ofsmallthings
Introducing contract tests
Introducing contract tests
My daily routine
© LockeSteerpike
Introducing contract tests
My daily routine
© rickandmorty.com
Unit tests are not enough
Introducing contract tests
“#cake” >> {
result = call(“cake”)
assert(result == “lie”)
}
GET “/cake”:
return “lie”
Unit tests are not enough
Introducing contract tests
GET “/cake”:
return “truth”
“#cake” >> {
result = call(“cake”)
assert(result == “lie”)
}
Unit tests are not enough
Introducing contract tests
import JsonLibFoo
GET “/cake”:
return toJson(current_state)
// { “current_state” : “lie” }
import JsonLibFoo
“#cake” >> {
result = fromJson(call(“cake”))
assert(result == “lie”)
}
Unit tests are not enough
Introducing contract tests
import JsonLibBar
GET “/cake”:
return toJson(current_state)
// { “currentState” : “lie” }
import JsonLibBar
“#cake” >> {
result = fromJson(call(“cake”))
assert(result == “lie”)
}
Introducing contract tests
How this works?
Consumer Provider
End-to-End Test
Introducing contract tests
How this works?
Consumer Provider
Unit Test Unit Test
Introducing contract tests
How this works?
Consumer Provider
Unit Test Unit Test
Introducing contract tests
How this works?
➢ Requesting “/cake”.
➢ Expecting a JSON response
with a key “current_state”.
➢ Asserting deserialization
of the response succeeds.
import JsonLibFoo
GET “/cake”:
return toJson(current_state)
// { “current_state” : “lie” }
Consumer
Provider
Pactifying our services
http://pact.io
What’s Pact?
Pactifying our services
● A family of frameworks designed for consumer driven
contract testing.
● Supports JSON over HTTP.
● Impl. for Java, Scala, Go, Ruby, .Net, Swift, JS etc.
● Tests run locally, no external dependencies.
What’s Pact?
Pactifying our services
Step 1: Define consumer expectations
© pact.io
What’s Pact?
Pactifying our services
Step 2: Verify expectations on provider
© pact.io
Consumer: client code (LikesClient)
Consumer: client code (LikesClient)
Consumer: client code (LikesClient)
Consumer: client code (LikesClient)
Consumer: client code (LikesClient)
Consumer: client code (LikesClient)
Consumer: client unit test
Consumer: client unit test
Consumer: client unit test
Consumer: client unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: client contract unit test
Consumer: my-consumer-likes.json
Consumer: my-consumer-likes.json
Consumer: my-consumer-likes.json
Consumer: my-consumer-likes.json
Consumer: my-consumer-likes.json
Consumer: my-consumer-likes.json
Consumer: my-consumer-likes.json
Pactifying our services
Provider side verification
● Collect pact files from consumers and verify them all.
● Keep your provider environment isolated.
○ Dockerized databases.
○ Test doubles for upstream services.
Pactifying our services
Provider states
Pactifying our services
Provider states
Likes
App
Likes
DB
Pactifying our services
Provider states
Set state:
“User 1000 has liked 2 tracks”
Likes
App
Likes
DB
Pactifying our services
Provider states
INSERT
likes
Set state:
“User 1000 has liked 2 tracks”
Likes
App
Likes
DB
Pactifying our services
Provider states
INSERT
likes
Set state:
“User 1000 has liked 2 tracks”
HTTP Request: GET /likes/1000
Likes
App
Likes
DB
Pactifying our services
Provider states
HTTP Request: GET /likes/1000
HTTP Response: 200 OK
INSERT
likes
Set state:
“User 1000 has liked 2 tracks”
Likes
App
Likes
DB
Pactifying our services
Provider states
Likes
App
Likes
DB
HTTP Response: 200 OK
INSERT
likes
Set state:
“User 1000 has liked 2 tracks”
HTTP Request: GET /likes/2000
HTTP Response: 404 Not Found
Set state:
“User 2000 has liked no tracks”
HTTP Request: GET /likes/1000
DELETE
likes
Pactifying our services
Pact broker
● Share pact files between projects.
● API for pact frameworks to fetch all pacts by provider.
● Support for versioning and tagging.
● Useful UI and visualization of the network.
Pactifying our services
Pact broker
© pact broker
Pactifying our services
Pact broker
© pact broker
Pactifying our services
Pact broker
© pact broker
Pactifying our services
Our CI pipeline
Push new
change
Generate
consumer
contracts
Deploy
Upload
pacts & tag
with ‘prod’
Consumer pipeline
Pactifying our services
Our CI pipeline
Push new
change
Deploy
Upload
pacts & tag
with ‘prod’
Consumer pipeline
Push new
change
Verify all
‘prod’-tagged
pacts
Deploy
Provider pipeline
Generate
consumer
contracts
● Communication is key.
Caveats
● Communication is key.
● New moving parts.
Caveats
● Communication is key.
● New moving parts.
● Learning curve per pact framework.
Caveats
● Communication is key.
● New moving parts.
● Learning curve per pact framework.
● Frameworks are WIP.
Caveats
● Communication is key.
● New moving parts.
● Learning curve per pact framework.
● Frameworks are WIP.
● Provider side setup is time consuming.
Caveats
● Communication is key.
● New moving parts.
● Learning curve per pact framework.
● Frameworks are WIP.
● Provider side setup is time consuming.
● Automating consumer-triggered provider verification.
Caveats
● Communication is key.
● New moving parts.
● Learning curve per pact framework.
● Frameworks are WIP.
● Provider side setup is time consuming.
● Automating consumer-triggered provider verification.
● Adoption is essential.
Caveats
Recap
Recap
Write contract tests
Consum
ers
Recap
Write contract tests Generate pact files
Consum
ers
Recap
Write contract tests Generate pact files
Publish to broker
Consum
ers
Recap
Write contract tests Generate pact files
Publish to brokerVerify pacts
Consum
ers
Providers
Recap
Write contract tests Generate pact files
Publish to brokerVerify pacts
Consum
ers
Providers
QA Q&A
@alonpeer

More Related Content

Viewers also liked (9)

PDF
Ports & Adapters Architecture - XP Days 2017
Nathan Johnstone
 
PPTX
XP Days 2017 Tansformation practices
Dmitriy Yefimenko
 
PDF
Improving Your Organization's Technical Prowess With Legacy Code Retreats
Howard Deiner
 
PDF
Funny stories and anti-patterns from DevOps landscape
Mikalai Alimenkou
 
PDF
Origins of Serverless
Andrii Soldatenko
 
PDF
DevOps Pragmatic Overview
Mykola Marzhan
 
PPTX
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
PDF
Future of Serverless
Yoav Avrahami
 
PPTX
Designing REST API automation tests in Kotlin
Dmitriy Sobko
 
Ports & Adapters Architecture - XP Days 2017
Nathan Johnstone
 
XP Days 2017 Tansformation practices
Dmitriy Yefimenko
 
Improving Your Organization's Technical Prowess With Legacy Code Retreats
Howard Deiner
 
Funny stories and anti-patterns from DevOps landscape
Mikalai Alimenkou
 
Origins of Serverless
Andrii Soldatenko
 
DevOps Pragmatic Overview
Mykola Marzhan
 
Code Review tool for personal effectiveness and waste analysis
Mikalai Alimenkou
 
Future of Serverless
Yoav Avrahami
 
Designing REST API automation tests in Kotlin
Dmitriy Sobko
 

Similar to Move fast and consumer driven contract test things (20)

PDF
Microservices: What's Missing - O'Reilly Software Architecture New York
Adrian Cockcroft
 
PPTX
ESB Testing
Nithin Bijjala
 
PPTX
ATAGTR2017 CDC Tests - Integration Tests cant be made simpler than this!
Agile Testing Alliance
 
PPTX
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
KenAtIndeed
 
PPTX
vodQA(Pune) 2018 - Consumer driven contract testing using pact
vodQA
 
PDF
Oracle OSB Tutorial 2
Rakesh Gujjarlapudi
 
PDF
Cloud Foundry Cookbook: Recipes for a Successful Cloud Foundry Deployment in ...
VMware Tanzu
 
PDF
Recipes for a successful production cloudfoundry deployment - CF Summit 2014
Vinícius Carvalho
 
PPTX
Into the cloud
Tomas Riha
 
PDF
Oop2008 RESTful services with GWT and Apache CXF
Adrian Trenaman
 
PDF
Next Generation Client APIs in Envoy Mobile
C4Media
 
PDF
Deploy with Confidence using Pact Go!
DiUS
 
PDF
The case for consumer-driven contracts
DiUS
 
PPTX
Supercharging Optimizely Performance by Moving Decisions to the Edge
Optimizely
 
PPTX
Service workers and their role in PWAs
Ipsha Bhidonia
 
PPTX
Deploy Faster Without Failing Faster - Metrics-Driven - Dynatrace User Groups...
Andreas Grabner
 
PPTX
Rl Partner Webinar To Share
Compuware APM
 
PPTX
"Asynchronous" Integration Tests for Microservices - RootConf 2017
Ramya Authappan
 
PDF
Edge architecture ieee international conference on cloud engineering
Mikey Cohen - Hiring Amazing Engineers
 
PPT
Postman.ppt
ParrotBAD
 
Microservices: What's Missing - O'Reilly Software Architecture New York
Adrian Cockcroft
 
ESB Testing
Nithin Bijjala
 
ATAGTR2017 CDC Tests - Integration Tests cant be made simpler than this!
Agile Testing Alliance
 
Engineering Velocity @indeed eng presented on Sept 24 2014 at Beyond Agile
KenAtIndeed
 
vodQA(Pune) 2018 - Consumer driven contract testing using pact
vodQA
 
Oracle OSB Tutorial 2
Rakesh Gujjarlapudi
 
Cloud Foundry Cookbook: Recipes for a Successful Cloud Foundry Deployment in ...
VMware Tanzu
 
Recipes for a successful production cloudfoundry deployment - CF Summit 2014
Vinícius Carvalho
 
Into the cloud
Tomas Riha
 
Oop2008 RESTful services with GWT and Apache CXF
Adrian Trenaman
 
Next Generation Client APIs in Envoy Mobile
C4Media
 
Deploy with Confidence using Pact Go!
DiUS
 
The case for consumer-driven contracts
DiUS
 
Supercharging Optimizely Performance by Moving Decisions to the Edge
Optimizely
 
Service workers and their role in PWAs
Ipsha Bhidonia
 
Deploy Faster Without Failing Faster - Metrics-Driven - Dynatrace User Groups...
Andreas Grabner
 
Rl Partner Webinar To Share
Compuware APM
 
"Asynchronous" Integration Tests for Microservices - RootConf 2017
Ramya Authappan
 
Edge architecture ieee international conference on cloud engineering
Mikey Cohen - Hiring Amazing Engineers
 
Postman.ppt
ParrotBAD
 
Ad

Recently uploaded (20)

PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PPT
Activate_Methodology_Summary presentatio
annapureddyn
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
Troubleshooting Virtual Threads in Java!
Tier1 app
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PDF
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
Brief History of Python by Learning Python in three hours
adanechb21
 
Activate_Methodology_Summary presentatio
annapureddyn
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
Troubleshooting Virtual Threads in Java!
Tier1 app
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
On Software Engineers' Productivity - Beyond Misleading Metrics
Romén Rodríguez-Gil
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Presentation about variables and constant.pptx
kr2589474
 
Ad

Move fast and consumer driven contract test things