Removing complexity from integration tests using Testcontainers!

A presentation at DevOpsCon London in April 2022 in London, UK by Oleg Šelajev

Slide 1

Slide 1

Removing complexity from integration tests

Slide 2

Slide 2

e2e Integration tests Unit tests By Unknown author - U.S. Army Photo, Public Domain, https://commons.wikimedia.org/w/index.php?curid=55124

Slide 3

Slide 3

Microservices Testing Honeycomb https://labs.spotify.com/2018/01/11/testing-of-microservices/

Slide 4

Slide 4

Oleg Šelajev Developer relations @shelajev github.com/shelajev oleg@atomicjar.com

Slide 5

Slide 5

https://martinfowler.com/bliki/IntegrationTest.html

Slide 6

Slide 6

https://martinfowler.com/bliki/IntegrationTest.html

Slide 7

Slide 7

https://martinfowler.com/bliki/IntegrationTest.html

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

• Process isolation • FileSystem, Network • CPU/memory limits

Slide 11

Slide 11

• Con guring multiple services simultaneously • Flexibility in creating test data or use-cases • Separation of production & test environments • Dynamic con guration of external mappings • Parallel deployments fi fi 😓

Slide 12

Slide 12

testcontainers.org

Slide 13

Slide 13

Testcontainers • Created 7 years ago • github.com/testcontainers/testcontainers-java • Uses docker-java API • Automatic Docker environment discovery • Automatic cleanup

Slide 14

Slide 14

Slide 15

Slide 15

We think it’s a useful default option for creating a reliable environment for running tests. … Our teams have consistently found this library of programmable, lightweight and disposable containers to make functional tests more reliable. https://www.thoughtworks.com/en-us/radar/languages-and-frameworks/testcontainers

Slide 16

Slide 16

Downloads

Slide 17

Slide 17

Unique IPs

Slide 18

Slide 18

Show me the code

Slide 19

Slide 19

Model: record Rating (String talkId, Integer value) {}

Slide 20

Slide 20

What’s next? Reusable containers Networks for more complex topologies Custom startup & waiting strategies Creating images on-the- y fl fi Logs, les, commands, limits…

Slide 21

Slide 21

What to do if you have no Docker?

Slide 22

Slide 22

Docker environments https://www.atomicjar.com/2021/10/docker-on-windows-and-macos

Slide 23

Slide 23

Testcontainers Cloud testcontainers.cloud

Slide 24

Slide 24

What’s next? — www.testcontainers.org — github.com/testcontainers/testcontainers-java ! — github.com/testcontainers/workshop

Slide 25

Slide 25

Thanks!