FC-7093, Annual Contract for Electrical Testing & Inspections
Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual...
Transcript of Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual...
![Page 1: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/1.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/2.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/3.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/4.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/5.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/6.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/7.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/9.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/10.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/11.jpg)
11
![Page 12: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/12.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/13.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/14.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/15.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/16.jpg)
16
![Page 17: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/17.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/18.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/19.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/20.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/21.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/22.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/23.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/24.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/25.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/26.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/27.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/28.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/29.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/30.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/31.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/32.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/33.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/34.jpg)
34
![Page 35: Contract testing - Amazon S3 · Testing beyond borders - Separate codebases - Individual deployments ... Contract ( !) Testing - A contract defines a fix interface ( !) between two](https://reader035.fdocuments.in/reader035/viewer/2022070718/5ede1c9ead6a402d66696637/html5/thumbnails/35.jpg)
Thank you for your attention
35
¿Questions?