Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Consumer-Driven Contracts
to enable API evolution
Marcin Grzejszczak
Marcin Grzejszczak @mgrzejszczak, 17-19 May 2017
2
Spring Cloud developer at Pivotal
Working mostly on
● Spring Cloud Sleuth
● Spring Cloud Contract
● Spring Cloud Pipelin...
3
Introduction
Demo
Summary
Agenda
4
What we will NOT be talking about?
5
●
●
●
●
●
What we will NOT be talking about?
THE IDEA OF SPRING CLOUD
CONTRACT IS NOT TO
INTRODUCE UNNECESSARY
COUPLING ...
6
●
○
●
○
●
○
●
○
Introduction
7
●
●
Introduction
What problems are we trying to solve?
8
Introduction
Typical situation
HTTP
CONSUMER PRODUCER
9
Introduction
How to write a test for it?
HTTP
CONSUMER PRODUCER
10
Introduction
How to write a test for it?
HTTP
CONSUMER PRODUCER
11
Introduction
Stub validity & reusability
WE’RE ON THE CONSUMER SIDE!!
CONSUMER OWNS THE STUB
DEFINITIONS
12
Introduction
Stub validity & reusability
13
Introduction
Let’s assume that we’re introducing a new
endpoint...
14
Introduction
Stub validity & reusability
15
●
●
●
Introduction
So now what?
16
Introduction
Ooops...
17
Introduction
What went wrong?
HTTP
CONSUMER PRODUCER
TEST
OK
HTTP
CONSUMER PRODUCER
REALITY
WAT?!
18
Introduction
Another example with messaging
CONSUMERPRODUCER
TEST
PRODUCER CONSUMER
REALITY
topic: bar topic: foo
topic...
19
●
●
●
●
●
●
Introduction
Stub validity & reusability
20
●
●
●
Introduction
Nice API creation
21
Introduction
Nice API creation - no cooperation results
22
Introduction
Nice API creation - no cooperation results
23
Demo
Potential answer
Spring Cloud Contract
24
●
○
○
●
○
●
○
○
Demo
What are we going to code?
25
Introduction
What are we going to code?
I’m 22 give me a beer
CONSUMER PRODUCER
THERE YOU GO
Can he get the beer?
Yes!
26
Introduction
What are we going to code?
I’m 17 give me a beer
CONSUMER PRODUCER
GET LOST
Can he get the beer?
No!
27
Demo
Who is who?
BLACK TERMINAL
BLACK IDE
CONSUMER
WHITE TERMINAL
WHITE IDE
PRODUCER
28
Demo
29
Demo
PRODUCER CONSUMER
30
Demo
PRODUCER
CONSUMER
CLONES
PRODUCER
PRODUCER
CLONE CONSUMER
31
Demo
PRODUCER CONSUMER
CONSUMER
CLONES
PRODUCER
PRODUCER
CLONE
INTERACTION
32
Demo
PRODUCER CONSUMER
PRODUCER
CLONE
INTERACTION
CONSUMER FILES
A PR
33
Demo
34
Demo
PRODUCER
TAKES OVER THE PR
35
Demo
PRODUCER
TAKES OVER THE PR
WRITES THE MISSING
IMPLEMENTATION
36
Demo
PRODUCER
TAKES OVER THE PR
WRITES THE MISSING
IMPLEMENTATION
MERGES TO MASTER
CI UPLOADS TO NEXUS /
ARTIFACTORY
37
Demo
38
Demo
CONSUMER
SWITCHES TO
ONLINE MODE
DOWNLOADS STUBS OF
COLLABORATORS DURING
BUILD PHASE
39
I don’t want to keep my contracts with the producer
40
I don’t want to keep my contracts with the producer
You can keep the contracts
in a dedicated repository!
41
Common repo with contracts
PRODUCER CONSUMERREPO WITH
CONTRACTS
INTERACTIONINTERACTION
42
Summary
43
Summary
44
I don’t want to write any scripts!
45
Spring Cloud Contract with Rest Docs
Don’t worry! You can use Spring Cloud
Contract WireMock with Rest Docs!!
46
Spring Cloud Contract with Rest Docs - producer side
47
●
●
●
●
●
Summary
48
●
●
●
●
○
○
●
●
Summary
49
●
○
○
○
○
●
●
●
● stubMatchers testMatchers
Summary
50
Learn More. Stay Connected.
▪ Read the docs
http://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html
▪ C...
51
Survey
http://tiny.cc/geeconcdc
52
QUESTIONS
53
mgrzejszczak
Upcoming SlideShare
Loading in …5
×

Consumer Driven Contracts To Enable API Evolution @Geecon

574 views

Published on

Slides from the https://2017.geecon.org presentation

Published in: Technology
  • Be the first to comment

Consumer Driven Contracts To Enable API Evolution @Geecon

  1. 1. Consumer-Driven Contracts to enable API evolution Marcin Grzejszczak Marcin Grzejszczak @mgrzejszczak, 17-19 May 2017
  2. 2. 2 Spring Cloud developer at Pivotal Working mostly on ● Spring Cloud Sleuth ● Spring Cloud Contract ● Spring Cloud Pipelines About me Twitter: @mgrzejszczak Blog: http://toomuchcoding.com
  3. 3. 3 Introduction Demo Summary Agenda
  4. 4. 4 What we will NOT be talking about?
  5. 5. 5 ● ● ● ● ● What we will NOT be talking about? THE IDEA OF SPRING CLOUD CONTRACT IS NOT TO INTRODUCE UNNECESSARY COUPLING OR REPLICATE OLD MISTAKES
  6. 6. 6 ● ○ ● ○ ● ○ ● ○ Introduction
  7. 7. 7 ● ● Introduction What problems are we trying to solve?
  8. 8. 8 Introduction Typical situation HTTP CONSUMER PRODUCER
  9. 9. 9 Introduction How to write a test for it? HTTP CONSUMER PRODUCER
  10. 10. 10 Introduction How to write a test for it? HTTP CONSUMER PRODUCER
  11. 11. 11 Introduction Stub validity & reusability WE’RE ON THE CONSUMER SIDE!! CONSUMER OWNS THE STUB DEFINITIONS
  12. 12. 12 Introduction Stub validity & reusability
  13. 13. 13 Introduction Let’s assume that we’re introducing a new endpoint...
  14. 14. 14 Introduction Stub validity & reusability
  15. 15. 15 ● ● ● Introduction So now what?
  16. 16. 16 Introduction Ooops...
  17. 17. 17 Introduction What went wrong? HTTP CONSUMER PRODUCER TEST OK HTTP CONSUMER PRODUCER REALITY WAT?!
  18. 18. 18 Introduction Another example with messaging CONSUMERPRODUCER TEST PRODUCER CONSUMER REALITY topic: bar topic: foo topic: bar
  19. 19. 19 ● ● ● ● ● ● Introduction Stub validity & reusability
  20. 20. 20 ● ● ● Introduction Nice API creation
  21. 21. 21 Introduction Nice API creation - no cooperation results
  22. 22. 22 Introduction Nice API creation - no cooperation results
  23. 23. 23 Demo Potential answer Spring Cloud Contract
  24. 24. 24 ● ○ ○ ● ○ ● ○ ○ Demo What are we going to code?
  25. 25. 25 Introduction What are we going to code? I’m 22 give me a beer CONSUMER PRODUCER THERE YOU GO Can he get the beer? Yes!
  26. 26. 26 Introduction What are we going to code? I’m 17 give me a beer CONSUMER PRODUCER GET LOST Can he get the beer? No!
  27. 27. 27 Demo Who is who? BLACK TERMINAL BLACK IDE CONSUMER WHITE TERMINAL WHITE IDE PRODUCER
  28. 28. 28 Demo
  29. 29. 29 Demo PRODUCER CONSUMER
  30. 30. 30 Demo PRODUCER CONSUMER CLONES PRODUCER PRODUCER CLONE CONSUMER
  31. 31. 31 Demo PRODUCER CONSUMER CONSUMER CLONES PRODUCER PRODUCER CLONE INTERACTION
  32. 32. 32 Demo PRODUCER CONSUMER PRODUCER CLONE INTERACTION CONSUMER FILES A PR
  33. 33. 33 Demo
  34. 34. 34 Demo PRODUCER TAKES OVER THE PR
  35. 35. 35 Demo PRODUCER TAKES OVER THE PR WRITES THE MISSING IMPLEMENTATION
  36. 36. 36 Demo PRODUCER TAKES OVER THE PR WRITES THE MISSING IMPLEMENTATION MERGES TO MASTER CI UPLOADS TO NEXUS / ARTIFACTORY
  37. 37. 37 Demo
  38. 38. 38 Demo CONSUMER SWITCHES TO ONLINE MODE DOWNLOADS STUBS OF COLLABORATORS DURING BUILD PHASE
  39. 39. 39 I don’t want to keep my contracts with the producer
  40. 40. 40 I don’t want to keep my contracts with the producer You can keep the contracts in a dedicated repository!
  41. 41. 41 Common repo with contracts PRODUCER CONSUMERREPO WITH CONTRACTS INTERACTIONINTERACTION
  42. 42. 42 Summary
  43. 43. 43 Summary
  44. 44. 44 I don’t want to write any scripts!
  45. 45. 45 Spring Cloud Contract with Rest Docs Don’t worry! You can use Spring Cloud Contract WireMock with Rest Docs!!
  46. 46. 46 Spring Cloud Contract with Rest Docs - producer side
  47. 47. 47 ● ● ● ● ● Summary
  48. 48. 48 ● ● ● ● ○ ○ ● ● Summary
  49. 49. 49 ● ○ ○ ○ ○ ● ● ● ● stubMatchers testMatchers Summary
  50. 50. 50 Learn More. Stay Connected. ▪ Read the docs http://cloud.spring.io/spring-cloud-contract/spring-cloud-contract.html ▪ Check the samples https://github.com/spring-cloud-samples/spring-cloud-contract-samples ▪ Talk to us on Gitter https://gitter.im/spring-cloud/spring-cloud-contract Twitter: twitter.com/springcentral YouTube: spring.io/video LinkedIn: spring.io/linkedin Google Plus: spring.io/gplus
  51. 51. 51 Survey http://tiny.cc/geeconcdc
  52. 52. 52 QUESTIONS
  53. 53. 53 mgrzejszczak

×