Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Resilience Testing with Wiremock

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for David Schmitz David Schmitz
March 23, 2017
180

Resilience Testing with Wiremock

Avatar for David Schmitz

David Schmitz

March 23, 2017
Tweet

Transcript

  1. <[email protected]> Enter Wiremock • Stub and Mock framework for testing

    HTTP(s) traffic • Features include • Request verification, • record, playback, • fault injection, • unit test and stand alone Client Unit Test Embedded Wiremock Client Standalone Wiremock
  2. <[email protected]> How does it work? Client Wiremock Request Mapping Response

    Data $ curl -H ‘Accept: application/json’ http://localhost:8080/sample/
  3. <[email protected]> How does it work? Client Wiremock Request Mapping Response

    Data • Starts embedded Jetty Server • Acts as a proxy to the actual service • Is used by the client transparently
  4. <[email protected]> How does it work? Client Wiremock Request Mapping Response

    Data "request" : { "url" : "/sample/", "method" : "GET", } } }, "response" : { "status" : 200, "bodyFileName" : "body.json", "headers" : { "Content-Type" : “application/json" … } }
  5. <[email protected]> How does it work? Client Wiremock Request Mapping Response

    Data body.json: [{"publicId":"...","data":"..."}, {"publicId":"...","data":"..."}]
  6. <[email protected]> …but what about bad responses? Client Service HTTP/1.1 200

    OK Content-Type: application/json;charset=UTF-8 [300 MB of random garbage] GET http://service/resource/12
  7. <[email protected]> Summary • Resilience can be tested • Do not

    rely on happy paths and mocks only • Use stubs and verify in unit tests • Use record and playback for external services • Make sure not to be the developer responsible for a downtime during the busy-business-time :D