184
@mogronalol Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

Simulating APIs for Effective Testing: (Micro)Service Virtualisation

1

Andrew Morgan @mogronalol

OpenCredo & Spectolabs

Page 2: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 2

About Me

• Consultant at OpenCredo • Background mainly with

Java and now Go • Spectolabs

Andrew Morgan @mogronalol

Page 3: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 3

Agenda

Page 4: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 3

Agenda

• The problems with operating and testing distributed systems and microservices

Page 5: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 3

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation

Page 6: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 3

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation• Improving our Tests

Page 7: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 3

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation• Improving our Tests• Data Synchronisation

Page 8: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 3

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation• Improving our Tests• Data Synchronisation• Summary

Page 9: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 4

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation • Improving our Tests • Data Synchronisation • Summary

Page 10: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

-INFOX

5

Distributed Systems

Page 11: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

Microservices

6

Payment

Company

Booking

Flights

Auth

Page 12: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

Microservices

6

Payment

Company

Booking

Flights

Auth

Page 13: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

A natural evolution...

7

Page 14: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

Challenges…

8

Page 15: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 9

Airline Booking Application

Page 16: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 9

Airline Booking Application

• Microservice architecture

Page 17: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 9

Airline Booking Application

• Microservice architecture• Integration with third party services

Page 18: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 9

Airline Booking Application

• Microservice architecture• Integration with third party services• Integration with legacy internal services

Page 19: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 9

Airline Booking Application

• Microservice architecture• Integration with third party services• Integration with legacy internal services• Heavy resource consumption

Page 20: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 9

Airline Booking Application

• Microservice architecture• Integration with third party services• Integration with legacy internal services• Heavy resource consumption• A standard CI/CD pipeline

Page 21: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Page 22: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Page 23: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Page 24: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Page 25: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Payments

Page 26: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Payments

Fraud

Page 27: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Payments

Fraud

Page 28: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Payments

Fraud

Page 29: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Payments

Fraud

Page 30: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 10

Resources

Booking

Flights

Rewards

Payments

Fraud

Cost

Page 31: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 11

Page 32: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 12

Licensing

Page 33: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 12

Licensing

Consumer

Producer

Page 34: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 12

Licensing

Consumer

Producer

Third party

Page 35: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 12

Licensing

Consumer

Producer

Consumer

Producer

Third party

Page 36: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 12

Licensing

Consumer

Producer

Consumer

Producer

Third party Cost

Page 37: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 13

Dependency Constraints

Page 38: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 13

Dependency Constraints

Consumer

Producer

Page 39: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 13

Dependency Constraints

Consumer

Producer

Page 40: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 13

Dependency Constraints

Consumer

Producer

Consumer

Producer

Page 41: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 14

Flakey Dependencies

Page 42: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 14

Flakey Dependencies

Consumer

Producer

Page 43: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 14

Flakey Dependencies

Consumer

Producer

Consumer

Producer

Page 44: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 15

Doesn't exist

Page 45: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 15

Doesn't exist

Consumer

?

Page 46: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 16

Non Deterministic

Page 47: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 16

Non Deterministic

Consumer

Booking Service

Page 48: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 16

Non Deterministic

Consumer

Booking Service {

“date” : “2013-01-08”, … }

Page 49: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 16

Non Deterministic

assertThat(booking.getDate()) .isEqualTo(LocalDate.of(2013,1,8));

Consumer

Booking Service {

“date” : “2013-01-08”, … }

Page 50: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 16

Non Deterministic

assertThat(booking.getDate()) .isEqualTo(LocalDate.of(2013,1,8));

Consumer

Booking Service {

“date” : “2013-01-08”, … }

Page 51: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 16

Non Deterministic

assertThat(booking.getDate()) .isEqualTo(LocalDate.of(2013,1,8));

Consumer

Booking Service {

“date” : “2016-02-07”, … }

Page 52: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 17

Fault Injection

Page 53: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 17

Fault Injection

Consumer

Producer

Page 54: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 17

Fault Injection

Consumer

Producer

Consumer

Producer

Page 55: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 17

Fault Injection

Consumer

Producer

Consumer

Producer

4xx, 5xx, timeouts

Page 56: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 17

Fault Injection

Consumer

Producer

Consumer

Producer

4xx, 5xx, timeouts

Operationally challenging to trigger

faults

Page 57: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 18

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation • Improving our Tests • Data Synchronisation • Summary

Page 58: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 19

Service Virtualisation

Page 59: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 19

Service Virtualisation

• Emulation of real service

Page 60: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 19

Service Virtualisation

• Emulation of real service• Non-intrusive

Page 61: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 19

Service Virtualisation

• Emulation of real service• Non-intrusive• Lightweight - or should be

Page 62: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 20

Service Virtualisation

Page 63: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 20

Service Virtualisation

Consumer

Page 64: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 20

Service Virtualisation

Consumer Producer

Page 65: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 20

Service Virtualisation

Consumer Virtual Producer

Page 66: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 21

Creating Data

Page 67: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 21

Creating Data

Consumer

Page 68: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 21

Creating Data

Consumer Producer

Page 69: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 21

Creating Data

Consumer ProducerService

Virtualisation Tool

Page 70: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 22

Creating Data

https://github.com/tomakehurst/wiremock

Page 71: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 23

Proxy Mode

Page 72: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 23

Proxy Mode

Consumer

Page 73: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 23

Proxy Mode

Consumer Producer

Page 74: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 23

Proxy Mode

Consumer ProducerService

Virtualisation Tool

Page 75: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 24

Webserver / Facade Mode

Page 76: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 24

Webserver / Facade Mode

Consumer

Page 77: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 24

Webserver / Facade Mode

Consumer Producer

Page 78: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 24

Webserver / Facade Mode

Consumer Producer

Page 79: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 24

Webserver / Facade Mode

Consumer Producer

Service Virtualisation

Tool

Page 80: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 24

Webserver / Facade Mode

Consumer Producer

Service Virtualisation

Tool

Page 81: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 25

Not Mocking

Service Under Test

Dependant Service

Http

Page 82: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 25

Not Mocking

Service Under Test

Mocking

Dependant Service

Http

Page 83: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 25

Not Mocking

Service Under Test

Mocking

Page 84: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 25

Not Mocking

Service Under Test

Virtual Service

Page 85: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 25

Not Mocking

Service Under Test

Virtual Service

Mocks bleed into the architectural boundary of your

application

Page 86: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 26

Open Source Tooling

Page 87: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 26

Open Source Tooling

Page 88: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 26

Open Source Tooling

Page 89: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 26

Open Source Tooling

Page 90: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 27

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation • Improving our Tests • Data Synchronisation • Summary

Page 91: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 28

Record and replay

Page 92: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 28

Record and replay

Consumer

Page 93: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 28

Record and replay

Consumer External Producer

Page 94: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 28

Record and replay

Consumer External Producer

Service Virtualisati

on Tool

Page 95: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 28

Record and replay

Consumer External Producer

Service Virtualisati

on Tool

Page 96: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 29

JUnit Example

Page 97: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 29

JUnit Example

@Testpublic void shouldBeAbleToRetrieveABooking() throws URISyntaxException { // Given final int bookingId = 1; // When final Booking booking = bookingServiceGateway.getBooking(bookingId); // Then assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”); assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));}

Page 98: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 29

JUnit Example

@Rule public HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode(“src/test/resources/external.json").build();

@Testpublic void shouldBeAbleToRetrieveABooking() throws URISyntaxException { // Given final int bookingId = 1; // When final Booking booking = bookingServiceGateway.getBooking(bookingId); // Then assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”); assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));}

Page 99: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 30

JUnit Example{ "data": [ { "request": { "path": "/api/bookings/1", "method": "GET", "destination": "www.my-test.com", "query": null, "body": "" }, "response": { "status": 200, "body": “{\”customer\”:\”Andrew Morgan\", \”date\”: \”2016-03-01\”}}}”, "headers": { "Content-Type": [ "application/json" ] } } } ]}

Page 100: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 31

JUnit Example

@Testpublic void shouldBeAbleToRetrieveABooking() throws URISyntaxException { // Given final int bookingId = 1; // When final Booking booking = bookingServiceGateway.getBooking(bookingId); // Then assertThat(booking.getCustomer()).isEqualTo(“Andrew Morgan”); assertThat(booking.getDate()).isEqualTo(LocalDate.of(2016,3,1));}

@Rule public HoverflyRule hoverflyRule = HoverflyRule.buildFromClassPathResource(“external.json").build();

Page 101: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 32

Advantages

Page 102: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 32

Advantages

• Isolation

Page 103: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 32

Advantages

• Isolation• Flaky dependencies

Page 104: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 32

Advantages

• Isolation• Flaky dependencies• Rate limiting

Page 105: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 32

Advantages

• Isolation• Flaky dependencies• Rate limiting• Deterministic

Page 106: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 32

Advantages

• Isolation• Flaky dependencies• Rate limiting• Deterministic• Licensing

Page 107: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 33

Deployment and Infrastructure

Page 108: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 33

Deployment and Infrastructure

Consumer External Producer

Page 109: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 33

Deployment and Infrastructure

Consumer External Producer

Internal Producer

Internal Producer

Internal Producer

Page 110: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 33

Deployment and Infrastructure

Consumer

Virtual Service

Virtual Service

Virtual Service

Virtual Service

Page 111: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

Page 112: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

$ hoverctl start —proxy-port 8080

Page 113: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

$ hoverctl start —proxy-port 8080$ hoverctl import accounts-service-simulation.json

Page 114: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

$ hoverctl start —proxy-port 8080$ hoverctl import accounts-service-simulation.json

$ hoverctl start —proxy-port 8081

Page 115: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

$ hoverctl start —proxy-port 8080$ hoverctl import accounts-service-simulation.json

$ hoverctl start —proxy-port 8081$ hoverctl import payments-service-simulation.json

Page 116: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

$ hoverctl start —proxy-port 8080$ hoverctl import accounts-service-simulation.json

$ hoverctl start —proxy-port 8081$ hoverctl import payments-service-simulation.json

$ curl http://www.account-service.com/api/v1/accounts/1 —proxy http://localhost:8080

[{"name":"foo"}]

Page 117: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 34

CLI Example

$ hoverctl start —proxy-port 8080$ hoverctl import accounts-service-simulation.json

$ hoverctl start —proxy-port 8081$ hoverctl import payments-service-simulation.json

$ curl http://www.account-service.com/api/v1/accounts/1 —proxy http://localhost:8080

[{"name":"foo"}]

$ curl http://www.payment-service.com/api/v1/payments/1 -proxy http://localhost:8081

[{“amount":"£23.27"}]

Page 118: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 35

Page 119: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 36

Fault Injection

Page 120: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 36

Fault Injection

Consumer External Producer

Service Virtualisation

Tool

Page 121: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 36

Fault Injection

Consumer External Producer

Service Virtualisation

Tool

Middleware

Page 122: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 37

Fault Injection

Page 123: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 38

Advantages

Page 124: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 38

Advantages

• Transparent

Page 125: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 38

Advantages

• Transparent• Configurable

Page 126: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 38

Advantages

• Transparent• Configurable• Operationally simple

Page 127: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 39

Documentation-Driven

Page 128: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 39

Documentation-Driven

Consumer ?

Page 129: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 39

Documentation-Driven

Consumer

Page 130: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 39

Documentation-Driven

Consumer

Transform

Page 131: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

Virtual Service

39

Documentation-Driven

Consumer

Transform

Page 132: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 40

Advantages

Page 133: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 40

Advantages

• Documentation Driven Development

Page 134: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 40

Advantages

• Documentation Driven Development• Work in Parallel

Page 135: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 41

Agenda

• The problems with operating and testing distributed systems and microservices

• Overview of Service Virtualisation / Api Simulation • Improving our Tests • Data Synchronisation • Summary

Page 136: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 42

Data Synchronisation Issues

Page 137: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 42

Data Synchronisation Issues

Consumer Virtual Service

Page 138: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 42

Data Synchronisation Issues

ConsumerConsumer Virtual Service

Page 139: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 42

Data Synchronisation Issues

ConsumerConsumerConsumer Real Service

Page 140: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 43

Ownership

Page 141: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 43

Ownership

Own Consumer Own Producer Strategy

Page 142: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 43

Ownership

Own Consumer Own Producer Strategy

Integration Contract Testing

Page 143: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 144: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

Scheduled Build

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 145: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

Scheduled Build

Reproduce Simulations

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 146: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

Scheduled Build

Reproduce Simulations Diff

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 147: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

Scheduled Build

Reproduce Simulations Diff

Integration Testing or

Contract Diff

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 148: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

Scheduled Build

Reproduce Simulations Diff

No diff?

Integration Testing or

Contract Diff

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 149: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 44

Integration Contract Testing

Scheduled Build

Reproduce Simulations Diff

No diff?

Diff?

Integration Testing or

Contract Diff

http://martinfowler.com/bliki/IntegrationContractTest.html

Page 150: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 45

Ownership

Own Consumer Own Producer Strategy

Integration Contract Testing

Page 151: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 45

Ownership

Own Consumer Own Producer Strategy

Integration Contract Testing

Virtual Service as First Class Citizen

Page 152: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 46

Virtual Service as First Class Citizen

Page 153: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 46

Virtual Service as First Class Citizen

Run and Capture

Service Tests

Page 154: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 46

Virtual Service as First Class Citizen

Run and Capture

Service Tests

Transform to simulation

Page 155: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 46

Virtual Service as First Class Citizen

Run and Capture

Service Tests

Transform to simulation

Publish Virtual Service

Page 156: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 46

Virtual Service as First Class Citizen

Run and Capture

Service Tests

Parse Contract

Transform to simulation

Publish Virtual Service

Page 157: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 46

Virtual Service as First Class Citizen

Run and Capture

Service Tests

Parse Contract

Transform to simulation

Parse Documentati

on

Publish Virtual Service

Page 158: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 47

Ownership

Own Consumer Own Producer Strategy

Integration Contract Testing

Virtual Service as First Class Citizen

Page 159: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 47

Ownership

Own Consumer Own Producer Strategy

Integration Contract Testing

Consumer Driven Contract Testing

Virtual Service as First Class Citizen

Page 160: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Page 161: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Page 162: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Page 163: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Implement Consumer

Page 164: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Implement Consumer

Page 165: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Generate Producer Contract

Tests

Implement Consumer

Page 166: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

Implement Producer

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Generate Producer Contract

Tests

Implement Consumer

Page 167: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

Implement Producer

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Generate Producer Contract

Tests

Implement Consumer

Run Consumer Contract

Tests

Page 168: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 48

Consumer Driven Contract Testing

Consumer Defines Contract

Implement Producer

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Generate Producer

Stubs

Generate Producer Contract

Tests

Implement Consumer

Run Consumer Contract

Tests

Page 169: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 49

Consumer Driven Contract Testing

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Page 170: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 49

Consumer Driven Contract Testing

Change producer

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Page 171: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 49

Consumer Driven Contract Testing

Change producer

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Run Consumer Contract

Tests

Page 172: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 49

Consumer Driven Contract Testing

Change producer

http://www.martinfowler.com/articles/consumerDrivenContracts.html

Run Consumer Contract

Tests

Page 173: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 50

Tools

Page 174: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 50

Tools

Page 175: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 50

Tools

Page 176: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 51

Testing Pyramid

End to end

Integration / Service Testing

Unit Testing

Page 177: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 51

Testing Pyramid

End to end

Integration / Service Testing

Unit Testing

Consumer Driven Contract Testing

Page 178: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 51

Testing Pyramid

End to end

Integration / Service Testing

Unit Testing

Consumer Driven Contract Testing

Page 179: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 52

Summary

Page 180: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 52

Summary

• Cost reduction from simulated services

Page 181: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 52

Summary

• Cost reduction from simulated services• Easy deployment of simulations

Page 182: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 52

Summary

• Cost reduction from simulated services• Easy deployment of simulations• Less dependant on end to end testing

Page 183: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol 52

Summary

• Cost reduction from simulated services• Easy deployment of simulations• Less dependant on end to end testing• Better feedback cycle

Page 184: Simulating APIs for Effective Testing: (Micro)Service ......Simulating APIs for Effective Testing: (Micro)Service Virtualisation 1 Andrew Morgan @mogronalol OpenCredo & Spectolabs

@mogronalol

Questions?

53

@mogronalol

https://github.com/mogronalol