31
Deploy with Confidence Consumer Driven Contract tests with Pact

Deploy with confidence

Embed Size (px)

Citation preview

Deploy with ConfidenceConsumer Driven Contract tests with Pact

Scenario

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Scenario (cont.)

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Test

Test

Test

Test Test

Scenario (cont.)

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Test

Test

Test

Test Test

Scenario (cont.)

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Test

Test

Test

Test Test

dev sit

test

dev sit

test

dev sit

test

Scenario (cont.)

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Test

Test

Test

Test Test

Scenario (cont.)

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Test

Test

Test

Test Test3RD PARTY SOFTWARE

“Integrated tests are a scam”

Talk by J. B. (Joe) Rainsberger

http://bit.ly/29IHASL(presentation)

http://bit.ly/29uw8GX(blogpost)

“Integrated tests are a scam”

▪ They take too long to run

▪ Infrastructure pain

▪ Unreliable

▪ Costly

Consumer Driven Contracts(Testing)

Ian Robinson

Consumer Driven Contract (Testing)

List of agreements between Consumer and Provider

Consumer Driven Contract (Testing)

List of agreements between Consumer and ProviderRequest / Response pair

Consumer Driven Contract (Testing)

Consumer Driven Contract is a pattern that

drives the development of the Provider

from its Consumers point of view

Micro Service 1

Micro Service 2 Micro Service 3 Micro Service 4

Consumer 2

Provider Consumer 1 Consumer 3

Consumer 2

Provider Consumer 1 Consumer 3

Consumer 2

Provider Consumer 1 Consumer 3

Benefits?

▪ Provider knows when a consumer will break

▪ Documentation

▪ Test independence

Pact

Pact is a testing tool that guaranteesthose Contracts are satisfied

pact.io

Pact

▪ Essentially TDD for Services

▪ Fail fast, recover fast

▪ Started at REA with a Ruby implementation

▪ Now available in

▪ JVM (Java, Scala, Groovy)

▪ .NET

▪ Javascript / Node▪ Go▪ Swift

2-Step Process

2-Step Process

Pact JS

▪ Under github.com/pact-foundation

▪ pact-js

▪ karma-pact

▪ pact-node

▪ pact-js-mocha (WIP)

karma-pact

▪ Plugin for Karma

▪ Manages Provider Mock Server

Pact Node

▪ Wraps the Ruby Provider Mock Server

▪ Allows for interaction recording and verification

▪ Enables Pact publishing

▪ Enables management of multiple servers

Pact JS Mocha

▪ Abstracts the DSL

▪ “Extends” Mocha’s BDD interface

▪ Less boilerplate

▪ Improved readability

▪ Still WIP (feedback welcome!)

Code

Consumer

HTTPClient

Provider

GET consumer/projects/1/tasks

GET provider/tasks

Sharing Pacts

▪ Pact Broker

▪ There’s even a Docker container!▪ Has to run on port 80 though

Pact JS

▪ docs.pact.io

▪ Gitter

▪ gitter.im/pact-foundation

▪ gitter.im/realestate-com-au/pact

▪ gitter.im/DiUS/pact-jvm

▪ groups.google.com/forum/#!forum/pact-support

Finding Help

Thanks! Questions?

@tarciosaraiva @pact_up