“Quality cannot be inspected into a product or service; it must be built into it.”
W Edwards Deming
CD Requires Fast Feedback
- ✔️ Independent deployability
- ✔️ Automation
- ✔️ Shifting feedback left
- ✔️ Collaboration over handoffs
End to End
Challenges:
- Speed of feedback
- Reliability of feedback
- Managing unowned dependencies
"Any advantage you gain by talking to the real system is overwhelmed by the need to stamp out non-determinism"
Martin Fowler
"Push tests as low as they can go for the highest return in investment and quickest feedback"
Janet Gregory and Lisa Crispin
Decomposing what we do:
- Connectivity - Mocks and Smoke Testing
- Conversation - Contract Testing
- Conduct - Contracts, Monitoring, User Journeys
Contract Testing
Capture service communication in a contract
Pact terminology:
- Consumer of a service
- Provider
- Pactfiles
- Broker
Consumer
- 🧪 Write unit tests demonstrating usage
- 📜 Run tests against a mock to generate contracts
- 💾 Upload to Broker during CI
A Pactfile viewed in the Pact Broker UI
Provider
Does this build satisfy the consumer's contracts?
During CI...
- 📜 Retrieve mainline contract for each consumer
- 🧪 Start service (mock upstream dependencies)
- 🚀 Launch Pact mock client
- ✔️ Verify service's responses against contract
- 💾 Upload verification results to Broker
When a new consumer contract is published...
- ⚡ Special CI provider job triggered by Broker
- ✔️ Runs provider verification against new contract
- 💾 Upload verification result to Broker
Time to Deploy!
Pre-
pact-broker can-i-deploy
--pacticipant=pact-consumer
--version=$CI_COMMIT_SHORT_SHA
--to-environment=production
Post-
pact-broker record-deployment
--pacticipant=pact-consumer
--version=$CI_COMMIT_SHORT_SHA
--environment=production
Deploy consumer (when provider isn't deployed)
Deploy provider
Deploy consumer
Deploy consumer (with unsupported changes)
- Provider States
- Pending Pacts
- WIP Pacts
- Bi-directional Contract Testing