Slide 1

Slide 1 text

Service Virtualization on the Cheap [email protected] @EmanuilSlavov

Slide 2

Slide 2 text

3 hours 3 minutes

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Service Virtualization to the Rescue

Slide 6

Slide 6 text

Your Options

Slide 7

Slide 7 text

Record and Replay Application External Service Storage First Request Next Request

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Simulation Application Facebook Paypal Amazon S3

Slide 13

Slide 13 text

Facebook Application Paypal Amazon S3 Proxy Simulation

Slide 14

Slide 14 text

Basic Functionality

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

So we decided to create our own.

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

github.com/emanuil/nagual Project Nagual

Slide 19

Slide 19 text

Enough talk, let’s DEMO!

Slide 20

Slide 20 text

Basic Scenario

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

Advanced Scenario

Slide 23

Slide 23 text

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)

Slide 24

Slide 24 text

The POST Stub

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

The GET Stub

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Monitoring

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Future Work

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

Roll Your Own

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

Recommended Reading

Slide 39

Slide 39 text

EmanuilSlavov.com @EmanuilSlavov speakerdeck.com/emanuil

Slide 40

Slide 40 text

No content