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

Service Virtualization On The Cheap (Agile Testing Days 2016)

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

emanuil

December 08, 2016
Tweet

More Decks by emanuil

Other Decks in Programming

Transcript

  1. Service Virtualization
    on the Cheap
    [email protected]
    @EmanuilSlavov

    View Slide

  2. 3
    hours
    3
    minutes

    View Slide

  3. View Slide

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

    View Slide

  5. Service Virtualization
    to the Rescue

    View Slide

  6. Your Options

    View Slide

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

    View Slide

  8. Pros Cons
    Uses real recorded data
    Refreshes automatically Returns only recorded data
    Framework specific
    Easy to setup for simple APIs Requires network

    View Slide

  9. Stubs In The Code
    Application
    External Service
    Internal Logic
    Should
    call the
    real API
    Should
    fake the
    request

    View Slide

  10. View Slide

  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

    View Slide

  12. Simulation
    Application
    Facebook
    Paypal
    Amazon
    S3

    View Slide

  13. Facebook
    Application Paypal
    Amazon
    S3
    Proxy
    Simulation

    View Slide

  14. Basic Functionality

    View Slide

  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

    View Slide

  16. So we decided to create
    our own.

    View Slide

  17. Written in Node.JS
    Pluggable architecture
    Optimized for speed
    Battle tested: Facebook, Twitter, Instagram
    It’s free, examples included

    View Slide

  18. github.com/emanuil/nagual
    Project Nagual

    View Slide

  19. Enough talk,
    let’s DEMO!

    View Slide

  20. Basic Scenario

    View Slide

  21. View Slide

  22. Advanced Scenario

    View Slide

  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)

    View Slide

  24. The POST Stub

    View Slide

  25. View Slide

  26. The GET Stub

    View Slide

  27. View Slide

  28. Monitoring

    View Slide

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

    View Slide

  30. View Slide

  31. View Slide

  32. View Slide

  33. View Slide

  34. Future Work

    View Slide

  35. Simulate other protocols - e.g. SMTP
    Random generation of non-latin text encodings
    API access to the logs

    View Slide

  36. Roll Your Own

    View Slide

  37. Nagual core is only 700 lines of code
    Modifying HTTP is easy in Node.JS
    Future out what features you need

    View Slide

  38. Recommended Reading

    View Slide

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

    View Slide

  40. View Slide