Testing Microservices with Mountebank
Brandon Byars
  • MEAP began March 2017
  • Publication in Spring 2018 (estimated)
  • ISBN 9781617294778
  • 275 pages (estimated)
  • printed in black & white
Testing Microservices with Mountebank is your guide to the ins and outs of testing microservices with service virtualization. Starting from your first test with mountebank you'll dive into testing with canned responses, using predicates, and recording and replaying behavior to your tests. Following real world use-cases you'll master the art of programming mountebank with your own dynamic responses and explore working with binary protocols. This book also explains using mountebank for load testing, in a continuous delivery pipeline, and more.
Table of Contents detailed table of contents

Part 1: First steps

1. Testing Microservices

1.1. A microservices refresher

1.1.1. Microservices and organizational structure

1.2. The problem with end-to-end testing

1.3. Understanding service virtualization

1.3.1. Approaches to service virtualization

1.3.2. Putting service virtualization in context

1.4. Introducing mountebank

1.5. Summary

2. Taking Mountebank for a Test Drive

2.1. Setting Up The Example

2.2. HTTP And Mountebank: A Primer

2.3. Virtualizing the Product Catalog Service

2.4. Our First Test

2.5. Summary

Part 2: using mountebank

3. Testing Using Canned Responses

3.1. The Basics of Canned Responses

3.1.1. The Default Response

3.1.2. Understanding how the default response works

3.1.3. Changing the default response

3.1.4. Cycling through responses

3.2. HTTPS imposters

3.2.1. Setting up a trusted HTTPS imposter

3.2.2. Using mutual authentication

3.3. Saving the responses in a configuration file

3.3.1. Saving multiple imposters in the config file

3.4. Summary

4. Using Predicates to Send Different Responses

4.1. The basics of predicates

4.1.1. Types of predicates

4.1.2. Matching object request fields

4.1.3. The deepequals predicate

4.1.4. Matching multi-valued fields

4.1.5. The exists predicate

4.1.6. Conjunction Junction

4.1.7. A complete list of predicate types

4.2. Parameterizing predicates

4.2.1. Making case-sensitive predicates

4.3. Using predicates on JSON values

4.3.1. Using direct JSON predicates

4.3.2. Selecting a JSON value with JSONPath

4.4. Selecting XML values

4.5. Summary

5. Adding record / replay behavior

5.1. Setting up a proxy

5.2. Generating the correct predicates

5.2.1. Adding predicate parameters

5.3. Capturing multiple responses for the same request

5.4. Ways to replay a proxy

5.5. Configuring the proxy

5.5.1. Using mutual authentication

5.5.2. Adding custom headers

5.6. Proxy use cases

5.6.1. Using a proxy as a fallback

5.6.2. Converting HTTPS to HTTP

5.7. Summary

6. Programming mountebank

6.1. Creating your own predicate

6.2. Creating your own dynamic response

6.2.1. Adding state

6.2.2. Adding async

6.2.3. Deciding between response vs. predicate injection

6.3. A word of caution: security matters

6.4. Debugging tips

6.5. Summary

7. Adding behaviors

7.1. Understanding behaviors

7.2. Decorating a response

7.2.1. Using the decorate function

7.2.2. Adding decoration to saved proxy responses

7.2.3. Adding middleware through shellTransform

7.3. Adding latency to a response

7.4. Repeating a response multiple times

7.5. Replacing content in the response

7.5.1. Copying request data to the response

7.5.2. Looking up data from an external data source

7.6. A complete list of behaviors

7.7. Summary

8. Protocols

8.1. How protocols work in mountebank

8.2. A TCP primer

8.3. Stubbing text-based TCP-based RPC

8.3.1. Creating a basic TCP imposter

8.3.2. Creating a TCP proxy

8.3.3. Matching and manipulating an XML payload

8.4. Binary support

8.4.1. Using binary mode with Base64 encoding

8.4.2. Using predicates in binary mode

8.5. Virtualizing a .NET Remoting service

8.5.1. Creating a simple .NET Remoting client

8.5.2. Virtualizing the .NET Remoting server

8.5.3. How to tell mountebank where the message ends

8.6. Summary

Part 3: Closing the loop

9. Adding contract tests

10. Putting mountebank in a continuous delivery pipeline

11. Using mountebank for load testing

About the Technology

Microservices are independent, single-responsibility units of code that form a system with other microservices. It's difficult to test an individual microservice since each one depends on the other services. Mountebank solves this conundrum through service virtualization - imitating other components in the system so that you can test a microservice in isolation. Mountebank is the most capable service virtualization tool around, providing a programmable stand-in for a real dependency. As the only open-source virtualization tool with support for multiple protocols and scaling for load testing mountebank isn't snake oil; it's the cure-all for all your service virtualization needs.

What's inside

  • Approaches to service virtualization
  • Testing using canned responses
  • Programming mountebank
  • Understanding behaviors
  • Creating record / replay behavior
  • Adding contract tests

About the reader

Readers need programming skills and should be generally familiar with SOA or microservice systems.

About the author

Brandon Byars is a principal consultant at ThoughtWorks with long-standing experience in SOA and microservices. He is the author and chief maintainer of Mountebank and has helped multiple companies use it for testing a variety of systems.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
Buy
MEAP combo $49.99 pBook + eBook + liveBook
MEAP eBook $39.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks