+ All Categories
Home > Documents > Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual...

Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual...

Date post: 02-Jun-2020
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
35
Contract testing - Verification across service boundaries 1
Transcript
Page 1: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Contract testing-

Verification across service boundaries

1

Page 2: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Who am I?Peter Czibik@peteyycz

github.com/peteyycz

- Nerd - Senior Node JS developer- Linux enthusiast- Lover of programming

languages- Generally a nice guy

2

Page 3: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

We help companies succeed with microservices3

Page 4: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Who here works with microservices?4

Page 5: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Everyone loves microservices5

Page 6: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

A sad story of Atlassian- Two independent services: Payment and

Users

6

Page 7: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

A sad story of Atlassian- Two independent services: Payment and

Users

7

Page 8: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

A sad story of Atlassian- Changing a single letter in a json response

{

“user”: [ … ]

}

{

“users”: [ … ]

}

8

Page 9: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

9

There’s no worse thing than not letting users pay.

Page 10: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

How can we avoid problems like that?

10

Page 11: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

11

Page 12: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Everyone loves microservices12

Page 13: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

What kind of tests?

13

Page 14: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Testing- Unit tests- Integration tests- End-to-end tests

14

Page 15: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Those are not enough.

15

Page 16: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

16

Page 17: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Testing beyond borders- Separate codebases- Individual deployments- Multiple programming languages

17

Page 18: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Testing beyond borders

18

Page 19: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Testing beyond borders

19

Page 20: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

These concepts apply to both worlds.

20

Page 21: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Solution A

21

Page 22: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Mocking- Light on resources- No data pollution- Spares maintenance cost- Points out issues quickly- Idempotent- Not trustworthy

22

Page 23: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Solution B

23

Page 24: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Using an instance of the upstream service- Hard to use other team’s code- Trustworthy- Expensive- Non-Idempotent

24

Page 25: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Wrap up

- Idempotent- Light on resources- Cheap ($$$ and code)- CI compatible- Not trustworthy

- Non-Idempotent- Resource heavy- Expensive ($$$ and code)- Not CI compatible- Trustworthy

25

Mocking Extra instancevs.

Page 26: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Solution C

26

C for Contract

Page 27: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Contract ( ) Testing- A contract defines a fix interface ( ) between two parties- Both parties use this definition to test

27

Page 28: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Testing

28

- Uses real data- No extra infrastructure cost- Fast- Easy to scale- Quick setup- Stable- Reliable

Page 29: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Testing- Unit tests- Integration tests- End-to-end tests

29

Page 30: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Consumer Driven TestingImplementation steps:

1. Client makes expectations2. Client uses these expectations to test3. Serialize expectations to language independent format4. Transfer expectations to server5. Server uses those expectations to test

30

Page 31: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Meet Pact31

Page 32: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Pact- Implementation of a Consumer Driven Test Suite- JSON (language independent)- Libraries already exist in multiple languages

- .NET- JVM (Java & Scala)- Javascript

32

Page 33: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

33

Everyone stop.

It’s demo time!

Page 34: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

34

Page 35: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two

Thank you for your attention

35

¿Questions?


Recommended