Service Virtualization On The Cheap (Agile Testing Days 2016)

1f686da361195e15bb4e478397a4fc8f?s=47 emanuil
December 08, 2016

Service Virtualization On The Cheap (Agile Testing Days 2016)

Any sufficiently complex software application is talking to the outside world via HTTP to external services — for payments, data storage, social networks, IoT integration. Because of this, your high level automated tests have many more reasons to fail — the internet is slow, the external service throttle your requests or your credentials expire periodically.

This talk goes over the history of external service simulation and its role in creating reliable automated tests. It shows you how to start small (using internal triggers) and build your way up using open source tools for HTTP simulation.

At Komfo, we consume lots of advanced 3rd party APIs, and we hit the limits or the first generation tools pretty quickly. We had to develop our own tool — project Nagual to address today’s complex application needs for complete HTTP protocol simulation.

Nagual is written in node.js with speed and simplicity in mind. It has а number of distinct features not all present in any current tool: no code or database changes needed for the application under test, fully dynamic responses, local response storage for complex scenarios, transparent traffic routing, dynamic generation of SSL certificates to handle SSL verification of external services. It’s free, open source and can be found here: github.com/emanuil/nagual

1f686da361195e15bb4e478397a4fc8f?s=128

emanuil

December 08, 2016
Tweet

Transcript

  1. Service Virtualization on the Cheap emanuil.slavov@gmail.com @EmanuilSlavov

  2. 3 hours 3 minutes

  3. None
  4. Problems with 3rd party services Unreliable Network Throttling Costly Can’t

    Control Output
  5. Service Virtualization to the Rescue

  6. Your Options

  7. Record and Replay Application External Service Storage First Request Next

    Request
  8. Pros Cons Uses real recorded data Refreshes automatically Returns only

    recorded data Framework specific Easy to setup for simple APIs Requires network
  9. Stubs In The Code Application External Service Internal Logic Should

    call the real API Should fake the request
  10. None
  11. Pros Cons No need for network Access to internal app

    state Monolithic applications only Cheap to setup Do not cover low level code May cause havoc in production
  12. Simulation Application Facebook Paypal Amazon S3

  13. Facebook Application Paypal Amazon S3 Proxy Simulation

  14. Basic Functionality

  15. Existing Tools (March 2016) Transparent Fake SSL certs Dynamic Responses

    Local Storage Return Binary Data Regex URL match Stubby4J WireMock Wilma soapUI MockServer mounteback Hoverfly Mirage
  16. So we decided to create our own.

  17. Written in Node.JS Pluggable architecture Optimized for speed Battle tested:

    Facebook, Twitter, Instagram It’s free, examples included
  18. github.com/emanuil/nagual Project Nagual

  19. Enough talk, let’s DEMO!

  20. Basic Scenario

  21. None
  22. Advanced Scenario

  23. POST /v2.2/12345678/comments { id: 99997777 } GET /v2.2/99997777 { id:

    99997777
 message: “my new comment” timestamp: 1481923013 more_fields: “yes” } {message: “my new comment”} Application (request) Facebook (response)
  24. The POST Stub

  25. None
  26. The GET Stub

  27. None
  28. Monitoring

  29. Since Nagual acts as a MiTM proxy, all passing traffic

    can be inspected.
  30. None
  31. None
  32. None
  33. None
  34. Future Work

  35. Simulate other protocols - e.g. SMTP Random generation of non-latin

    text encodings API access to the logs
  36. Roll Your Own

  37. Nagual core is only 700 lines of code Modifying HTTP

    is easy in Node.JS Future out what features you need
  38. Recommended Reading

  39. EmanuilSlavov.com @EmanuilSlavov speakerdeck.com/emanuil

  40. None