Pactflow Code Demos
Introduction
Demo script
All demos are designed to fit in a 60 minute time slot, with the rough split of 5 minutes for introductions, 45 minutes for the demo, and 10 minutes for Q&A and follow up actions.
Here is a rough guide for how we run each demo:
Preparation
Step | Description | Purpose | Duration |
---|---|---|---|
1 | Run through slides 1 - 27 of demo pack | Problem statement, solution (contract-testing) | 5 mins |
2 | Choose a technology mix to construct a scenario relevant to your customer (you can mix and match consumer/provider technology for comparable use cases) | Setup demo | n/a |
3 | Setup the integration in your Pactflow account (see CI/CD workshop for pre-requisites) | Ensure the Demo Gods are on your side | 10 - 15 minutes |
During the session
Step | Description | Purpose | Duration |
---|---|---|---|
4 | Show the consumer + provider working together in action (i.e. run them locally) | Understand use case | 2 minutes |
5 | Show consumer code + integration point (class/object) being tested | Consumer test scope | 5 minutes |
6 | Show consumer pact test code and step through the consumer pact tests (e.g. make test ) | How to write Pact tests | 5 mins |
7 | Run the fake (make fake_ci ) CI process (or show the real via a git push) | Demonstrate a CI/CD workflow | 5 mins |
(Optional) show how you can use pact-stub-service to run the consumer offline | Demonstrate value for local testing ahead of a real provider | 2 mins | |
8 | Show that the contract was published (tagged master ) to Pactflow and basic features | Why Pactflow/Pact Broker exists | 2 minutes |
8 | Explain what just happened with the can-i-deploy step | The "magic moment" feature | 2 minutes |
9 | Show provider code + integration point (class/object) being tested | Provider test scope | 2 minutes |
10 | Show provider pact test code and step through the provider pact test (e.g. make test ) | How to verify a Provider | 5 mins |
11 | Run the fake (make fake_ci ) CI process (or show the real via a git push) | Demonstrate a CI/CD workflow | 5 mins |
The provider build should pass, and is now deployed to production (denoted by the prod tag in Pactflow) | - | - | |
12 | Re-run the consumer ci/cd process (make fake_ci ) and "deploy" to prod | Understand value of Pactflow | 2 mins |
Observe that it is now tagged as prod in Pactflow | Understand can-i-deploy and environment management via tags | - |
Optional variations
If time permits, you may want to extend the demo to show other scenarios such as.
1. Modify the single product route to be GET /products/:id
- This can be initiated from the consumer side or the provider side
- Show how Pact will prevent a breaking change from being introduced and that it facilitiates
Scenarios
Product Catalog System (HTTP/Messages)
Our standard example is a product catalog website (see React above) which consumes a basic Products API implementing the following HTTP interface. All demo languages implement this interface so that we can easily mix and match technologies.
Endpoint | Example Response |
---|---|
GET /products | [{"id":"09","type":"CREDIT_CARD","name":"Gem Visa","version":"v1"},{"id":"10","type":"CREDIT_CARD","name":"28 Degrees","version":"v1"},{"id":"11","type":"PERSONAL_LOAN","name":"MyFlexiPay","version":"v2"}] |
GET /product/1 | {"id":"09","type":"CREDIT_CARD","name":"Gem Visa","version":"v1"} |
info
The single get product endpoint is not a spelling mistake, and is used to show evolution to more standard resource based design
Demos
Consumers
Language | Use Case | Framework/Tech | Description |
---|---|---|---|
JS/NodeJS | Web | React | React JS website relying on a Products API |
JS/NodeJS | Web | Cypress | Example demonstrating how Cypress could be used to generate consumer pacts |
Java | Messages | Kafka | Java Kafka consumer |
NodeJS | Messages | Kafka | NodeJS Kafka consumer |
Java | SOAP | Java | Java SOAP API consumer (note: only compatible with the SOAP provider) |
.NET | API | .NET | .NET Products API consumer |
Providers
Language | Use Case | Framework/Tech | Description |
---|---|---|---|
JS/NodeJS | API | Express JS | ExpressJS API provider |
Java | API | Spring Boot | Java Spring Boot API provider |
Java | Messages | Kafka | Java Kafka message provider |
Java | SOAP | Java | Java SOAP API provider (note: only compatible with the SOAP consumer) |
.NET | API | .NET | .NET API provider |