$30 off During Our Annual Pro Sale. View Details »

Uh, Does This Thing Actually Work? Modern Microservices Testing

Uh, Does This Thing Actually Work? Modern Microservices Testing

To realise the promise of microservices, individual services must be independently deployable, and they should be deployed often. But that’s easier said than done. Releases take confidence.

How does a business achieve enough confidence to release often without getting bogged down in manual QA bottlenecks? Is automating tests too expensive? How do services know if they’ve made a breaking change? If the individual microservices all work, does that mean the system works?

This talk discuss microservices testing strategies and explore some of the modern tools which make testing easier and better. And there’s a demo: Holly will show Pact contract testing, test containers, and Quarkus’s continuous testing and dev services support.

Holly Cummins

June 22, 2023
Tweet

More Decks by Holly Cummins

Other Decks in Programming

Transcript





  1. Holly Cummins


    Red Hat


    #JSpring
    uh, does this thing actually work?


    modern microservices testing

    View Slide

  2. Disclaimer: I am not a tester.


    … but that’s ok.


    (Testing is every developer’s job.)

    View Slide

  3. View Slide

  4. @holly_cummins #RedHat
    what does testing mean?

    View Slide

  5. @holly_cummins #RedHat
    what does testing mean?

    View Slide

  6. @holly_cummins #RedHat
    writing tests?

    View Slide

  7. @holly_cummins #RedHat
    writing lots of tests?

    View Slide

  8. @holly_cummins #RedHat
    95% test coverage!

    View Slide

  9. @holly_cummins #RedHat
    actually having assertions
    in tests

    View Slide

  10. @holly_cummins #RedHat
    confidence the thing works

    View Slide

  11. @holly_cummins #RedHat
    confidence to make changes

    View Slide

  12. @holly_cummins #RedHat
    “we are moving to microservices so
    we can change things more easily.”

    View Slide

  13. @holly_cummins #RedHat
    “If your microservice only does one thing, it can’t
    have an error. That would be an additional thing.”


    – Matt Stratton


    (not being serious!)


    View Slide

  14. @holly_cummins #RedHat
    if you’re going to do microservices,
    you need to get good at automation.


    … and testing.

    View Slide

  15. @holly_cummins #RedHat
    fallacies of microservices

    View Slide

  16. @holly_cummins #RedHat
    fallacies of microservices
    “things we wish were true”

    View Slide

  17. #Quarkus @holly_cummins
    “microservices makes testing easy!


    the thing I have to test is so small!”

    View Slide

  18. #Quarkus @holly_cummins
    Netflix microservice
    architecture
    “microservices makes testing easy!


    the thing I have to test is so small!”

    View Slide

  19. #Quarkus @holly_cummins
    Netflix microservice
    architecture
    “microservices makes testing easy!


    the thing I have to test is so small!”
    if you only test the points, and not
    the lines … does the thing work?

    View Slide

  20. @holly_cummins #RedHat
    “my microservice is perfectly tested, even
    though the system doesn’t actually work.”

    View Slide

  21. @holly_cummins #RedHat
    “we don’t need to
    test the lines…


    we’re decoupled!”

    View Slide

  22. @holly_cummins #RedHat
    “we don’t need to
    test the lines…


    we’re decoupled!”

    View Slide

  23. @holly_cummins #RedHat
    distributed != decoupled

    View Slide

  24. @holly_cummins #RedHat
    “uh, what do you mean you
    corrected the typo in your json?”

    View Slide

  25. @holly_cummins #RedHat
    “ohhhh, we weren’t expecting
    your service to do that … “

    View Slide

  26. @holly_cummins #RedHat

    View Slide

  27. @holly_cummins #RedHat
    “you’re putting a value in the wrong
    field when you call our API.

    View Slide

  28. @holly_cummins #RedHat
    “you’re putting a value in the wrong
    field when you call our API.
    yes, I know there are 15 fields and the
    names aren’t particularly descriptive.”

    View Slide

  29. @holly_cummins #RedHat
    how do you know if
    you’re decoupled?

    View Slide

  30. can you deploy
    independently? v5.1.4
    v5.1.4
    v5.1.4
    v5.1.4

    View Slide

  31. can you deploy
    independently? v6.2.8
    v65.7
    v5.1.4
    v1.0.5

    View Slide

  32. @holly_cummins #RedHat
    TDD

    View Slide

  33. @holly_cummins #RedHat
    TDD: improves quality

    View Slide

  34. @holly_cummins #RedHat
    TDD: an excellent design tool

    View Slide

  35. @holly_cummins #RedHat
    TDD: an excellent design tool
    (if testing is hard, that’s a hint
    the design is wrong)

    View Slide

  36. @holly_cummins #RedHat

    View Slide

  37. @holly_cummins #RedHat
    the real reason to do TDD:

    View Slide

  38. @holly_cummins #RedHat
    the real reason to do TDD:

    View Slide

  39. @holly_cummins #RedHat
    the real reason to do TDD:
    gamified testing

    View Slide

  40. @holly_cummins #RedHat
    the test
    pyramid

    View Slide

  41. @holly_cummins #RedHat
    the test
    pyramid
    (you can TDD
    at every level)

    View Slide

  42. @holly_cummins #RedHat
    the test
    pyramid

    View Slide

  43. @holly_cummins #RedHat
    the test
    pyramid end-to-end tests

    View Slide

  44. @holly_cummins #RedHat
    the test
    pyramid end-to-end tests
    integration tests

    View Slide

  45. @holly_cummins #RedHat
    the test
    pyramid end-to-end tests
    unit tests
    integration tests

    View Slide

  46. @holly_cummins #RedHat
    the test
    pyramid end-to-end tests
    unit tests
    integration tests
    low effort

    View Slide

  47. @holly_cummins #RedHat
    the test
    pyramid end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  48. @holly_cummins #RedHat
    the test
    pyramid end-to-end tests
    unit tests
    integration tests
    low effort
    high realism
    high value

    View Slide

  49. @holly_cummins #RedHat
    all models are wrong


    some are useful

    View Slide

  50. @holly_cummins #RedHat
    tools
    evolve end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  51. @holly_cummins #RedHat
    tools
    evolve end-to-end tests
    unit tests
    integration tests
    low effort
    high realism
    tests with
    application
    server

    View Slide

  52. @holly_cummins #RedHat
    tools
    evolve end-to-end tests
    unit tests
    integration tests
    low effort
    high realism
    tests with
    application
    server
    test REST
    endpoints

    View Slide

  53. @holly_cummins #RedHat
    tools
    evolve end-to-end tests
    unit tests
    integration tests
    low effort
    high realism
    tests with
    application
    server
    test REST
    endpoints

    View Slide

  54. @holly_cummins #RedHat
    unit tests
    low effort

    View Slide

  55. @holly_cummins #RedHat
    “why have I spent half a
    day writing mocks just so
    I can write a unit test?”
    the limitations of unit tests

    View Slide

  56. @holly_cummins #RedHat
    the limitations of unit tests
    “why do my colleagues
    tell me my code is
    broken, even though my
    unit tests all pass?”

    View Slide

  57. @holly_cummins #RedHat
    their code
    our code
    why unit tests
    aren’t enough

    View Slide

  58. @holly_cummins #RedHat
    their code
    our code
    why mocks
    aren’t enough

    View Slide

  59. @holly_cummins #RedHat
    their code
    our code
    why stubs
    aren’t enough

    View Slide

  60. @holly_cummins #RedHat
    our code our mock
    why mocks
    aren’t enough

    View Slide

  61. @holly_cummins #RedHat
    our code our mock
    tests ✔


    why mocks
    aren’t enough

    View Slide

  62. @holly_cummins #RedHat
    our code our mock
    our code their actual code
    tests ✔


    why mocks
    aren’t enough

    View Slide

  63. @holly_cummins #RedHat
    our code our mock
    our code their actual code
    tests ✔


    reality ✘
    why mocks
    aren’t enough

    View Slide

  64. @holly_cummins #RedHat
    what needs
    integration tests?
    our service

    View Slide

  65. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    all code that serialises or deserialises data

    View Slide

  66. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    all code that serialises or deserialises data

    View Slide

  67. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    db calls
    all code that serialises or deserialises data

    View Slide

  68. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    db calls
    queues


    ETL
    all code that serialises or deserialises data

    View Slide

  69. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    db calls
    filesystem
    config, etc
    queues


    ETL
    all code that serialises or deserialises data

    View Slide

  70. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    db calls
    external
    applications
    colleague’s
    services
    other services
    filesystem
    config, etc
    queues


    ETL
    all code that serialises or deserialises data

    View Slide

  71. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    db calls
    external
    applications
    colleague’s
    services
    filesystem
    config, etc
    queues


    ETL
    all code that serialises or deserialises data

    View Slide

  72. @holly_cummins #RedHat
    what needs
    integration tests?
    our service
    rest api
    usage by consumers
    db calls
    external
    applications
    colleague’s
    services
    filesystem
    config, etc
    queues


    ETL
    all code that serialises or deserialises data

    View Slide

  73. @holly_cummins #RedHat
    end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  74. @holly_cummins #RedHat
    end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  75. @holly_cummins #RedHat
    end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  76. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  77. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    high realism

    View Slide

  78. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    high realism
    in staging

    View Slide

  79. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    high realism
    in staging
    ?

    View Slide

  80. @holly_cummins #RedHat
    “why do I keep getting failures in
    production even though everything
    looked fine in staging?”
    Photo by Eggs&Beer, Flickr

    View Slide

  81. @holly_cummins #RedHat
    staging
    staging ✔


    why staging is
    not enough
    our service
    other
    services
    other
    services
    other
    services
    other
    services

    View Slide

  82. @holly_cummins #RedHat
    staging
    staging ✔


    production ✘
    why staging is
    not enough
    our service
    other
    services
    other
    services
    other
    services
    other
    services
    our service
    production
    other services other
    services
    other
    services
    other
    services

    View Slide

  83. @holly_cummins #RedHat
    “test in prod or live a lie”


    - Charity Majors

    View Slide

  84. @holly_cummins #RedHat
    testing in production, done well:


    observability


    ability to deploy quickly (& safely)

    View Slide

  85. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    unit tests
    integration tests
    low effort
    high realism

    View Slide

  86. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    unit tests
    integration tests
    low effort
    high realism
    testing in production

    View Slide

  87. @holly_cummins #RedHat
    the test
    trophy end-to-end tests
    unit tests
    integration tests
    low effort
    high realism
    static tests
    testing in production

    View Slide

  88. @holly_cummins #RedHat
    confidence
    effort

    View Slide

  89. @holly_cummins #RedHat
    confidence
    effort
    quality

    View Slide

  90. @holly_cummins #RedHat
    confidence
    effort
    quality
    expense

    View Slide

  91. @holly_cummins #RedHat
    confidence
    effort
    quality
    expense
    cheap and
    cheerful

    View Slide

  92. @holly_cummins #RedHat
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful

    View Slide

  93. @holly_cummins #RedHat
    winning
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful

    View Slide

  94. @holly_cummins #RedHat
    a waste
    winning
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful

    View Slide

  95. @holly_cummins #RedHat
    a waste
    winning
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful

    View Slide

  96. @holly_cummins #RedHat
    a waste
    winning
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests

    View Slide

  97. @holly_cummins #RedHat
    a waste
    winning
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests

    View Slide

  98. @holly_cummins #RedHat
    a waste
    winning
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests

    View Slide

  99. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    static
    tests

    View Slide

  100. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests

    View Slide

  101. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    YMMV

    View Slide

  102. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    YMMV

    View Slide

  103. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    YMMV

    View Slide

  104. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    YMMV

    View Slide

  105. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests

    View Slide

  106. @holly_cummins #RedHat
    a waste
    confidence
    effort
    quality
    expense
    hard work,


    but valuable
    cheap and
    cheerful
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    constantly question the
    value of your tests

    View Slide

  107. @holly_cummins #RedHat
    integration tests

    View Slide

  108. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests

    View Slide

  109. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests

    View Slide

  110. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    all integration
    tests are not
    created equal

    View Slide

  111. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    integration tests
    all integration
    tests are not
    created equal

    View Slide

  112. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    integration tests
    all integration
    tests are not
    created equal
    integration tests

    View Slide

  113. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    integration tests
    all integration
    tests are not
    created equal
    integration tests
    integration tests

    View Slide

  114. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    integration tests
    all integration
    tests are not
    created equal
    integration tests
    integration tests
    integration tests

    View Slide

  115. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    all integration
    tests are not
    created equal
    integration tests
    contract tests
    integration tests
    integration tests

    View Slide

  116. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    all integration
    tests are not
    created equal
    contract tests
    sandbox tests
    integration tests
    integration tests

    View Slide

  117. @holly_cummins #RedHat
    confidence
    effort
    unit tests
    integration tests
    e2e tests
    testing in
    production
    static
    tests
    all integration
    tests are not
    created equal
    contract tests
    sandbox tests
    testcontainers tests
    integration tests

    View Slide

  118. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications

    View Slide

  119. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    mock all the things

    View Slide

  120. @holly_cummins #RedHat
    “why have I spent half a
    day writing mocks just so I
    can write a cleanly-scoped
    integration test?”

    View Slide

  121. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications

    View Slide

  122. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications

    View Slide

  123. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    containerise all the things

    View Slide

  124. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    containerise all the things

    View Slide

  125. @holly_cummins #RedHat

    View Slide

  126. @holly_cummins #RedHat
    “I can’t bring up my dev stack

    View Slide

  127. @holly_cummins #RedHat
    “I can’t bring up my dev stack
    … on my brand new Apple laptop
    with a M1 chip and 64GB of RAM.”
    - fintech developer

    View Slide

  128. @holly_cummins #RedHat
    “I can’t bring up my dev stack
    … on my brand new Apple laptop
    with a M1 chip and 64GB of RAM.”
    digression: if this is you


    • maybe testing is only part of your problem


    • … and Quarkus could help :)
    - fintech developer

    View Slide

  129. @holly_cummins #RedHat
    “I have to do all this shell
    scripting and manual process
    and orchestration before I can
    write a test or do development.”

    View Slide

  130. @holly_cummins #RedHat
    testing is a useful design tool

    View Slide

  131. @holly_cummins #RedHat
    testing is a useful design tool
    (if testing your micro service is
    hard, that’s a hint the domain
    boundary is wrong)

    View Slide

  132. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    remote sandbox
    remote system


    + remote deploy

    View Slide

  133. @holly_cummins #RedHat
    “I miss developing on my
    actual laptop.”

    View Slide

  134. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    remote system


    with telepresence

    View Slide

  135. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    remocal sandbox
    remote system


    with telepresence

    View Slide

  136. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    remocal sandbox
    remote system


    with telepresence

    View Slide

  137. @holly_cummins #RedHat
    pitfalls:


    • all services need to be configured to
    forward headers


    • relies on rest; will not play well with kafka
    queues or other protocols


    • can be tricky to get to work

    View Slide

  138. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    shared remocal sandbox
    remote system


    with telepresence


    and per-request isolation

    View Slide

  139. @holly_cummins #RedHat
    pitfalls:


    • it all works great – until a test changes some
    state, eg


    • writing to a db


    • adding a user to a security provider


    • getting IP whitelists when running locally is tricky

    View Slide

  140. @holly_cummins #RedHat

    View Slide

  141. @holly_cummins #RedHat
    “could I be … a bit less realistic?
    and a bit more offline?”

    View Slide

  142. @holly_cummins #RedHat
    networks: just say no

    View Slide

  143. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications

    View Slide

  144. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications

    View Slide

  145. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    testcontainers

    View Slide

  146. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    db calls
    external
    applications
    filesystem
    config, etc
    queues


    ETL
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    testcontainers

    View Slide

  147. to the code!
    @holly_cummins #RedHat

    View Slide

  148. @holly_cummins #RedHat

    View Slide

  149. @holly_cummins #RedHat
    drawback:

    View Slide

  150. @holly_cummins #RedHat
    drawback:
    • the service still uses CPU

    View Slide

  151. @holly_cummins #RedHat
    drawback:
    • the service still uses CPU
    • only works for well-known libraries

    View Slide

  152. @holly_cummins #RedHat
    bonus:


    •programmatic control of dependencies


    •seamless with some frameworks (esp. Quarkus)

    View Slide

  153. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications

    View Slide

  154. @holly_cummins #RedHat
    approaches to
    integration tests
    our service
    rest api
    external
    applications
    filesystem
    colleague’s
    services
    colleague’s
    services
    colleague’s
    services
    external
    applications
    contract test (for services who will talk to you)

    View Slide

  155. @holly_cummins #RedHat
    our code our mock
    our code their actual code
    tests ✔


    why mocks aren’t
    enough

    View Slide

  156. @holly_cummins #RedHat
    our code our mock
    our code their actual code
    tests ✔


    reality ✘
    why mocks aren’t
    enough

    View Slide

  157. @holly_cummins #RedHat
    our code their code
    why mocks aren’t
    enough

    View Slide

  158. @holly_cummins #RedHat
    our code their code
    contract test
    why mocks aren’t
    enough

    View Slide

  159. @holly_cummins #RedHat
    our code their code
    contract test
    mock
    why mocks aren’t
    enough

    View Slide

  160. @holly_cummins #RedHat
    our code their code
    contract test
    mock functional test
    why mocks aren’t
    enough

    View Slide

  161. @holly_cummins #RedHat
    our code their code
    contract test
    mock functional test
    our tests ✔


    their tests ✔


    reality ✔


    why mocks aren’t
    enough

    View Slide

  162. @holly_cummins #RedHat
    our code their code
    contract test
    mock functional test
    why mocks aren’t
    enough

    View Slide

  163. @holly_cummins #RedHat
    our code their code
    contract test
    mock functional test
    our tests ✔


    their tests ✘


    reality ✘


    why mocks aren’t
    enough

    View Slide

  164. @holly_cummins #RedHat
    our code their code
    contract test
    mock functional test
    why mocks aren’t
    enough

    View Slide

  165. @holly_cummins #RedHat
    our code their code
    contract test
    mock functional test
    our tests ✘


    their tests ✔


    reality ✘


    why mocks aren’t
    enough

    View Slide

  166. @holly_cummins #RedHat

    View Slide

  167. @holly_cummins #RedHat
    contract-first is a great way to TDD

    View Slide

  168. @holly_cummins #RedHat
    contract-first is a great way to TDD
    (and a great design tool)

    View Slide

  169. to the code!
    @holly_cummins #RedHat

    View Slide

  170. #RedHat
    @holly_cummins
    demo recap:


    https://github.com/holly-cummins/house-of-microservices-quarkus-contract-testing-sample

    View Slide

  171. #RedHat
    @holly_cummins
    demo recap:


    https://github.com/holly-cummins/house-of-microservices-quarkus-contract-testing-sample

    View Slide

  172. #RedHat
    @holly_cummins
    demo recap:


    • consumer-driven contract testing can save your bacon


    • pact is a mock for the consumer


    • pact is a functional test for the producer


    • shared json contracts aligns expectations across services

    View Slide

  173. @holly_cummins #RedHat
    pitfalls of contract testing:


    • we have to talk to the other team


    • our consumers can break our CI?!


    • but I’ve already written mocks and
    functional tests

    View Slide

  174. @holly_cummins #RedHat
    unexpected benefits of contract testing:


    preserving backwards compatibility


    YAGNI


    YAWIBNCSDI*

    View Slide

  175. @holly_cummins #RedHat
    unexpected benefits of contract testing:


    preserving backwards compatibility


    YAGNI


    YAWIBNCSDI*
    * (you already wrote it but now can safely delete it)

    View Slide

  176. @holly_cummins #RedHat
    contract testing options:


    • pact.io


    • Microcks


    • spring contract


    • OpenAPI schema validation + mock generation


    • prism


    • schemathesis

    View Slide

  177. @holly_cummins #RedHat
    ok but what should I do?

    View Slide

  178. @holly_cummins #RedHat
    confidence
    effort
    integration
    testing


    landscape
    mock all the services
    testcontainers
    remote sandbox
    remocal
    sandbox
    contract tests
    local orchestration

    View Slide

  179. @holly_cummins #RedHat
    confidence
    effort
    integration
    testing


    landscape
    mock all the services
    testcontainers
    remote sandbox
    remocal
    sandbox
    contract tests
    local orchestration
    if you don’t have a big platform team

    View Slide

  180. @holly_cummins #RedHat
    confidence
    effort
    integration
    testing


    landscape
    mock all the services
    testcontainers
    remote sandbox
    remocal
    sandbox
    contract tests
    local orchestration
    if you have a platform team

    View Slide

  181. @holly_cummins #RedHat
    so, does the thing work?


    test early, test often


    testcontainers rocks


    contract testing can prevent pain


    think both locally and system-level

    View Slide

  182. ®
    thank you


    @holly_cummins
    slides + code

    View Slide